Switch Over 20+ LLM Providers with a Single String in Deep Agents
The article explains how Deep Agents compresses model provider switching into a one‑line "provider:model" string, compares this approach with passing a LangChain model instance, and provides installation, configuration, and best‑practice guidance for both standard and domestic AI services.
Conclusion First
Deep Agents offers two ways to specify the model parameter: provider:model – a simple string for quick switching of standard providers.
Pass a model instance – required when you need base_url, a proxy, a private endpoint, or custom timeout settings.
This is not a matter of one replacing the other; choose the string for standard OpenAI/Anthropic/Google/DeepSeek providers, and the instance for domestic OpenAI‑compatible services, enterprise gateways, Azure OpenAI, or local models.
What provider:model Actually Does
The entry point remains create_deep_agent():
from deepagents import create_deep_agent
agent = create_deep_agent(
model="anthropic:claude-sonnet-4-6",
tools=[...],
)The format is provider:model-name. Under the hood Deep Agents delegates parsing to LangChain's init_chat_model, reusing LangChain's existing chat model integrations.
Typical provider strings and their required LangChain packages are: openai:gpt-5 –
langchain-openai anthropic:claude-sonnet-4-6–
langchain-anthropic google_genai:gemini-2.5-pro–
langchain-google-genai openrouter:anthropic/claude-sonnet-4-6–
langchain-openrouter deepseek:deepseek-chat–
langchain-deepseek ollama:qwen3:4b–
langchain-ollama groq:llama-3.3-70b–
langchain-groq mistralai:mistral-large-latest– langchain-mistralai Note that the model name must exist in the provider’s current catalog; Deep Agents does not guarantee model availability.
Installation: CLI vs SDK
CLI installation with extras pulls common providers in one step:
uv tool install 'deepagents-cli[openai,anthropic,google-genai]'Later you can add DeepSeek or Ollama without reinstalling the whole tool:
uv tool install deepagents-cli --with langchain-deepseek
uv tool install deepagents-cli --with langchain-ollamaFor SDK use, install only the partner packages you need:
pip install -qU deepagents langchain-anthropic
pip install -qU langchain-deepseek langchain-ollamaInstalling the meta package deepagents-cli[all-providers] pulls many dependencies, which can cause timeouts on Chinese networks and slow CI builds. Prefer declaring the exact provider packages in pyproject.toml.
Key and Configuration Files
Credentials are read from standard environment variables:
export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...
export DEEPSEEK_API_KEY=sk-...The CLI also supports a private prefix to isolate keys, e.g., DEEPAGENTS_CLI_OPENAI_API_KEY, useful when another tool already uses OPENAI_API_KEY.
Configuration loading order (higher priority later): ~/.deepagents/.env – global defaults
Project .env – overrides global settings
Current shell environment – temporary overrides for debugging
Common Practices for Chinese Developers
OpenAI‑Compatible Services
Services such as SiliconFlow, Zhipu, and Moonshot expose OpenAI‑compatible endpoints. Using a model instance makes all configuration explicit:
from deepagents import create_deep_agent
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="Pro/MiniMaxAI/MiniMax-M2.5",
base_url="https://api.siliconflow.cn/v1",
api_key="your-key",
)
agent = create_deep_agent(
model=llm,
tools=[get_weather],
)This approach surfaces model name, base_url, API key, timeout, and retry strategy.
When evaluating providers, look beyond per‑call price; consider end‑to‑end cost, context length, tool‑call stability, and failure‑recovery capability.
Ollama Local Models
For fully offline experiments, install Ollama and pull a model:
uv tool install deepagents-cli --with langchain-ollama
ollama serve
ollama pull qwen3:4bThen create the agent:
agent = create_deep_agent(
model="ollama:qwen3:4b",
tools=[...],
)Deep Agents’ default toolchain is heavy; models smaller than 4B may fail to recognize required tool schemas. For long‑running tasks, start evaluating with models of at least 14B.
String vs. Instance Decision Table
Standard OpenAI/Anthropic/Google/DeepSeek – use the string.
Only want to swap models without code changes – use the string.
Ops control model via env vars – use the string.
Need private base_url – pass a model instance.
Require proxy, private gateway, special auth – pass a model instance.
Need fine‑tuning parameters like temperature, max_tokens, timeout – pass a model instance.
Integrating Azure OpenAI – pass a model instance for clarity.
Strings are lazily parsed; forgetting to install the corresponding LangChain package (e.g., langchain-openai) can cause initialization errors that are not obvious at first glance. Therefore, declare provider dependencies in the project rather than relying on a globally installed environment.
CLI Utilities
Inside the Deep Agents terminal, the command /model opens an interactive model selector. Adding --default writes the chosen model back to the default configuration. This is handy for local debugging but not a replacement for production configuration management.
Author’s Judgment
Model configuration is more than swapping a line of code. In a real project I separate concerns into:
Provider
Model name
Base URL
API key
Timeout and retry policy
Billing and usage tracking
Tenant‑level routing rules
Enterprises often keep Deep Agents at the application layer while a model gateway handles rate limiting, billing, audit, and gradual rollout. The business code then only decides which model to use for a given tenant, task, and time window, turning model changes into configuration updates rather than code changes.
Next Article Preview
The upcoming post will dissect the write_todos tool, which lets an agent plan, execute, and update state for long‑running tasks. Many agents drift because of issues in this component.
How to Get the Code
If you are comparing OpenAI, Anthropic, DeepSeek, Ollama, or domestic OpenAI‑compatible services, reply "DeepAgents" to the public account backend to receive the code repository. Include the provider, base_url, and any error messages when you comment, and the author will prioritize common issues.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Tech Ocean
Focused on AI programming, sharing ready-to-use development efficiency solutions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
