Skip to content

Commit cd68088

Browse files
kathaylkodster28
andauthored
Create 2025-06-02-aig-openai-compatible-endpoint.mdx (#22803)
* Create 2025-06-02-aig-openai-compatible-endpoint.mdx * Update src/content/changelog/ai-gateway/2025-06-02-aig-openai-compatible-endpoint.mdx Co-authored-by: Kody Jackson <[email protected]> * Update src/content/changelog/ai-gateway/2025-06-02-aig-openai-compatible-endpoint.mdx Co-authored-by: Kody Jackson <[email protected]> * Update src/content/changelog/ai-gateway/2025-06-02-aig-openai-compatible-endpoint.mdx Co-authored-by: Kody Jackson <[email protected]> * Update 2025-06-02-aig-openai-compatible-endpoint.mdx * Update and rename 2025-06-02-aig-openai-compatible-endpoint.mdx to 2025-06-03-aig-openai-compatible-endpoint.mdx date change * Update src/content/changelog/ai-gateway/2025-06-03-aig-openai-compatible-endpoint.mdx Co-authored-by: Kody Jackson <[email protected]> * Update 2025-06-03-aig-openai-compatible-endpoint.mdx --------- Co-authored-by: Kody Jackson <[email protected]>
1 parent 953647a commit cd68088

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: AI Gateway adds OpenAI compatible endpoint
3+
description: AI Gateway has added OpenAI compatibility
4+
products:
5+
- ai-gateway
6+
date: 2025-06-03T12:00:00Z
7+
---
8+
Users can now use an [OpenAI Compatible endpoint](/ai-gateway/chat-completion/) in AI Gateway to easily switch between providers, while keeping the exact same request and response formats. We're launching now with the chat completions endpoint, with the embeddings endpoint coming up next.
9+
10+
To get started, use the OpenAI compatible chat completions endpoint URL with your own account id and gateway id and switch between providers by changing the `model` and `apiKey` parameters.
11+
12+
```js title="OpenAI SDK Example"
13+
import OpenAI from "openai";
14+
const client = new OpenAI({
15+
apiKey: "YOUR_PROVIDER_API_KEY", // Provider API key
16+
baseURL:
17+
"https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/compat/chat/completions",
18+
});
19+
20+
const response = await client.chat.completions.create({
21+
model: "google-ai-studio/gemini-2.0-flash",
22+
messages: [{ role: "user", content: "What is Cloudflare?" }],
23+
});
24+
25+
console.log(response.choices[0].message.content);
26+
```
27+
28+
Additionally, the [OpenAI Compatible endpoint](/ai-gateway/chat-completion/) can be combined with our [Universal Endpoint](/ai-gateway/universal/) to add fallbacks across multiple providers. That means AI Gateway will return every response in the same standardized format, no extra parsing logic required!
29+
30+
Learn more in the [OpenAI Compatibility](/ai-gateway/chat-completion/) documentation.

0 commit comments

Comments
 (0)