Skip to main content

Cloudflare AI Gateway

Use this when Cloudflare AI Gateway owns the upstream route and you want the gateway path, account id, and gateway name to remain operator-visible.

At A Glance

FieldValue
Built-in kindcloudflare_ai_gateway
Provider groupGateway And Compatibility Providers
Protocol familyopenai_chat_completions
Feature familyopenai_compatible
Auth schemebearer
Credential envsCLOUDFLARE_API_KEY, CLOUDFLARE_AI_GATEWAY_API_KEY
Aliasescloudflare-ai-gateway, cloudflare_ai, cloudflare-ai, cloudflare
Default base URLhttps://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_name>/openai/compat
Request endpointhttps://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_name>/openai/compat/chat/completions
Models endpointhttps://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_name>/openai/compat/models

Minimal Config

active_provider = "cloudflare_ai_gateway"

[providers.cloudflare_ai_gateway]
kind = "cloudflare_ai_gateway"
base_url = "https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_name>/openai/compat"
api_key = { env = "CLOUDFLARE_API_KEY" }
model = "auto"

Verify It

loong doctor
loong list-models
loong ask --message "Say hello and name the active provider."
If list-models is unreliable for this account or region, pin an explicit provider.model or add preferred_models instead of leaving recovery implicit.

Auth And Routing Contract

ContractValue
Auth optionalno
Model probe auth optionalno
Default API key envCLOUDFLARE_API_KEY
OAuth envnone
Primary request routehttps://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_name>/openai/compat/chat/completions
Primary model-catalog routehttps://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_name>/openai/compat/models

Operator Notes

  • cloudflare_ai_gateway requires tenant-scoped base_url configuration: replace <account_id> and <gateway_name> in provider.base_url with your real Cloudflare AI Gateway path; current template: https://gateway.ai.cloudflare.com/v1/<account_id>/<gateway_name>/openai/compat.