@@ -163,7 +163,6 @@ await anthropic.beta.messages.batches.create({
163
163
});
164
164
```
165
165
166
-
167
166
### Getting results from a batch
168
167
169
168
Once a Message Batch has been processed, indicated by ` .processing_status === 'ended' ` , you can access the results with ` .batches.results() `
@@ -172,7 +171,7 @@ Once a Message Batch has been processed, indicated by `.processing_status === 'e
172
171
const results = await anthropic .beta .messages .batches .results (batch_id );
173
172
for await (const entry of results ) {
174
173
if (entry .result .type === ' succeeded' ) {
175
- console .log (entry .result .message .content )
174
+ console .log (entry .result .message .content );
176
175
}
177
176
}
178
177
```
@@ -234,11 +233,14 @@ Error codes are as follows:
234
233
All object responses in the SDK provide a ` _request_id ` property which is added from the ` request-id ` response header so that you can quickly log failing requests and report them back to Anthropic.
235
234
236
235
``` ts
237
- const message = await client .messages .create ({ max_tokens: 1024 , messages: [{ role: ' user' , content: ' Hello, Claude' }], model: ' claude-3-5-sonnet-latest' });
238
- console .log (completion ._request_id ) // req_018EeWyXxfu5pfWkrYcMdjWG
236
+ const message = await client .messages .create ({
237
+ max_tokens: 1024 ,
238
+ messages: [{ role: ' user' , content: ' Hello, Claude' }],
239
+ model: ' claude-3-5-sonnet-latest' ,
240
+ });
241
+ console .log (completion ._request_id ); // req_018EeWyXxfu5pfWkrYcMdjWG
239
242
```
240
243
241
-
242
244
### Retries
243
245
244
246
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
@@ -263,12 +265,14 @@ await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', cont
263
265
### Timeouts
264
266
265
267
By default requests time out after 10 minutes. However if you have specified a large ` max_tokens ` value and are
266
- * not* streaming, the default timeout will be calculated dynamically using the formula:
268
+ _ not_ streaming, the default timeout will be calculated dynamically using the formula:
269
+
267
270
``` typescript
268
271
const minimum = 10 * 60 ;
269
272
const calculated = (60 * 60 * maxTokens ) / 128_000 ;
270
273
return calculated < minimum ? minimum * 1000 : calculated * 1000 ;
271
274
```
275
+
272
276
which will result in a timeout up to 60 minutes, scaled by the ` max_tokens ` parameter, unless overriden at the request or client level.
273
277
274
278
You can configure this with a ` timeout ` option:
0 commit comments