Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.agno.com/llms.txt

Use this file to discover all available pages before exploring further.

Cloudflare AI Gateway exposes an OpenAI-compatible unified API, so you reach multiple vendors through a single endpoint by setting the model id to a vendor/model route. The default vendor is Workers AI, which needs only a Cloudflare token and account id. The Cloudflare class defaults to @cf/meta/llama-3.3-70b-instruct-fp8-fast. Agno rewrites any @cf/... id to workers-ai/@cf/... for the gateway.

Authentication

Cloudflare needs an API token and your account id. The AI Gateway id is optional and falls back to default.
VariableRequiredDescription
CLOUDFLARE_API_TOKENYesAPI token. Create one at dash.cloudflare.com.
CLOUDFLARE_ACCOUNT_IDYesYour account id, found in the Cloudflare dashboard.
CLOUDFLARE_AI_GATEWAY_IDNoAI Gateway id. Defaults to default.
export CLOUDFLARE_API_TOKEN=***
export CLOUDFLARE_ACCOUNT_ID=***
export CLOUDFLARE_AI_GATEWAY_ID=***  # optional

Example

Use Cloudflare with your Agent:
from agno.agent import Agent
from agno.models.cloudflare import Cloudflare

agent = Agent(
    model=Cloudflare(id="@cf/meta/llama-3.3-70b-instruct-fp8-fast"),
    markdown=True,
)

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

Parameters

ParameterTypeDefaultDescription
idstr"@cf/meta/llama-3.3-70b-instruct-fp8-fast"The gateway model id. See Model selection.
namestr"Cloudflare"The name of the model
providerstr"Cloudflare"The provider of the model
api_keyOptional[str]NoneAPI token (defaults to CLOUDFLARE_API_TOKEN env var)
account_idOptional[str]NoneAccount id (defaults to CLOUDFLARE_ACCOUNT_ID env var)
gateway_idOptional[str]NoneAI Gateway id (defaults to CLOUDFLARE_AI_GATEWAY_ID, or default)
base_urlOptional[str]NoneOverride the gateway URL. Skips env-var lookup when set.
max_tokensOptional[int]NoneMaximum tokens to generate
Cloudflare extends the OpenAI-compatible interface and supports most parameters from the OpenAI model. Use use_json_mode=True for structured output when a model does not support native structured outputs.

Model selection

Pick the route by setting id:
VendorId formatNotes
Workers AI@cf/<org>/<model>Copy the binding id from the model catalog. Agno prepends workers-ai/.
OpenAI, Google, etcopenai/<model>, google/<model>Requires the vendor’s BYOK key stored in the AI Gateway dashboard.
Dynamic routedynamic/<route>A route configured in the dashboard for fallbacks.
from agno.agent import Agent
from agno.models.cloudflare import Cloudflare

# Workers AI (Agno rewrites to workers-ai/@cf/...)
agent = Agent(model=Cloudflare(id="@cf/google/gemma-4-26b-a4b-it"), markdown=True)
Workers AI serves Google’s open-weight Gemma models, not the standard Gemini API. Invented ids such as @cf/.../gemini-... return HTTP 400. For Gemini, use a google/... route with BYOK credentials. Vendor routes also need a model id from the Cloudflare docs.