Microsoft Agent Framework
Microsoft 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
Before starting, prepare the following:
- A Python environment supported by Microsoft Agent Framework.
- A running AISIX gateway with the proxy listener available.
- An AISIX caller API key.
- A model alias the caller API key can access through the Responses API.
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:
# Replace with your values
export AISIX_BASE_URL="http://127.0.0.1:3000/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 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
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/responsesrequest for theOpenAIChatClientpath, or a successfulPOST /v1/chat/completionsrequest for the Semantic Kernel fallback.
If you use AISIX Cloud or an on-premises managed control plane, verify the request in the managed gateway logs. For self-hosted gateways, use your configured logs, 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. 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
- Responses API: review gateway-facing Responses behavior.
- OpenAI-Compatible API: use Chat Completions when a workflow needs broad OpenAI-compatible support.
- Tool Calling: confirm tool-call behavior before enabling agent tools.