TL;DR - You can run DeepSeek and Gemini inside the OpenAI Agents SDK by configuring anAsyncOpenAIclient with custom base URLs and credentials. By wrapping these clients inOpenAIChatCompletionsModel, your agents gain full function-call compatibility across multiple LLM providers while cutting cloud API costs by up to 90 percent.
Understanding Custom Provider Compatibility in the Agents SDK 🤖
When I first started building multi-agent workflows, I wanted a way to experiment with different LLM providers without rewriting my entire agent loop. The OpenAI Agents SDK makes this possible because it relies on standard OpenAI-compatible API schemas. By substituting default API endpoints with vendor-specific URLs, you can plug in DeepSeek, Google Gemini, or local models running on Ollama directly into your Python scripts.

How does the Agents SDK communicate with non-OpenAI models behind the scenes? It treats them as standard chat completion endpoints. Because these third-party providers mirror the OpenAI API shape, you can wrap your client using OpenAIChatCompletionsModel from the SDK. This guarantees that your agents can still execute tool calls, handle structured outputs, and maintain conversation state seamlessly across different providers.
Setting Up AsyncOpenAI Clients for DeepSeek and Gemini ⚙️
Connecting custom models begins with initializing an AsyncOpenAI client configured with your provider-specific credentials and base URLs. For DeepSeek, you point your base URL to https://api.deepseek.com. For Gemini, you use the Google OpenAI-compatible endpoint at https://generativelanguage.googleapis.com/v1beta/openai/.
import os
from openai import AsyncOpenAI
from agents import Agent, OpenAIChatCompletionsModel
# Initialize DeepSeek client
deepseek_client = AsyncOpenAI(
api_key=os.getenv("DEEPSEEK_API_KEY"),
base_url="https://api.deepseek.com"
)
# Initialize Gemini client
gemini_client = AsyncOpenAI(
api_key=os.getenv("GEMINI_API_KEY"),
base_url="https://generativelanguage.googleapis.com/v1beta/openai/"
)Which environment variables do you need to export in your .env file? You should export DEEPSEEK_API_KEY and GEMINI_API_KEY alongside your core project variables. To prevent authentication errors, ensure your client instance is passed directly into the model wrapper for the specific agent you are building. You can explore detailed reference patterns in the OpenAI Agents SDK Model Documentation and review community setups in the LangDB Integration Guide.
Delegating Tasks across Models with Multi-Agent Handoffs 💡
Multi-agent handoffs enable a central triage agent to pass user requests to specialized sub-agents powered by different LLMs. For instance, I often use a fast, inexpensive model like DeepSeek Chat for initial routing and data extraction, while delegating complex reasoning tasks to Gemini or Claude.
Why should you assign different tasks across model providers? Mixing models keeps workloads efficient while maximizing output quality. You do not need expensive frontier models for simple classification or formatting tasks. For complete multi-provider handoff examples, check out the guide on how to Build Agents with OpenAI SDK using any LLM Provider.
Running Local DeepSeek Models via Ollama 🌐
If data privacy or offline processing is a top priority for your architecture, you can run DeepSeek locally using Ollama while maintaining full compatibility with the Agents SDK. Pointing your AsyncOpenAI client to your local gateway allows your agents to process queries securely on your own hardware without sending data to external cloud servers.
# Initialize local Ollama client
local_client = AsyncOpenAI(
api_key="ollama", # Ollama requires a dummy string
base_url="http://localhost:11434/v1"
)
local_agent = Agent(
name="LocalAgent",
model=OpenAIChatCompletionsModel(
model="deepseek-r1:7b",
openai_client=local_client
)
)Can you run high-performing reasoning models completely on your local machine? Yes, local execution gives you complete control over data privacy and eliminates cloud API costs entirely. For a complete local walkthrough, watch the OpenAI Agents SDK Local DeepSeek R1 Tutorial.
Handling Telemetry 401 Errors and Tracing Limits 🚀
When running agents without an active OpenAI API key, the SDK built-in tracing utility may throw HTTP 401 telemetry errors because it attempts to authenticate against OpenAI's telemetry servers by default. You can resolve this by turning off tracing altogether using set_tracing_disabled(True), or by setting an explicit tracing key using a valid OpenAI key from your platform dashboard.
Why does tracing fail when you rely solely on third-party API keys? The built-in telemetry client expects a valid OpenAI developer key for trace uploads. Review the OpenAI Developer Community Gemini Discussion to discover proven fixes for common connection hurdles and tracing adjustments.
Bottom Line
Integrating DeepSeek and Gemini into the OpenAI Agents SDK is one of the most practical ways to build flexible, cost-effective AI workflows. By configuring custom AsyncOpenAI clients and wrapping them in OpenAIChatCompletionsModel, you retain full tool compatibility while choosing the ideal model for every specific task. For more details on structuring agent memory and tool calling, check out our guide on Postgres and S3 Memory Layers for AI Agents and our overview on Build Multi-Tool AI Agents with OpenAI Agents SDK and MCP.
Sources
- Models - OpenAI Agents SDK (OpenAI)
- Use OpenAI Agents SDK with Gemini, Claude, DeepSeek (LangDB)
- Build Agents with OpenAI SDK using any LLM Provider (Medium)
- OpenAI Agents SDK Local DeepSeek R1 Local DeepSeek R1 + Ollama (YouTube)
- Using Gemini with OpenAI Agents SDK (OpenAI Developer Community)
Follow Owais Abdullah on Google Search & Discover
Add this domain as a preferred source to see new AI engineering, Next.js SaaS, and Digital FTE breakdowns prioritized in your Google Top Stories, AI Overviews, and Discover feed.
Architecture FAQs
Was this article helpful?
Your feedback helps improve our future articles and tutorials.

Discussion & Thoughts
Join the conversation with your perspective