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
2 changes: 1 addition & 1 deletion src/content/docs/ai-gateway/features/unified-billing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Workers AI models (models prefixed with `@cf/`) routed through AI Gateway are no

### AI binding

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.
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.

```typescript
const resp = await env.AI.run(
Expand Down
8 changes: 6 additions & 2 deletions src/content/docs/ai-gateway/integrations/vercel-ai-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar:
order: 2
---

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

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.
Expand All @@ -25,6 +25,8 @@ npm install ai-gateway-provider

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`:

<TypeScriptExample>

```ts
import { createWorkersAI } from "workers-ai-provider";
import { streamText } from "ai";
Expand All @@ -46,7 +48,9 @@ export default {
} satisfies ExportedHandler<Env>;
```

This works with any [supported provider and model](/ai-gateway/usage/providers/) available through AI Gateway.
</TypeScriptExample>

This works with any [supported provider and model](/ai/models/) available through AI Gateway.

### Fallback Providers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: >-
for feedback, logging, URLs, and universal requests.
---

import { Render, WranglerConfig } from "~/components";
import { Render, TypeScriptExample, WranglerConfig } from "~/components";

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

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

**Workers AI model:**

```typescript
<TypeScriptExample>

```ts
const resp = await env.AI.run(
"@cf/moonshotai/kimi-k2.5",
{
Expand All @@ -58,9 +60,13 @@ const resp = await env.AI.run(
);
```

</TypeScriptExample>

**Third-party model:**

```typescript
<TypeScriptExample>

```ts
const resp = await env.AI.run(
"openai/gpt-4.1-mini",
{
Expand All @@ -74,13 +80,15 @@ const resp = await env.AI.run(
);
```

</TypeScriptExample>

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.

:::note
[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.
:::

Browse available models in the [model catalog](https://developers.cloudflare.com/ai/models/).
Browse available models in the [model catalog](/ai/models/).

### Gateway options

Expand Down
Loading