Create a batch
https://api.respan.ai/api/v1/batchesCreate an OpenAI-compatible batch processing job from an uploaded JSONL file. provider_id is required and selects the customer-owned provider credential used for the batch.
Servers
https://api.respan.ai: Respan API Server
Authentication
RespanApiKey
Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.
HTTP scheme: bearer; format: Respan API key.
Authorization: Bearer $RESPAN_API_KEYHeaders
X-Data-Respan-Params string OptionalX-Data-Keywordsai-Params is still accepted.Request body
A request body is required.
application/json
$ object Required body
input_file_id string Required in parentExample:
"file-abc123"endpoint string Required in parentAllowed:
"/v1/chat/completions", "/v1/embeddings"Example:
"/v1/chat/completions"completion_window string Required in parent"24h"Example:
"24h"metadata object OptionalAdditional properties are allowed
Example:
{"project":"eval-run-1"}customer_identifier string OptionalExample:
"user_123"custom_identifier string Optionalthread_identifier string Optionalenvironment string OptionalExample:
"prod"provider_id string Required in parentOpenAPI request schema
{
"type": "object",
"required": [
"input_file_id",
"endpoint",
"completion_window",
"provider_id"
],
"properties": {
"input_file_id": {
"type": "string",
"description": "Uploaded JSONL file ID.",
"example": "file-abc123"
},
"endpoint": {
"type": "string",
"description": "Endpoint each JSONL request targets.",
"enum": [
"/v1/chat/completions",
"/v1/embeddings"
],
"example": "/v1/chat/completions"
},
"completion_window": {
"type": "string",
"enum": [
"24h"
],
"example": "24h"
},
"metadata": {
"type": "object",
"description": "Custom metadata for tracking.",
"additionalProperties": true,
"example": {
"project": "eval-run-1"
}
},
"customer_identifier": {
"type": "string",
"description": "End-user identifier for logging.",
"example": "user_123"
},
"custom_identifier": {
"type": "string",
"description": "Custom identifier for querying."
},
"thread_identifier": {
"type": "string",
"description": "Conversation thread identifier."
},
"environment": {
"type": "string",
"description": "Environment tag.",
"example": "prod"
},
"provider_id": {
"type": "string",
"description": "Provider route with customer-owned credentials."
}
}
}Responses
200
Created batch.
application/json
$ object Body
id string Required in parentExample:
"batch_abc123"object string Optional"batch"endpoint string Optional"/v1/chat/completions"input_file_id string Optional"file-abc123"output_file_id string or null Optionalerror_file_id string or null Optionalcompletion_window string Optional"24h"status string Required in parent"validating", "pending", "in_progress", "finalizing", "completed", "failed", "expired", "cancelling", "cancelled"Example:
"in_progress"created_at integer OptionalExample:
1710000000in_progress_at integer or null Optionalexpires_at integer or null Optionalfinalizing_at integer or null Optionalcompleted_at integer or null Optionalfailed_at integer or null Optionalexpired_at integer or null Optionalcancelling_at integer or null Optionalcancelled_at integer or null Optionalrequest_counts object Optional
request_counts.total integer Optional100request_counts.completed integer Optional97request_counts.failed integer Optional3metadata object Optionalerrors any or null OptionalOpenAPI response schema
{
"type": "object",
"required": [
"id",
"status"
],
"properties": {
"id": {
"type": "string",
"description": "Batch ID.",
"example": "batch_abc123"
},
"object": {
"type": "string",
"example": "batch"
},
"endpoint": {
"type": "string",
"example": "/v1/chat/completions"
},
"input_file_id": {
"type": "string",
"example": "file-abc123"
},
"output_file_id": {
"type": "string",
"nullable": true,
"description": "Output file ID, available when the batch completes."
},
"error_file_id": {
"type": "string",
"nullable": true,
"description": "Error file ID, when provider errors are available."
},
"completion_window": {
"type": "string",
"example": "24h"
},
"status": {
"type": "string",
"enum": [
"validating",
"pending",
"in_progress",
"finalizing",
"completed",
"failed",
"expired",
"cancelling",
"cancelled"
],
"example": "in_progress"
},
"created_at": {
"type": "integer",
"description": "Unix timestamp.",
"example": 1710000000
},
"in_progress_at": {
"type": "integer",
"nullable": true
},
"expires_at": {
"type": "integer",
"nullable": true
},
"finalizing_at": {
"type": "integer",
"nullable": true
},
"completed_at": {
"type": "integer",
"nullable": true
},
"failed_at": {
"type": "integer",
"nullable": true
},
"expired_at": {
"type": "integer",
"nullable": true
},
"cancelling_at": {
"type": "integer",
"nullable": true
},
"cancelled_at": {
"type": "integer",
"nullable": true
},
"request_counts": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"example": 100
},
"completed": {
"type": "integer",
"example": 97
},
"failed": {
"type": "integer",
"example": 3
}
}
},
"metadata": {
"type": "object",
"additionalProperties": true
},
"errors": {
"nullable": true,
"description": "Provider error details, when available."
}
},
"additionalProperties": true
}400
Bad Request
application/json
$ object Body
error string Optionaldetail string Optionalerror_class string Optionalid string OptionalOpenAPI response schema
{
"type": "object",
"properties": {
"error": {
"type": "string"
},
"detail": {
"type": "string"
},
"error_class": {
"type": "string"
},
"id": {
"type": "string"
}
},
"additionalProperties": true
}Example
{
"error": "Invalid request"
}401
You haven’t added your own key for the provider in Settings › Providers, or the provider rejected it. Files and batches always run on your own key; Respan credits can’t cover them.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Example
{
"detail": "Please add your OpenAI API key in Settings -> Providers. The Files and Batch endpoints always run on your own credentials. Respan credits cannot cover them, because a batch's usage is only known after it completes."
}403
The API key is missing, invalid or expired.
application/json
$ object Body
detail string Required in parentOpenAPI response schema
{
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
}Example
{
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}OpenAPI source
The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.
OpenAPI operation
{
"summary": "Create a batch",
"operationId": "createBatch",
"tags": [
"OpenAI Batch"
],
"description": "Create an OpenAI-compatible batch processing job from an uploaded JSONL file. `provider_id` is required and selects the customer-owned provider credential used for the batch.",
"parameters": [
{
"name": "X-Data-Respan-Params",
"in": "header",
"required": false,
"schema": {
"type": "string"
},
"description": "Base64-encoded JSON object of Respan request parameters. Legacy `X-Data-Keywordsai-Params` is still accepted."
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"input_file_id",
"endpoint",
"completion_window",
"provider_id"
],
"properties": {
"input_file_id": {
"type": "string",
"description": "Uploaded JSONL file ID.",
"example": "file-abc123"
},
"endpoint": {
"type": "string",
"description": "Endpoint each JSONL request targets.",
"enum": [
"/v1/chat/completions",
"/v1/embeddings"
],
"example": "/v1/chat/completions"
},
"completion_window": {
"type": "string",
"enum": [
"24h"
],
"example": "24h"
},
"metadata": {
"type": "object",
"description": "Custom metadata for tracking.",
"additionalProperties": true,
"example": {
"project": "eval-run-1"
}
},
"customer_identifier": {
"type": "string",
"description": "End-user identifier for logging.",
"example": "user_123"
},
"custom_identifier": {
"type": "string",
"description": "Custom identifier for querying."
},
"thread_identifier": {
"type": "string",
"description": "Conversation thread identifier."
},
"environment": {
"type": "string",
"description": "Environment tag.",
"example": "prod"
},
"provider_id": {
"type": "string",
"description": "Provider route with customer-owned credentials."
}
}
}
}
}
},
"responses": {
"200": {
"description": "Created batch.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"id",
"status"
],
"properties": {
"id": {
"type": "string",
"description": "Batch ID.",
"example": "batch_abc123"
},
"object": {
"type": "string",
"example": "batch"
},
"endpoint": {
"type": "string",
"example": "/v1/chat/completions"
},
"input_file_id": {
"type": "string",
"example": "file-abc123"
},
"output_file_id": {
"type": "string",
"nullable": true,
"description": "Output file ID, available when the batch completes."
},
"error_file_id": {
"type": "string",
"nullable": true,
"description": "Error file ID, when provider errors are available."
},
"completion_window": {
"type": "string",
"example": "24h"
},
"status": {
"type": "string",
"enum": [
"validating",
"pending",
"in_progress",
"finalizing",
"completed",
"failed",
"expired",
"cancelling",
"cancelled"
],
"example": "in_progress"
},
"created_at": {
"type": "integer",
"description": "Unix timestamp.",
"example": 1710000000
},
"in_progress_at": {
"type": "integer",
"nullable": true
},
"expires_at": {
"type": "integer",
"nullable": true
},
"finalizing_at": {
"type": "integer",
"nullable": true
},
"completed_at": {
"type": "integer",
"nullable": true
},
"failed_at": {
"type": "integer",
"nullable": true
},
"expired_at": {
"type": "integer",
"nullable": true
},
"cancelling_at": {
"type": "integer",
"nullable": true
},
"cancelled_at": {
"type": "integer",
"nullable": true
},
"request_counts": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"example": 100
},
"completed": {
"type": "integer",
"example": 97
},
"failed": {
"type": "integer",
"example": 3
}
}
},
"metadata": {
"type": "object",
"additionalProperties": true
},
"errors": {
"nullable": true,
"description": "Provider error details, when available."
}
},
"additionalProperties": true
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"detail": {
"type": "string"
},
"error_class": {
"type": "string"
},
"id": {
"type": "string"
}
},
"additionalProperties": true
},
"example": {
"error": "Invalid request"
}
}
}
},
"401": {
"description": "You haven't added your own key for the provider in Settings › Providers, or the provider rejected it. Files and batches always run on your own key; Respan credits can't cover them.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"example": {
"detail": "Please add your OpenAI API key in Settings -> Providers. The Files and Batch endpoints always run on your own credentials. Respan credits cannot cover them, because a batch's usage is only known after it completes."
}
}
}
},
"403": {
"$ref": "#/components/responses/InvalidApiKey"
}
},
"security": [
{
"RespanApiKey": []
}
]
}OpenAPI path metadata
{}Referenced OpenAPI components
{
"responses": {
"InvalidApiKey": {
"description": "The API key is missing, invalid or expired.",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"detail"
],
"properties": {
"detail": {
"type": "string"
}
}
},
"example": {
"detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
}
}
}
},
"securitySchemes": {
"RespanApiKey": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "Respan API key",
"description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
"x-fern-bearer": {
"name": "respanApiKey",
"env": "RESPAN_API_KEY"
}
}
}
}