Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/content/changelog/ai-gateway/2026-05-18-rest-api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Call any AI model through AI Gateway's new REST API
description: Call third-party and Workers AI models through one Cloudflare REST API, with AI Gateway features applied automatically.
products:
- ai-gateway
date: 2026-05-19
---

AI Gateway now uses the AI REST API on `api.cloudflare.com`. You can call any model — whether from OpenAI, Anthropic, Google, or hosted on Workers AI — through one unified API, using the same endpoints and authentication regardless of provider. Three endpoints are 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

```bash
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?"}]
}'
```

All AI Gateway features — logging, caching, rate limiting, and guardrails — are applied automatically. Third-party models are billed through [Unified Billing](/ai-gateway/features/unified-billing/), so you do not need to manage separate provider API keys.

Every request through the REST API is routed through your account's default gateway, which is created automatically on first use. To route requests through a specific gateway, add the `cf-aig-gateway-id` header.

If you are already calling Workers AI models through the existing REST API, that path (`/ai/run/@cf/{model}`) continues to work. To call Workers AI models through AI Gateway, replace it with `/ai/run` and move the model name into the request body with `"provider": "cloudflare"`.

For more details and examples, refer to the [REST API documentation](/ai-gateway/usage/rest-api/).