Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/openai/chat/
--header 'cf-aig-authorization: Bearer {CF_AIG_TOKEN}' \
--header 'Authorization: Bearer OPENAI_TOKEN' \
--header 'Content-Type: application/json' \
--data '{"model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}'
--data '{"model": "gpt-5-mini", "messages": [{"role": "user", "content": "What is Cloudflare?"}]}'
```

Using the OpenAI SDK:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ curl -X POST https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/comp
--header 'cf-aig-authorization: Bearer {CF_AIG_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
"model": "dynamic/gemini-2.0-flash",
"model": "dynamic/<your-dynamic-route-name>",
"messages": [
{
"role": "user",
Expand All @@ -68,12 +68,12 @@ export interface Env {

export default {
async fetch(request: Request, env: Env) {
const response = await env.AI.gateway("dfD").run({
const response = await env.AI.gateway("default").run({
provider: "compat",
endpoint: "chat/completion",
headers: {},
query: {
model: "dynamic/support",
model: "dynamic/<your-dynamic-route-name>",
messages: [
{
role: "user",
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/ai-gateway/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const client = new OpenAI({

// Use different providers by changing the model parameter
const response = await client.chat.completions.create({
model: "google-ai-studio/gemini-2.0-flash", // or "openai/gpt-4o", "anthropic/claude-3-haiku"
model: "google-ai-studio/gemini-2.5-flash", // or "openai/gpt-5-mini", "anthropic/claude-sonnet-4-5"
messages: [{ role: "user", content: "Hello, world!" }],
});
```
Expand Down
10 changes: 5 additions & 5 deletions src/content/docs/ai-gateway/usage/chat-completion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Switch providers by changing the `model` and `apiKey` parameters.

Specify the model using `{provider}/{model}` format. For example:

- `openai/gpt-4o-mini`
- `google-ai-studio/gemini-2.0-flash`
- `anthropic/claude-3-haiku`
- `openai/gpt-5-mini`
- `google-ai-studio/gemini-2.5-flash`
- `anthropic/claude-sonnet-4-5`

## Examples

Expand All @@ -41,7 +41,7 @@ const client = new OpenAI({
});

const response = await client.chat.completions.create({
model: "google-ai-studio/gemini-2.0-flash",
model: "google-ai-studio/gemini-2.5-flash",
messages: [{ role: "user", content: "What is Cloudflare?" }],
});

Expand All @@ -55,7 +55,7 @@ curl -X POST https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/comp
--header 'Authorization: Bearer {GOOGLE_GENERATIVE_AI_API_KEY}' \
--header 'Content-Type: application/json' \
--data '{
"model": "google-ai-studio/gemini-2.0-flash",
"model": "google-ai-studio/gemini-2.5-flash",
"messages": [
{
"role": "user",
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/ai-gateway/usage/providers/anthropic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ curl https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/anthropic/v1
--header 'anthropic-version: 2023-06-01' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-3-opus-20240229",
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "What is Cloudflare?"}
Expand All @@ -57,7 +57,7 @@ const anthropic = new Anthropic({
baseURL,
});

const model = "claude-3-opus-20240229";
const model = "claude-sonnet-4-5";
const messages = [{ role: "user", content: "What is Cloudflare?" }];
const maxTokens = 1024;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ So your final URL will come together as: `https://gateway.ai.cloudflare.com/v1/{
### cURL

```bash title="Example fetch request"
curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}/google-ai-studio/v1/models/gemini-1.0-pro:generateContent" \
curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_name}/google-ai-studio/v1/models/gemini-2.5-flash:generateContent" \
--header 'content-type: application/json' \
--header 'x-goog-api-key: {google_studio_api_key}' \
--data '{
Expand Down Expand Up @@ -63,7 +63,7 @@ const gateway_name = "";

const genAI = new GoogleGenerativeAI(api_token);
const model = genAI.getGenerativeModel(
{ model: "gemini-1.5-flash" },
{ model: "gemini-2.5-flash" },
{
baseUrl: `https://gateway.ai.cloudflare.com/v1/${account_id}/${gateway_name}/google-ai-studio`,
},
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/ai-gateway/usage/providers/openai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const openai = new OpenAI({
});

try {
const model = "gpt-3.5-turbo-0613";
const model = "gpt-5-mini";
const messages = [{ role: "user", content: "What is a neuron?" }];
const maxTokens = 100;
const chatCompletion = await openai.chat.completions.create({
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/ai-gateway/usage/providers/openrouter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ curl -X POST https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/open
--header 'content-type: application/json' \
--header 'Authorization: Bearer OPENROUTER_TOKEN' \
--data '{
"model": "openai/gpt-3.5-turbo",
"model": "openai/gpt-5-mini",
"messages": [
{
"role": "user",
Expand All @@ -59,7 +59,7 @@ const openai = new OpenAI({

try {
const chatCompletion = await openai.chat.completions.create({
model: "openai/gpt-3.5-turbo",
model: "openai/gpt-5-mini",
messages: [{ role: "user", content: "What is Cloudflare?" }],
});

Expand Down
6 changes: 3 additions & 3 deletions src/content/docs/ai-gateway/usage/providers/vertex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Your new base URL will use the data above in this structure: `https://gateway.ai

Then you can append the endpoint you want to hit, for example: `/publishers/google/models/{model}:{generative_ai_rest_resource}`

So your final URL will come together as: `https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-vertex-ai/v1/projects/{project_name}/locations/{region}/publishers/google/models/gemini-1.0-pro-001:generateContent`
So your final URL will come together as: `https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-vertex-ai/v1/projects/{project_name}/locations/{region}/publishers/google/models/gemini-2.5-flash:generateContent`

## Authenticating with Vertex AI

Expand Down Expand Up @@ -85,7 +85,7 @@ This option is only supported for the provider-specific endpoint, not for the un
:::

```bash
curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-vertex-ai/v1/projects/{project_name}/locations/{region}/publishers/google/models/gemini-1.0-pro-001:generateContent" \
curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-vertex-ai/v1/projects/{project_name}/locations/{region}/publishers/google/models/gemini-2.5-flash:generateContent" \
-H "Authorization: Bearer ya29.c.b0Aaekm1K..." \
-H 'Content-Type: application/json' \
-d '{
Expand Down Expand Up @@ -161,7 +161,7 @@ You can also use the provider-specific endpoint to access the full Vertex AI API
### cURL

```bash title="Example fetch request"
curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-vertex-ai/v1/projects/{project_name}/locations/{region}/publishers/google/models/gemini-1.0-pro-001:generateContent" \
curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/google-vertex-ai/v1/projects/{project_name}/locations/{region}/publishers/google/models/gemini-2.5-flash:generateContent" \
-H "Authorization: Bearer {vertex_api_key}" \
-H 'Content-Type: application/json' \
-d '{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ws.on("message", (message) => console.log(message.data));
ws.send(
JSON.stringify({
setup: {
model: "models/gemini-2.0-flash-exp",
model: "models/gemini-2.5-flash",
generationConfig: { responseModalities: ["TEXT"] },
},
}),
Expand Down