You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workers-ai/features/async-batch-api.mdx
+14-7Lines changed: 14 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,11 +65,17 @@ binding = "AI"
65
65
66
66
Your binding is [available in your Worker code](/workers/reference/migrate-to-module-workers/#bindings-in-es-modules-format) on [`env.AI`](/workers/runtime-apis/handlers/fetch/).
67
67
68
-
## 4. How to use the Batch API
68
+
## 5. How to use the Batch API
69
69
70
70
### 1. Sending a Batch request
71
71
72
-
Send your initial batch inference request by composing a JSON payload containing an array of individual inference requests. Ensure that the total payload is under 25 MB.
72
+
Send your initial batch inference request by composing a JSON payload containing an array of individual inference requests.
73
+
74
+
:::note[Note]
75
+
76
+
Ensure that the total payload is under 25 MB.
77
+
78
+
:::
73
79
74
80
```javascript title=Example code
75
81
// Input: JSON with an array of individual request JSONs
@@ -183,7 +189,7 @@ When the inference is complete, the API returns a final HTTP status code of `200
183
189
-**`success`**: A Boolean flag indicating if the request was processed successfully.
184
190
-**`usage`**: Contains token usage details for the batch request.
185
191
186
-
## 5. Implementing the Batch API in your Worker
192
+
## 6. Implementing the Batch API in your Worker
187
193
188
194
Below is a sample TypeScript Worker that receives a batch of inference requests, sends them to a batch-enabled AI model, and returns the results.
189
195
@@ -263,9 +269,10 @@ If you prefer to work directly with the REST API instead of a Cloudflare Worker,
263
269
Make a POST request to the following endpoint:
264
270
265
271
```bash
266
-
POST https://api.cloudflare.com/client/v4/accounts/<account-id>/ai/run/@cf/meta/ray-llama-3.3-70b-instruct-fp8-fast?queueRequest=true
0 commit comments