Microsoft Agent Framework
The Microsoft Agent Framework is Microsoft's SDK for building AI agents and multi-agent systems. It supports custom OpenAI-compatible endpoints natively.
Install
pip install agent-framework-openai agent-framework-coreConfigure
from agent_framework import Message
from agent_framework_openai import OpenAIChatCompletionClient
import asyncio
client = OpenAIChatCompletionClient(
model="{{selectedModel.id}}",
base_url="https://api.doubleword.ai/v1",
api_key="{{apiKey}}",
)
async def main():
messages = [Message(role="user", contents=["Say hello."])]
response = await client.get_response(messages)
for content in response.messages[0].contents:
if hasattr(content, "text") and content.text:
print(content.text)
asyncio.run(main())Batch pricing with Autobatcher
For background tasks where latency is not critical, use Autobatcher to transparently route requests through the Batch API at reduced cost:
pip install agent-framework-openai agent-framework-core autobatcherfrom autobatcher import BatchOpenAI
from agent_framework import Message
from agent_framework_openai import OpenAIChatCompletionClient
import asyncio
batch_client = BatchOpenAI(
api_key="{{apiKey}}",
base_url="https://api.doubleword.ai/v1",
)
client = OpenAIChatCompletionClient(
model="{{selectedModel.id}}",
async_client=batch_client,
)
async def main():
messages = [Message(role="user", contents=["Say hello."])]
response = await client.get_response(messages)
for content in response.messages[0].contents:
if hasattr(content, "text") and content.text:
print(content.text)
await batch_client.close()
asyncio.run(main())BatchOpenAI is a drop-in AsyncOpenAI subclass that collects requests and submits them as batch jobs automatically, cutting inference costs by up to 90%.
Available clients
The framework provides three client types, all of which accept base_url and api_key:
| Client | Endpoint |
|---|---|
OpenAIChatCompletionClient | /chat/completions |
OpenAIChatClient | /responses (Responses API) |
OpenAIEmbeddingClient | /embeddings |
The Doubleword API supports all three endpoints.