Nexus
Use Nexus router models with Agno agents.
Nexus is a routing platform that provides endpoints for various Large Language Models through a unified API interface.
Explore Nexus's capabilities and documentation here.
Start the gateway
Nexus routes this example to Anthropic. Configure the provider key in the gateway process, not just in the Python client's shell.
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateConfigure Nexus
Install Nexus, then create nexus.toml in the directory where you will start the gateway:
[server]
listen_address = "127.0.0.1:8000"
[llm]
enabled = true
[llm.protocols.openai]
enabled = true
path = "/llm"
[llm.providers.anthropic]
type = "anthropic"
api_key = "{{ env.ANTHROPIC_API_KEY }}"
[llm.providers.anthropic.models."claude-sonnet-4-6"]The Nexus model sends OpenAI-compatible requests to http://localhost:8000/llm/v1/ by default. Nexus requires every model to be declared in nexus.toml.
Start Nexus
In a dedicated server terminal, set the provider key and start the gateway from the directory that contains nexus.toml:
export ANTHROPIC_API_KEY="your-anthropic-api-key"
nexusLeave this terminal running. The provider key belongs to the Nexus process. Open a second terminal in your example directory, activate the Python virtual environment there, and run the Agno client. Exporting the key only in that client terminal does not configure the gateway.
In the second terminal with the environment activated, install the client dependencies:
uv pip install -U agno openaiExample
Save the following as agent.py and run python agent.py in the client terminal:
from agno.agent import Agent
from agno.models.nexus import Nexus
agent = Agent(model=Nexus(id="anthropic/claude-sonnet-4-6"), markdown=True)
# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")
Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "openai/gpt-4" | The id of the model to use through Nexus |
name | str | "Nexus" | The name of the model |
provider | str | "Nexus" | The provider of the model |
api_key | Optional[str] | "not-provided" | The API key sent to the Nexus router. Not required for a local deployment |
base_url | str | "http://localhost:8000/llm/v1/" | The base URL for the Nexus API |
Nexus also supports the params of OpenAI.