Skip to main content
Build a language routing team that automatically detects user language and responds with native speakers. This example demonstrates intelligent routing across multiple AI models specialized for different languages.

What You’ll Learn

By building this team, you’ll understand:
  • How to create language-specific agents using different AI models
  • How to implement intelligent routing based on user input language
  • How to use multiple AI providers (OpenAI, Claude, Mistral, DeepSeek) in one team
  • How to handle unsupported languages with graceful fallback responses

Use Cases

Build multilingual customer support, international chatbots, translation services, or global help desk systems.

How It Works

The team uses route mode to direct queries to language-specific agents:
  1. Detect: Team leader analyzes the language of the user’s question
  2. Route: Directs the query to the appropriate language-specialized agent
  3. Respond: Language agent answers in the user’s native language
  4. Fallback: Handles unsupported languages with English response
Each language agent uses a different AI model optimized for that language’s characteristics.

Code

multi_language_team.py
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.models.deepseek import DeepSeek
from agno.models.mistral import MistralChat
from agno.models.openai import OpenAIChat
from agno.team import Team

japanese_agent = Agent(
    name="Japanese Agent",
    role="You only answer in Japanese",
    model=DeepSeek(id="deepseek-chat"),
)
chinese_agent = Agent(
    name="Chinese Agent",
    role="You only answer in Chinese",
    model=DeepSeek(id="deepseek-chat"),
)
spanish_agent = Agent(
    name="Spanish Agent",
    role="You only answer in Spanish",
    model=OpenAIChat(id="gpt-4o"),
)
french_agent = Agent(
    name="French Agent",
    role="You only answer in French",
    model=MistralChat(id="mistral-large-latest"),
)
german_agent = Agent(
    name="German Agent",
    role="You only answer in German",
    model=Claude(id="claude-3-5-sonnet-20241022"),
)

multi_language_team = Team(
    name="Multi Language Team",
    model=OpenAIChat(id="gpt-4o"),
    members=[
        spanish_agent,
        japanese_agent,
        french_agent,
        german_agent,
        chinese_agent,
    ],
    respond_directly=True,
    description="You are a language router that directs questions to the appropriate language agent.",
    instructions=[
        "Identify the language of the user's question and direct it to the appropriate language agent.",
        "Let the language agent answer the question in the language of the user's question.",
        "If the user asks a question in English, respond directly in English.",
        "If the user asks in a language that is not English or you don't have a member agent for that language, respond in English with:",
        "'I only answer in the following languages: English, Spanish, Japanese, Chinese, French and German. Please ask your question in one of these languages.'",
        "Always check the language of the user's input before routing to an agent.",
        "For unsupported languages like Italian, respond in English with the above message.",
    ],
    markdown=True,
    show_members_responses=True,
)

if __name__ == "__main__":
    # Ask "How are you?" in all supported languages
    multi_language_team.print_response("Comment allez-vous?", stream=True)  # French
    multi_language_team.print_response("How are you?", stream=True)  # English
    multi_language_team.print_response("你好吗?", stream=True)  # Chinese
    multi_language_team.print_response("お元気ですか?", stream=True)  # Japanese
    multi_language_team.print_response("Wie geht es Ihnen?", stream=True)  # German
    multi_language_team.print_response("Hola, ¿cómo estás?", stream=True)  # Spanish
    multi_language_team.print_response("Come stai?", stream=True)  # Italian

What to Expect

The team will automatically detect the language of your input and route it to the appropriate language-specific agent. Each agent responds fluently in their designated language using models optimized for that language. The output shows which agent handled each request. For unsupported languages, you’ll receive a polite message in English listing available languages.

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Set your API keys

export OPENAI_API_KEY=xxx
export ANTHROPIC_API_KEY=xxx
export DEEPSEEK_API_KEY=xxx
export MISTRAL_API_KEY=xxx
3

Install libraries

pip install -U agno openai anthropic mistralai deepseek-ai
4

Run Team

python multi_language_team.py

Next Steps

  • Add more language agents for additional language support
  • Modify the routing logic in instructions to handle dialects or regional variations
  • Experiment with different AI models for each language to optimize quality
  • Explore Teams for advanced request distribution