Skip to content

Commit 44c162a

Browse files
typescript fixes
1 parent ac0ffe2 commit 44c162a

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/content/docs/workers-ai/features/async-batch-api.mdx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ Ensure that the total payload is under 10 MB.
7777

7878
:::
7979

80-
```javascript title=Example code
81-
// Input: JSON with an array of individual request JSONs
80+
```typescript title="src/index.js"
81+
interface AIRequest {
82+
prompt: string;
83+
temperature: number;
84+
max_tokens: number;
85+
}
86+
8287
const resp = env.AI.run(
8388
"@cf/meta/ray-llama-3.3-70b-instruct-fp8-fast",
8489
{
@@ -98,7 +103,7 @@ const resp = env.AI.run(
98103
temperature: 0.7,
99104
max_tokens: 102,
100105
},
101-
],
106+
] as AIRequest[],
102107
},
103108
{ queueRequest: true },
104109
);
@@ -131,9 +136,7 @@ const status = env.AI.run("@cf/meta/ray-llama-3.3-70b-instruct-fp8-fast", {
131136
});
132137
```
133138

134-
#### Expected polling response (while queued)
135-
136-
```json
139+
```json output
137140
{
138141
"status": "queued",
139142
"request_id": "000-000-000"
@@ -275,12 +278,9 @@ Make a POST request to the following endpoint:
275278
Authorization: "<token>",
276279
"Content-Type": "application/json",
277280
}}
278-
code={{ mark: "value" }}
279281
/>
280282

281-
#### Request Payload Example
282-
283-
```json
283+
```json output
284284
{
285285
"requests": [
286286
{
@@ -299,15 +299,16 @@ Make a POST request to the following endpoint:
299299

300300
After receiving a `request_id` from your initial POST, you can poll for or retrieve the results with another POST request:
301301

302-
```bash
303-
POST https://api.cloudflare.com/client/v4/accounts/<account-id>/ai/run/@cf/meta/ray-llama-3.3-70b-instruct-fp8-fast
304-
Authorization: <token>
305-
Content-Type: application/json
306-
```
307-
308-
#### Request Payload for Retrieving Results
302+
<CURL
303+
url="https://api.cloudflare.com/client/v4/accounts/<account-id>/ai/run/@cf/meta/ray-llama-3.3-70b-instruct-fp8-fast"
304+
method="POST"
305+
headers={{
306+
Authorization: "<token>",
307+
"Content-Type": "application/json",
308+
}}
309+
/>
309310

310-
```json
311+
```json output
311312
{
312313
"request_id": "<uuid>"
313314
}

0 commit comments

Comments
 (0)