OpenAI-compatible models

Connect Agno agents to providers that implement Chat Completions or Open Responses.

Many providers support the OpenAI API format. Use the OpenAILike model to access them by replacing the base_url.

Example

Install the client packages in your Python environment:

uv pip install -U agno openai

For this Together example, create an API key and select a text model available to your account from the Together model catalog. Use its exact model ID:

export TOGETHER_API_KEY="YOUR_API_KEY"
export TOGETHER_MODEL_ID="YOUR_MODEL_ID"

Save the following code as agent.py.

from os import environ
from agno.agent import Agent
from agno.models.openai.like import OpenAILike

agent = Agent(
    model=OpenAILike(
        id=environ["TOGETHER_MODEL_ID"],
        api_key=environ["TOGETHER_API_KEY"],
        base_url="https://api.together.xyz/v1",
    )
)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.")

Run it with python agent.py.

Parameters

ParameterTypeDefaultDescription
idstr"not-provided"The id of the model to use
namestr"OpenAILike"The name of the model
providerstr"OpenAI"The provider of the model
api_keyOptional[str]"not-provided"The API key for authentication
base_urlOptional[str]NoneThe base URL for the API service
collect_metrics_on_completionboolFalseCollect token metrics only from the final streaming chunk (for providers with cumulative token counts)

OpenAILike inherits the parameters of OpenAIChat. Each endpoint and model determines which parameters, tools, modalities, and output formats it accepts. Check the provider documentation and model compatibility before enabling those features.

Responses API

For providers that implement the Open Responses API specification, use OpenResponses:

from agno.agent import Agent
from agno.models.openai import OpenResponses

agent = Agent(
    model=OpenResponses(
        id="your-model-id",
        base_url="https://your-provider.com/v1",
        api_key="your-api-key",
    ),
)

agent.print_response("Share a 2 sentence horror story.")

OpenResponses sets store=False by default and does not automatically chain requests through previous_response_id. This is the Agno adapter behavior; provider storage and state features depend on the endpoint.

For specific providers, use the dedicated classes:

See OpenResponses reference for full parameters.