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

Route Smolagents' underlying LLM calls through the Respan gateway to use 1000+ models from different providers. Only your `RESPAN_API_KEY` is needed. No separate provider keys are required.

Paste this into your coding agent:

```text
Help me set up the Respan gateway with the Smolagents integration.
Follow https://www.respan.ai/docs/integrations/gateway/smolagents.md
```

## Setup

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

```bash
pip install smolagents litellm
```

</Step>

<Step title="Set environment variables">

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

No `OPENAI_API_KEY` needed. The Respan gateway handles provider authentication.

</Step>

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

```python
import os
from smolagents import CodeAgent, LiteLLMModel

model = LiteLLMModel(
    model_id="openai/gpt-5.5",
    api_key=os.environ["RESPAN_API_KEY"],
    api_base="https://gateway.respan.ai",
)

agent = CodeAgent(tools=[], model=model)
print(agent.run("What is the capital of France?"))
```

</Step>
</Steps>

## Switch models

Use another OpenAI model ID through the same gateway-backed LiteLLM model wrapper.

```python
LiteLLMModel(model_id="openai/gpt-5.5", api_key=..., api_base="https://gateway.respan.ai")
LiteLLMModel(model_id="openai/gpt-5-mini", api_key=..., api_base="https://gateway.respan.ai")
```

<Note>
Smolagents uses LiteLLM provider namespaces. This page avoids showing Claude or Gemini behind an `openai/` prefix; 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).
