> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://respan.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/docs/_mcp/server.

# AutoGen (gateway)

> Set up AutoGen with the Respan gateway.

Route AutoGen model calls through the Respan gateway to use 1000+ models. Only your Respan API key is needed — no separate provider key is required in the example process.

## Setup

#### Install packages

```bash
pip install autogen-agentchat "autogen-ext[openai]"
```

#### Set environment variables

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

#### Point AutoGen to the Respan gateway

```python
import os

from autogen_ext.models.openai import OpenAIChatCompletionClient

model_client = OpenAIChatCompletionClient(
    model="gpt-5-mini",
    api_key=os.environ["RESPAN_API_KEY"],
    base_url="https://api.respan.ai/api",
    model_info={
        "vision": False,
        "function_calling": True,
        "json_output": True,
        "structured_output": True,
        "family": "unknown",
    },
)
```

## Switch models

Change the `model` value to use a different model through the same gateway.

```python
model_client = OpenAIChatCompletionClient(
    model="claude-sonnet-4-5-20250929",
    api_key=os.environ["RESPAN_API_KEY"],
    base_url="https://api.respan.ai/api",
    model_info={
        "vision": False,
        "function_calling": True,
        "json_output": True,
        "structured_output": True,
        "family": "unknown",
    },
)
```

AutoGen requires `model_info` for any model name it does not recognize as an OpenAI model.

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