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

Paste this into your coding agent:

```text
Help me set up the Respan gateway with the Microsoft Agent Framework integration.
Follow https://www.respan.ai/docs/integrations/gateway/microsoft-agent-framework.md
```

## Setup

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

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

</Step>

<Step title="Set environment variables">

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

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

</Step>

<Step title="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://gateway.respan.ai"),
        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.
</Note>

</Step>
</Steps>

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