Skip to main content
Microsoft Agent Framework is Microsoft’s open-source SDK for building AI agents and multi-agent workflows in Python and .NET. Its OpenAI clients work with any OpenAI-compatible endpoint, so you can point them at DeepInfra and use any LLM from our catalog. There is no DeepInfra-specific package; you use the standard OpenAI Chat Completions client with a custom base URL.

Installation

Get your API key from the Dashboard and export it as DEEPINFRA_TOKEN.

Configuration

Create the Chat Completions client with DeepInfra’s base URL and your API key, then build an agent from it. Everything else works as described in the Agent Framework docs.
Use the Chat Completions client only: OpenAIChatCompletionClient in Python, GetChatClient() in .NET. OpenAIChatClient (Python) and GetResponsesClient() (.NET) target the OpenAI Responses API, which DeepInfra does not serve.
Function tools, sessions, and structured output need no DeepInfra-specific setup. response_format with json_schema and strict: true is supported on many models; see Structured Outputs.
To pick a model, list the catalog with context windows and pricing via /v1/openai/models?filter=with_meta&sort_by=maf. Each entry’s metadata block has context_length, max_tokens, and per-million-token pricing; the id is what you pass as model.

Environment variables

The Python clients fall back to OPENAI_API_KEY, OPENAI_BASE_URL, and OPENAI_CHAT_COMPLETION_MODEL when constructor arguments are omitted, so you can also configure them that way:
If a real OpenAI key is already set in OPENAI_API_KEY, the client will send it to DeepInfra. Passing api_key and base_url explicitly, as above, avoids that.

Embeddings

OpenAIEmbeddingClient takes the same arguments. Use any embedding model from the catalog.

Reasoning models

DeepInfra returns the chain-of-thought of reasoning models in a reasoning_content field, in both the final message and each streaming delta. Agent Framework does not read that field natively, but its response_parser hook lets you surface it as text_reasoning content. Set reasoning_effort through options; any key there is forwarded to the OpenAI SDK, and DeepInfra-only parameters can go in options={"extra_body": {...}}.
DeepInfra does not require reasoning to be echoed back on later turns, so no message_preparer is needed; sessions and tool-call loops work with this parser as-is.

Learn more

Agent Framework docs

Agents, tools, sessions, structured output, workflows, and observability.

OpenAI-compatible endpoints

Agent Framework’s guidance on adapting its OpenAI client to other providers.
Agent Framework is under active development and API names change between releases; see the Python changelog. Tested with agent-framework-openai 1.14.2, openai 3.11.0, and Microsoft.Agents.AI.OpenAI 1.20.0.