OpenAICloudflare Developer PlatformMay 21, 2026, 12:00 AM

AI Gateway - Call any AI model through AI Gateway's new REST API

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

AI Gateway - Call any AI model through AI Gateway's new REST API

Key Points

  • Unified REST API for all AI models
  • Automatic logging, caching, rate limiting, guardrails
  • Use cf-aig-gateway-id to route; unified billing

Summary

AI Gateway now exposes a unified REST API on api.cloudflare.com to call any AI model (OpenAI, Anthropic, Google, or Workers AI) using the same endpoints and authentication across providers. Built-in features (logging, caching, rate limiting, guardrails) apply automatically and third-party usage is billed via Unified Billing.

Key Points

  • Endpoints available:
    • POST /ai/run — universal endpoint for all models and modalities
    • POST /ai/v1/chat/completions — OpenAI SDK compatible
    • POST /ai/v1/responses — OpenAI Responses API compatible
    • POST /ai/v1/messages — Anthropic SDK compatible
  • Authentication and request format are unified; you call models by name (e.g., openai/gpt-5.5).
  • Third-party models are billed through Unified Billing; no separate provider keys required.
  • Requests use your account's default gateway created on first use. To force a specific gateway, add the cf-aig-gateway-id header.
  • Workers AI models can be called via the @cf/ model prefix (e.g., @cf/moonshotai/kimi-k2.6) — the legacy path /ai/run/@cf/{model} continues to work.
  • All AI Gateway features (logging, caching, rate limits, guardrails) are applied automatically.

Quick example

curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/v1/chat/completions"
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
-H "Content-Type: application/json"
-d '{"model":"openai/gpt-5.5","messages":[{"role":"user","content":"What is Cloudflare?"}]}'

Where to go next

See the REST API documentation for full request/response schemas, gateway configuration, and examples.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

AI Gateway — 新しいREST APIで任意のAIモデルを呼び出す

AI Gateway — 新しいREST APIで任意のAIモデルを呼び出す

公開日: 2026-05-21

AI Gatewayは現在 api.cloudflare.com のAI REST APIを使用しています。OpenAI、Anthropic、Google、または Workers AI でホストされているモデルでも、プロバイダに関係なく、同じエンドポイントと認証を使って単一のAPI経由で呼び出せます。

利用可能なエンドポイントは4つです:

  • POST /ai/run — すべてのモデルとモダリティに対する汎用エンドポイント
  • POST /ai/v1/chat/completions — OpenAI SDK 互換
  • POST /ai/v1/responses — OpenAI Responses API 互換
  • POST /ai/v1/messages — Anthropic SDK 互換

例(curl):

curl -X POST "https://api.cloudflare.com/client/v4/accounts/ $CLOUDFLARE_ACCOUNT_ID /ai/v1/chat/completions" \
 --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN " \
 --header "Content-Type: application/json" \
 --data '{ "model": "openai/gpt-5.5", "messages": [{"role": "user", "content": "What is Cloudflare?"}] }'

すべてのAI Gatewayの機能(ログ記録(logging)、キャッシュ(caching)、レート制限(rate limiting)、ガードレール(guardrails))は自動的に適用されます。サードパーティのモデルは Unified Billing によって請求されるため、プロバイダごとのAPIキーを別途管理する必要はありません。

サードパーティモデルのリクエストは、最初の使用時に自動的に作成されるアカウントのデフォルトゲートウェイ経由でルーティングされます。特定のゲートウェイを経由させるには、cf-aig-gateway-id ヘッダーを追加してください。

既に Workers AI モデルを既存のREST API経由(/ai/run/@cf/{model})で呼び出している場合、そのパスは引き続き動作します。AI Gateway 経由で Workers AI モデルを呼び出すには、モデルプレフィックスに @cf/ を使用(例: @cf/moonshotai/kimi-k2.6)し、どのゲートウェイを通すかを指定するために cf-aig-gateway-id ヘッダーを含めてください。

詳細と例は REST APIドキュメント を参照してください(https://api.cloudflare.com)。