Skip to main content

Proxy Server Integration

LiteLLM can also be used as an OpenAI-compatible proxy server, allowing you to route requests to different models through a unified API.

Starting the Proxy Server

First, install LiteLLM with proxy support and the openai package, which LiteLLMOpenAI uses as its client:
Start the proxy server:

Set Your API Key

LiteLLMOpenAI requires the LITELLM_API_KEY environment variable to authenticate requests to the proxy server:

Using the Proxy

The LiteLLMOpenAI class connects to the LiteLLM proxy using an OpenAI-compatible interface:

Configuration Options

The LiteLLMOpenAI class accepts the following parameters: LiteLLMOpenAI is a subclass of the OpenAILike class and has access to the same params.

Examples

View more examples here.