Create Batch
Example Usage
import OpenAI from 'openai';
import { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'
const client = new OpenAI({
baseURL: PORTKEY_GATEWAY_URL,
defaultHeaders: createHeaders({
apiKey: "PORTKEY_API_KEY",
virtualKey: "PROVIDER_VIRTUAL_KEY"
})
});
async function main() {
const batch = await client.batches.create({
input_file_id: "file-abc123",
endpoint: "/v1/chat/completions",
completion_window: "24h"
});
console.log(batch);
}
main();
Authorizations
Body
any ofOptional
or
or
or
Responses
200
Batch created successfully.
application/json
post
curl https://api.portkey.ai/v1/batches \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \
-H "Content-Type: application/json" \
-d '{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}'
200
Batch created successfully.
{
"id": "text",
"object": "batch",
"endpoint": "text",
"errors": {
"object": "text",
"data": [
{
"code": "text",
"message": "text",
"param": "text",
"line": 1
}
]
},
"input_file_id": "text",
"completion_window": "text",
"status": "validating",
"output_file_id": "text",
"error_file_id": "text",
"created_at": 1,
"in_progress_at": 1,
"expires_at": 1,
"finalizing_at": 1,
"completed_at": 1,
"failed_at": 1,
"expired_at": 1,
"cancelling_at": 1,
"cancelled_at": 1,
"request_counts": {
"total": 1,
"completed": 1,
"failed": 1
},
"metadata": {}
}
Last updated
Was this helpful?