---
title: "AutoGen (gateway)"
description: "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.

Paste this into your coding agent:

```text
Help me set up the Respan gateway with the AutoGen integration.
Follow https://www.respan.ai/docs/integrations/gateway/auto-gen.md
```

## Setup

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

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

</Step>

<Step title="Set environment variables">

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

</Step>

<Step title="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://gateway.respan.ai",
    model_info={
        "vision": False,
        "function_calling": True,
        "json_output": True,
        "structured_output": True,
        "family": "unknown",
    },
)
```

</Step>
</Steps>

## 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://gateway.respan.ai",
    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).
