> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://respan.ai/docs/apis/gateway/list-batches/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/_mcp/server. # List batches GET https://api.respan.ai/api/v1/batches List batches from the selected provider using customer-owned credentials. The response is relayed in the provider's OpenAI-compatible shape. Reference: https://respan.ai/docs/apis/gateway/list-batches ## Authentication - `Authorization` header (bearer token, required) — Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer \. 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. ## Request ### Query parameters - `provider_id` (string, required) — Provider route, for example `openai` or `parasail`. - `after` (string, optional) — Provider pagination cursor. - `limit` (integer, optional) — Maximum batches requested from the provider. ## Response ### 200 OpenAI-compatible batch list. - `object` (enum, required) - Allowed values: `list` - `data` (list of ApiV1BatchesGetResponsesContentApplicationJsonSchemaDataItems, required) - `first_id` (string, optional, nullable) - `last_id` (string, optional, nullable) - `has_more` (boolean, optional) ## Errors ### 400 Bad Request Error `provider_id` is missing. - `detail` (string, required) ### 401 Unauthorized Error 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. - `detail` (string, required) ### 403 Forbidden Error The API key is missing, invalid or expired. - `detail` (string, required) ### 424 Failed Dependency Error The upstream provider failed. - `detail` (string, optional) ## Types ### ApiV1BatchesGetResponsesContentApplicationJsonSchemaDataItems - `id` (string, required) — Batch ID. - `status` (enum, required) - Allowed values: `validating`, `pending`, `in_progress`, `finalizing`, `completed`, `failed`, `expired`, `cancelling`, `cancelled` - `object` (string, optional) - `endpoint` (string, optional) - `input_file_id` (string, optional) - `output_file_id` (string, optional, nullable) — Output file ID, available when the batch completes. - `error_file_id` (string, optional, nullable) — Error file ID, when provider errors are available. - `completion_window` (string, optional) - `created_at` (integer, optional) — Unix timestamp. - `in_progress_at` (integer, optional, nullable) - `expires_at` (integer, optional, nullable) - `finalizing_at` (integer, optional, nullable) - `completed_at` (integer, optional, nullable) - `failed_at` (integer, optional, nullable) - `expired_at` (integer, optional, nullable) - `cancelling_at` (integer, optional, nullable) - `cancelled_at` (integer, optional, nullable) - `request_counts` (ApiV1BatchesGetResponsesContentApplicationJsonSchemaDataItemsRequestCounts, optional) - `metadata` (map from string to any, optional) - `errors` (any, optional, nullable) — Provider error details, when available. ### ApiV1BatchesGetResponsesContentApplicationJsonSchemaDataItemsRequestCounts - `total` (integer, optional) - `completed` (integer, optional) - `failed` (integer, optional) ## Examples **Response** ```json { "object": "list", "data": [ { "id": "batch_abc123", "status": "in_progress", "object": "batch", "endpoint": "/v1/chat/completions", "input_file_id": "file-abc123", "output_file_id": "string", "error_file_id": "string", "completion_window": "24h", "created_at": 1710000000, "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": 100, "completed": 97, "failed": 3 }, "metadata": {}, "errors": null } ], "first_id": "string", "last_id": "string", "has_more": true } ``` **SDK Code** ```python import requests url = "https://api.respan.ai/api/v1/batches" querystring = {"provider_id":"provider_id"} headers = {"Authorization": "Bearer "} response = requests.get(url, headers=headers, params=querystring) print(response.json()) ``` ```javascript const url = 'https://api.respan.ai/api/v1/batches?provider_id=provider_id'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.respan.ai/api/v1/batches?provider_id=provider_id" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.respan.ai/api/v1/batches?provider_id=provider_id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.respan.ai/api/v1/batches?provider_id=provider_id") .header("Authorization", "Bearer ") .asString(); ``` ```php request('GET', 'https://api.respan.ai/api/v1/batches?provider_id=provider_id', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.respan.ai/api/v1/batches?provider_id=provider_id"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let request = NSMutableURLRequest(url: NSURL(string: "https://api.respan.ai/api/v1/batches?provider_id=provider_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```