Skip to main content
The OpenAILike class lets you connect to any LLM provider that implements the OpenAI chat completions API. This includes self-hosted models (vLLM, Ollama, LiteLLM), cloud providers with OpenAI-compatible endpoints, and custom proxies.

Basic Usage

Parameters

str
required
Model identifier as expected by the target provider.
str
API key for authentication.
str
required
The base URL of the OpenAI-compatible API endpoint.
str
Human-readable name for this model instance.
str
Provider name for logging and metrics.
bool
default:"false"
Whether the provider supports OpenAI-style structured outputs.

Examples

Ollama

vLLM

LiteLLM Proxy

Azure OpenAI

Streaming

Creating Custom Provider Classes

For repeated use, subclass OpenAILike:
This is exactly how DeepSeekChat, MoonshotChat, and xAI are implemented internally.