Unified API (OpenAI compat)
Cloudflare's AI Gateway offers an OpenAI-compatible /chat/completions endpoint, enabling integration with multiple AI providers using a single URL. This feature simplifies the integration process, allowing for seamless switching between different models without significant code modifications.
https://gateway.ai.cloudflare.com/v1/{account_id}/default/compat/chat/completionsReplace {account_id} with your Cloudflare account ID. The default gateway is created automatically on your first request — no setup needed. You can also replace default with a specific gateway ID if you have already created one.
Switch providers by changing the model and apiKey parameters.
Specify the model using {provider}/{model} format. For example:
openai/gpt-5-minigoogle-ai-studio/gemini-2.5-flashanthropic/claude-sonnet-4-5
import OpenAI from "openai";
const client = new OpenAI({ apiKey: