> 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.

# Microsoft Agent Framework (gateway)

> Set up Microsoft Agent Framework with the Respan gateway.

Route Microsoft Agent Framework model calls through the Respan gateway to use models and provider credentials configured in Respan. Only your `RESPAN_API_KEY` is needed in the application.

## Setup

#### Install packages

```bash
pip install agent-framework-openai
```

#### Set environment variables

```bash
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
export RESPAN_BASE_URL="https://api.respan.ai/api"
export RESPAN_MODEL="gpt-5-mini"
```

No `OPENAI_API_KEY` is needed when the request is routed through the Respan gateway.

#### Point Agent Framework to the Respan gateway

```python
import asyncio
import os

from agent_framework import Agent, tool
from agent_framework.openai import OpenAIChatCompletionClient

@tool
def lookup_weather(city: str) -> str:
    return f"The weather in {city} is sunny."

async def main() -> None:
    client = OpenAIChatCompletionClient(
        api_key=os.environ["RESPAN_API_KEY"],
        base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
        model=os.getenv("RESPAN_MODEL", "gpt-5-mini"),
    )

    agent = Agent(
        client=client,
        name="weather_agent",
        instructions="Use the weather tool when asked about weather.",
        tools=[lookup_weather],
    )
    result = await agent.run("What is the weather in Seattle?")
    print(result)

asyncio.run(main())
```

> **Note**
>
> Use `OpenAIChatCompletionClient` for the gateway path. Agent Framework clients that target the Responses API may use a different endpoint shape than this OpenAI-compatible chat-completions route.

## Switch models

Change `RESPAN_MODEL` to another model available in your Respan account.

```bash
export RESPAN_MODEL="gpt-5.5"
export RESPAN_MODEL="gpt-5-mini"
```

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