# Microsoft Agent Framework

[Microsoft Agent Framework](https://learn.microsoft.com/en-us/agent-framework/) supports Python, C#, and Go workflows for building agents, tools, context providers, middleware, and AI applications. AISIX fits at the model request boundary when the application uses an OpenAI-compatible client with a custom endpoint.

This guide uses the Python `OpenAIChatClient`, which uses the Responses API and supports OpenAI-compatible endpoints through `base_url`. You will configure the client with an AISIX proxy URL, caller API key, and model alias.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

Before starting, prepare the following:

* A Python environment supported by [Microsoft Agent Framework](https://learn.microsoft.com/en-us/agent-framework/).
* A running AISIX gateway that the application can reach.
* An AISIX caller API key.
* A model alias the caller API key can access through the [Responses API](https://docs.api7.ai/ai-gateway/endpoints/responses-api.md).

If AISIX is already deployed for your organization, obtain the gateway URL, model alias, and caller API key from the team that manages it. Otherwise, follow the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md) or [AISIX Enterprise getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/aisix-cloud-quickstart.md), or [contact API7](https://api7.ai/contact) for AISIX Cloud access.

## Configure Microsoft Agent Framework[​](#configure-microsoft-agent-framework "Direct link to Configure Microsoft Agent Framework")

Install the OpenAI provider package if the application does not already include it:

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

Set the values that the agent application will use:

```
# AISIX_BASE_URL ends in /v1 and has no trailing slash

# The local quickstarts use http://127.0.0.1:3000/v1

export AISIX_BASE_URL="YOUR_AISIX_GATEWAY_URL/v1"

export AISIX_API_KEY="YOUR_CALLER_API_KEY"

export AISIX_MODEL="gpt-4o-prod"
```

Create an `OpenAIChatClient` with the AISIX values and convert it to an agent:

```
import asyncio

import os



from agent_framework.openai import OpenAIChatClient



client = OpenAIChatClient(

  base_url=os.environ["AISIX_BASE_URL"],

  api_key=os.environ["AISIX_API_KEY"],

  model=os.environ["AISIX_MODEL"],

)



agent = client.as_agent(

  name="GatewayAgent",

  instructions="You answer in one concise sentence.",

)





async def main():

  response = await agent.run("Why do gateways help AI teams?")

  print(response)





asyncio.run(main())
```

Microsoft documents `OpenAIChatCompletionClient` as the [Chat Completions fallback](https://learn.microsoft.com/en-us/agent-framework/agents/providers/openai#chat-completion-client) for broad model compatibility or existing Chat Completions integrations.

If your application still uses Semantic Kernel, configure its OpenAI chat completion connector with the AISIX endpoint instead:

```
#pragma warning disable SKEXP0010



builder.AddOpenAIChatCompletion(

  modelId: Environment.GetEnvironmentVariable("AISIX_MODEL")!,

  endpoint: new Uri(Environment.GetEnvironmentVariable("AISIX_BASE_URL")!),

  apiKey: Environment.GetEnvironmentVariable("AISIX_API_KEY")!

);



#pragma warning restore SKEXP0010
```

The model value is the AISIX model alias, not the upstream provider model ID. AISIX governs the model request path, while the Microsoft framework code still owns agents, tools, context providers, middleware, prompts, and workflow behavior.

## Verify the Integration[​](#verify-the-integration "Direct link to Verify the Integration")

Run the application from the shell where the AISIX environment variables are set.

When the request succeeds, verify the following results:

* The application prints an agent response.
* AISIX records a successful `POST /v1/responses` request for the `OpenAIChatClient` path, or a successful `POST /v1/chat/completions` request for the Semantic Kernel fallback.

Verify the request in the AISIX gateway logs. You can also use configured metrics or upstream provider logs.

If the request fails, first confirm that the caller API key can access the selected model alias and that `base_url` points to the AISIX proxy API root with `/v1`.

Microsoft Agent Framework supports both [Responses and Chat Completions clients](https://learn.microsoft.com/en-us/agent-framework/agents/providers/openai). Use Chat Completions when you need broad OpenAI-compatible model support through AISIX.

Responses-hosted tools and provider-specific features may not map to every upstream provider. Validate Responses workflows before relying on gateway policy or telemetry for streaming, tools, or Responses-based hosted-tool behavior.

## Next Steps[​](#next-steps "Direct link to Next Steps")

* [Responses API](https://docs.api7.ai/ai-gateway/endpoints/responses-api.md): review gateway-facing Responses behavior.
* [OpenAI-Compatible API](https://docs.api7.ai/ai-gateway/endpoints/openai-compatible-chat.md): use Chat Completions when a workflow needs broad OpenAI-compatible support.
* [Tool Calling](https://docs.api7.ai/ai-gateway/endpoints/tool-calling.md): confirm tool-call behavior before enabling agent tools.
