---
title: "LiteLLM (gateway)"
description: "Set up LiteLLM with the Respan gateway."
---

Route LiteLLM requests through the Respan gateway to use 1000+ models from different providers. Only your `RESPAN_API_KEY` is needed - no separate provider keys required.

Paste this into your coding agent:

```text
Help me set up the Respan gateway with the LiteLLM integration.
Follow https://www.respan.ai/docs/integrations/gateway/lite-llm.md
```

## Setup

<Steps>
<Step title="Install packages">

```bash
pip install litellm
```

</Step>

<Step title="Set environment variables">

```bash
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
```

No provider key needed - the Respan gateway handles provider authentication.

</Step>

<Step title="Point LiteLLM to the Respan gateway">

```python
import os
import litellm

response = litellm.completion(
    api_key=os.environ["RESPAN_API_KEY"],
    api_base="https://gateway.respan.ai",
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```

</Step>
</Steps>

## Switch models

Use another OpenAI model ID through the same gateway endpoint.

```python
messages = [{"role": "user", "content": "Hello!"}]

litellm.completion(
    api_key=os.environ["RESPAN_API_KEY"],
    api_base="https://gateway.respan.ai",
    model="gpt-5.5",
    messages=messages,
)
litellm.completion(
    api_key=os.environ["RESPAN_API_KEY"],
    api_base="https://gateway.respan.ai",
    model="gpt-5-mini",
    messages=messages,
)
```

<Note>
LiteLLM can be forced onto its OpenAI transport for non-OpenAI models, but that makes the transport provider easy to confuse with the model provider. This page avoids showing Claude or Gemini as OpenAI-provider models; use the Respan API or OpenAI SDK gateway pages for provider-neutral Claude and Gemini examples.
</Note>

See the [full model list](https://platform.respan.ai/platform/models).

## Respan parameters

Pass additional Respan parameters via `extra_body` for gateway features.

```python
response = litellm.completion(
    api_key=os.environ["RESPAN_API_KEY"],
    api_base="https://gateway.respan.ai",
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello!"}],
    extra_body={
        "customer_identifier": "user-123",
        "metadata": {"session_id": "abc123"},
        "session_identifier": "conversation_456",
    },
)
```

See [Respan params & metadata](/docs/ai-gateway/customers/respan-params) for the full list.
