Skip to content

Commit c9f746a

Browse files
committed
copy
1 parent d13b57d commit c9f746a

2 files changed

Lines changed: 104 additions & 9 deletions

File tree

src/content/changelog/ai-gateway/2026-03-25-run-api-beta.mdx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
2-
title: Run API now available in beta
3-
description: AI Gateway introduces the Run API, a new endpoint for running AI models with a simplified request/response pattern.
2+
title: New Run API for AI Gateway now available in beta
3+
description: AI Gateway introduces the /run api and support for running third party models in Workers AI bindings
44
products:
55
- ai-gateway
66
date: 2026-03-25
77
---
88

99
AI Gateway now offers a new `/run` endpoint for running AI models. The Run API uses its own request envelope, separate from the OpenAI-compatible `/chat/completions` format, and is designed to support a broader range of model types over time.
1010

11-
During the beta, the Run API supports one model — `google/nano-banana` for image generation. Authenticate with [Unified Billing](/ai-gateway/features/unified-billing/) or [BYOK (Gateway Key Store)](/ai-gateway/configuration/bring-your-own-keys/).
11+
Today, the Run API supports one model — `google/nano-banana` for image generation. Authenticate with [Unified Billing](/ai-gateway/features/unified-billing/) or [BYOK (Gateway Key Store)](/ai-gateway/configuration/bring-your-own-keys/).
1212

1313
```bash
1414
curl -X POST "https://gateway.ai.cloudflare.com/v1/$CLOUDFLARE_ACCOUNT_ID/default/run" \
@@ -22,4 +22,14 @@ curl -X POST "https://gateway.ai.cloudflare.com/v1/$CLOUDFLARE_ACCOUNT_ID/defaul
2222
}'
2323
```
2424

25+
With this release, the Workers AI binding (`env.AI.run()`) now supports running third-party models proxied through AI Gateway. You can call models like `google/nano-banana` directly from a Cloudflare Worker without managing provider credentials in your code:
26+
27+
```ts
28+
const response = await env.AI.run(
29+
"google/nano-banana",
30+
{ prompt: "a cat riding a burrito" },
31+
{ gateway: { id: "my-gateway" } },
32+
);
33+
```
34+
2535
Additional models and features will be added in future updates. For more information, refer to the [Run API](/ai-gateway/usage/run-api/) documentation.

src/content/docs/ai-gateway/usage/run-api.mdx

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,32 @@ The Run API supports the following authentication methods for upstream provider
3636
Passing provider API keys directly in request headers is not supported with the Run API. You must use Unified Billing or BYOK (Gateway Key Store) to authenticate with upstream providers.
3737
:::
3838

39+
## Request
40+
41+
```txt
42+
POST /v1/{account_id}/{gateway_id}/run
43+
```
44+
45+
### Request body
46+
47+
| Field | Type | Required | Description |
48+
| --- | --- | --- | --- |
49+
| `model` | `string` | Yes | The model to run. Refer to [Supported models](#supported-models) for available values. |
50+
| `input` | `object` | Yes | Model-specific input parameters. The accepted fields depend on the model. |
51+
| `provider` | `string` | No | Pin the request to a specific provider instead of using the default. |
52+
| `background` | `boolean` | No | When `true`, the request returns immediately with a `runId` that you can poll for results. |
53+
| `webhookUrl` | `string` | No | A URL to receive a callback when the run completes. Only valid when `background` is `true`. |
54+
55+
### Input fields for `google/nano-banana`
56+
57+
| Field | Type | Required | Description |
58+
| --- | --- | --- | --- |
59+
| `prompt` | `string` | Yes | The text prompt describing the image to generate. |
60+
| `image_input` | `string[]` | No | Up to 3 base64-encoded images to use as input for image-to-image generation. |
61+
| `aspect_ratio` | `string` | No | Aspect ratio of the output image. One of: `1:1`, `3:2`, `2:3`, `3:4`, `4:3`, `4:5`, `5:4`, `9:16`, `16:9`, `21:9`. |
62+
| `output_format` | `string` | No | Output image format. One of: `jpg`, `png`, `webp`. |
63+
| `image_size` | `string` | No | Output image resolution. One of: `1K`, `2K`, `4K`. |
64+
3965
## Supported models
4066

4167
The Run API currently supports a single model:
@@ -46,7 +72,9 @@ The Run API currently supports a single model:
4672

4773
More models will be added in future updates.
4874

49-
## Example
75+
## Examples
76+
77+
### Basic request
5078

5179
<Tabs>
5280
<TabItem label="curl">
@@ -108,7 +136,66 @@ export default {
108136
</TabItem>
109137
</Tabs>
110138

111-
### Response
139+
### With input options
140+
141+
```bash
142+
curl -X POST "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/run" \
143+
--header "cf-aig-authorization: Bearer $CLOUDFLARE_API_TOKEN" \
144+
--header "Content-Type: application/json" \
145+
--data '{
146+
"model": "google/nano-banana",
147+
"input": {
148+
"prompt": "a cat riding a burrito",
149+
"aspect_ratio": "16:9",
150+
"output_format": "png",
151+
"image_size": "2K"
152+
}
153+
}'
154+
```
155+
156+
### Background run
157+
158+
Set `background` to `true` to run the request asynchronously. The API returns a `runId` immediately, which you can poll for results.
159+
160+
```bash
161+
curl -X POST "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/run" \
162+
--header "cf-aig-authorization: Bearer $CLOUDFLARE_API_TOKEN" \
163+
--header "Content-Type: application/json" \
164+
--data '{
165+
"model": "google/nano-banana",
166+
"input": {
167+
"prompt": "a cat riding a burrito"
168+
},
169+
"background": true
170+
}'
171+
```
172+
173+
Poll for the result using the returned `runId`:
174+
175+
```bash
176+
curl "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/run/{run_id}" \
177+
--header "cf-aig-authorization: Bearer $CLOUDFLARE_API_TOKEN"
178+
```
179+
180+
You can also provide a `webhookUrl` to receive a callback when the run completes instead of polling:
181+
182+
```bash
183+
curl -X POST "https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/run" \
184+
--header "cf-aig-authorization: Bearer $CLOUDFLARE_API_TOKEN" \
185+
--header "Content-Type: application/json" \
186+
--data '{
187+
"model": "google/nano-banana",
188+
"input": {
189+
"prompt": "a cat riding a burrito"
190+
},
191+
"background": true,
192+
"webhookUrl": "https://example.com/webhook"
193+
}'
194+
```
195+
196+
## Response
197+
198+
### Success
112199

113200
A successful request returns a response with the following envelope:
114201

@@ -132,7 +219,7 @@ A successful request returns a response with the following envelope:
132219
| `provider` | The provider that served the request. |
133220
| `model` | The model that was used. |
134221

135-
### Error response
222+
### Error
136223

137224
```json
138225
{
@@ -150,11 +237,9 @@ A successful request returns a response with the following envelope:
150237
The Run API is in beta. The following limitations apply:
151238

152239
- **One model** — Only `google/nano-banana` is supported. Additional models will be added over time.
153-
- **Image generation only** — Chat and text generation models are not yet available through the Run API.
154240
- **No caching**[Caching](/ai-gateway/features/caching/) is not supported for Run API requests.
155241
- **No rate limiting**[Rate limiting](/ai-gateway/features/rate-limiting/) rules do not apply to Run API requests.
156-
- **No guardrails**[Guardrails](/ai-gateway/guardrails/) are not available for the Run API.
157-
- **No DLP** — Data loss prevention features are not supported.
242+
- **No guardrails or DLP**[Guardrails](/ai-gateway/guardrails/) and data loss prevention features are not available for the Run API.
158243
- **No dynamic routing**[Dynamic routing](/ai-gateway/features/dynamic-routing/) (fallbacks, A/B testing, conditional logic) is not available.
159244
- **No streaming** — Streaming responses are not supported.
160245
- **No TypeScript types** — TypeScript type definitions for the Run API are not yet available in `@cloudflare/workers-types`.

0 commit comments

Comments
 (0)