Skip to content

Commit a90a4c3

Browse files
authored
[AI Gateway] Fix full URLs, add TypeScriptExample components, and correct model catalog link (#30013)
Address PR #29864 feedback: convert full URLs to root-relative paths, wrap Workers code examples with TypeScriptExample for TS/JS tabs, and point the Vercel AI SDK model link to /ai/models/ instead of /ai-gateway/usage/providers/.
1 parent dbc00a2 commit a90a4c3

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/content/docs/ai-gateway/features/unified-billing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Workers AI models (models prefixed with `@cf/`) routed through AI Gateway are no
5757

5858
### AI binding
5959

60-
Call any model listed in the [model catalog](https://developers.cloudflare.com/ai/models/) using `env.AI.run()`. This includes both Workers AI models and third-party models from providers like OpenAI, Anthropic, and Google.
60+
Call any model listed in the [model catalog](/ai/models/) using `env.AI.run()`. This includes both Workers AI models and third-party models from providers like OpenAI, Anthropic, and Google.
6161

6262
```typescript
6363
const resp = await env.AI.run(

src/content/docs/ai-gateway/integrations/vercel-ai-sdk.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 2
66
---
77

8-
import { Details, Tabs, TabItem } from "~/components";
8+
import { Details, Tabs, TabItem, TypeScriptExample } from "~/components";
99
import CodeSnippets from "~/components/ai-gateway/code-examples.astro";
1010

1111
The [Vercel AI SDK](https://sdk.vercel.ai/) is a TypeScript library for building AI applications. The SDK supports many different AI providers, tools for streaming completions, and more.
@@ -25,6 +25,8 @@ npm install ai-gateway-provider
2525

2626
If you are already using the [`workers-ai-provider`](https://www.npmjs.com/package/workers-ai-provider) package, you can route requests through AI Gateway to call third-party models without needing separate provider SDKs. Pass a `gateway` option with your gateway ID to `createWorkersAI`:
2727

28+
<TypeScriptExample>
29+
2830
```ts
2931
import { createWorkersAI } from "workers-ai-provider";
3032
import { streamText } from "ai";
@@ -46,7 +48,9 @@ export default {
4648
} satisfies ExportedHandler<Env>;
4749
```
4850

49-
This works with any [supported provider and model](/ai-gateway/usage/providers/) available through AI Gateway.
51+
</TypeScriptExample>
52+
53+
This works with any [supported provider and model](/ai/models/) available through AI Gateway.
5054

5155
### Fallback Providers
5256

src/content/docs/ai-gateway/integrations/worker-binding-methods.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ description: >-
1212
for feedback, logging, URLs, and universal requests.
1313
---
1414

15-
import { Render, WranglerConfig } from "~/components";
15+
import { Render, TypeScriptExample, WranglerConfig } from "~/components";
1616

1717
The AI binding (`env.AI`) lets you call AI models and access AI Gateway features directly from your Worker.
1818

@@ -44,7 +44,9 @@ Runs an inference request through AI Gateway. Accepts Workers AI models (`@cf/`
4444

4545
**Workers AI model:**
4646

47-
```typescript
47+
<TypeScriptExample>
48+
49+
```ts
4850
const resp = await env.AI.run(
4951
"@cf/moonshotai/kimi-k2.5",
5052
{
@@ -58,9 +60,13 @@ const resp = await env.AI.run(
5860
);
5961
```
6062

63+
</TypeScriptExample>
64+
6165
**Third-party model:**
6266

63-
```typescript
67+
<TypeScriptExample>
68+
69+
```ts
6470
const resp = await env.AI.run(
6571
"openai/gpt-4.1-mini",
6672
{
@@ -74,13 +80,15 @@ const resp = await env.AI.run(
7480
);
7581
```
7682

83+
</TypeScriptExample>
84+
7785
Third-party models require an AI Gateway and use [Unified Billing](/ai-gateway/features/unified-billing/). Cloudflare manages the provider credentials and deducts credits from your account. You do not need to supply your own API keys.
7886

7987
:::note
8088
[BYOK (Bring Your Own Keys)](/ai-gateway/configuration/bring-your-own-keys/) is not supported for third-party models called through the AI binding. To use your own provider keys, use the [AI Gateway REST API](/ai-gateway/usage/providers/) or the [chat completions endpoint](/ai-gateway/usage/chat-completion/) instead.
8189
:::
8290

83-
Browse available models in the [model catalog](https://developers.cloudflare.com/ai/models/).
91+
Browse available models in the [model catalog](/ai/models/).
8492

8593
### Gateway options
8694

0 commit comments

Comments
 (0)