FrameworksCrewAI

CrewAI

Use Nemo Router with CrewAI for multi-agent orchestration

Last updated

CrewAI uses LiteLLM under the hood, so every CrewAI agent automatically supports Nemo Router. Set environment variables and CrewAI routes everything through the gateway — guardrails, caching, and rate-limits auto-apply per-agent.

Installation

pip install crewai

Setup

import os
from crewai import Agent, Task, Crew, LLM

llm = LLM(
    model="openai/claude-sonnet-4-20250514",
    base_url="https://api.nemorouter.ai/v1",
    api_key=os.environ["NEMOROUTER_API_KEY"],
)

Build a Crew

researcher = Agent(
    role="Senior Researcher",
    goal="Uncover cutting-edge developments in AI",
    backstory="An expert at finding patterns in technical literature.",
    llm=llm,
    verbose=True,
)

writer = Agent(
    role="Tech Writer",
    goal="Translate research into clear prose",
    backstory="Known for explaining complex topics simply.",
    llm=llm,
    verbose=True,
)

research_task = Task(
    description="Research the latest LLM gateway architectures.",
    expected_output="A 5-bullet summary of key findings.",
    agent=researcher,
)

write_task = Task(
    description="Turn the research into a 1-paragraph blog intro.",
    expected_output="A polished opening paragraph.",
    agent=writer,
    context=[research_task],
)

crew = Crew(agents=[researcher, writer], tasks=[research_task, write_task])
result = crew.kickoff()
print(result)

Per-Request Overrides

Pass nemo_* fields through extra_body on the LLM configuration:

llm = LLM(
    model="openai/gpt-4o",
    base_url="https://api.nemorouter.ai/v1",
    api_key=os.environ["NEMOROUTER_API_KEY"],
    extra_body={
        "nemo_prompt_template_id": "your-summarizer-id",
        "nemo_prompt_variables": {"language": "Spanish"},
        "nemo_guardrail_ids": ["guardrail-uuid-1"],
        "nemo_cache": False,
    },
)

Multi-Model Crews

Different agents can use different models — Nemo Router unifies billing and observability across them:

fast_llm = LLM(model="openai/gpt-4o-mini", base_url="https://api.nemorouter.ai/v1",
               api_key=os.environ["NEMOROUTER_API_KEY"])
smart_llm = LLM(model="openai/claude-sonnet-4-20250514", base_url="https://api.nemorouter.ai/v1",
                api_key=os.environ["NEMOROUTER_API_KEY"])

researcher = Agent(role="Researcher", llm=smart_llm, ...)
classifier = Agent(role="Classifier", llm=fast_llm, ...)

Next Steps

Was this page helpful?