DeepInfra
Use DeepInfra models with Agno agents.
Use open-source models hosted on DeepInfra with Agno agents.
DeepInfra supports a wide range of models. See their library of models here.
Use an explicit model ID from the current catalog. This example uses Phi-4; for tools, choose a model listed in the tool-calling guide. The adapter retains an older Llama 2 default, and old IDs may be forwarded under the provider's deprecation policy, so a default name does not establish which current model serves a request.
DeepInfra has rate limits. See the rate limit docs.
Authentication
Set your DEEPINFRA_API_KEY environment variable. Get your key from here.
export DEEPINFRA_API_KEY="your_value_here"Example
Install the openai package:
uv pip install -U openai agnoUse DeepInfra with your Agent:
from agno.agent import Agent
from agno.models.deepinfra import DeepInfra
agent = Agent(
model=DeepInfra(id="microsoft/phi-4"),
markdown=True
)
# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.") View more examples here.
Params
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "meta-llama/Llama-2-70b-chat-hf" | The id of the DeepInfra model to use |
name | str | "DeepInfra" | The name of the model |
provider | str | "DeepInfra" | The provider of the model |
api_key | Optional[str] | None | The API key for DeepInfra (defaults to DEEPINFRA_API_KEY env var) |
base_url | str | "https://api.deepinfra.com/v1/openai" | The base URL for the DeepInfra API |
DeepInfra also supports the parameters of OpenAI.