Skip to main content
Run many requests as one asynchronous batch. You upload a file with one request per line, Eden AI runs the whole batch on the provider at the provider’s batch rates, and you read the results when the batch has finished.

Providers and endpoints

A batch has one model and one url: every line names the same model and calls the same endpoint. In GET /v3/models, capabilities.supports_batch is true on each entry a batch accepts. Image, audio and other endpoints are not available in a batch. Every provider’s batch is created, listed, cancelled and read through the same routes. Chat lines use the chat completions format on every provider, and so do their results: an Anthropic result is translated to a chat completion.

Regions

A batch runs in the provider’s default region, and a model named with a region tag is refused with 400.

Overview

All routes are under https://api.edenai.run/v3/batches and use the same Authorization: Bearer YOUR_API_KEY header as the rest of the API. A batch that belongs to another account, or that does not exist, answers 404. /v3/batches is the only batch API. The V2 API has none: its /v2/{feature}/{subfeature}/batch/{name}/ route runs each line as its own separate feature call and does not use a provider’s batch endpoint. A sandbox token sends nothing to the provider: the batch is answered at once with sample results and is not billed.

Input file

The input is a JSONL file: one JSON object per line, in UTF-8. Empty lines are ignored. Each line describes one request:
No other key is allowed on a line.

Rules for every chat line

  • body.model is openai/<model>, anthropic/<model> or mistral/<model> with no @ or : suffix. Every line of a batch names the same model.
  • The model must have published batch rates. Models without them, models that price long-context bands, and models that price cached input without a cached batch rate are refused. Models that price cache writes or audio are refused too, except that cache-write rates do not refuse an Anthropic model (its lines carry no cache marker).
  • In GET /v3/models, capabilities.supports_batch is true on each entry a batch accepts, by the same rules.
  • Messages carry text only. A content list may contain text parts only.
  • max_tokens or max_completion_tokens on each line sets how much output Eden AI reserves for that line. Without either, the reservation uses the model’s maximum output. See Billing. A max_tokens is sent to OpenAI as max_completion_tokens, which every OpenAI chat model takes; GPT-5 and o-series models refuse max_tokens in a batch.
  • On Anthropic and Mistral, a line that states no output limit is sent with the reserved bound as its max_tokens. max_tokens applies to each completion, so a Mistral line with n above 1 is sent the reserved bound divided by n.
  • An output limit is checked as the provider’s own API documents it, and a value the provider refuses fails the file with 400 naming the line. Anthropic takes a number of 0 or more, and Mistral an integer of 0 or more.
  • A line that states both max_tokens and max_completion_tokens is reserved at the first one that is a positive integer, max_tokens first, and on Anthropic that value is the one sent. A limit that is not a positive integer, such as 512.0, reserves the model’s maximum output, and on Anthropic and Mistral it is sent capped at that reservation, a whole number written as an integer (512.0 is sent as 512).
  • service_tier, when present on an OpenAI line, is auto or default.
  • routing may only contain zero_data_retention. See Zero data retention.
  • Every line is moderated. See Content moderation.
A batch prices prompt and completion tokens only, so an OpenAI line’s body may carry these fields and no others: model, messages, n, max_tokens, max_completion_tokens, temperature, top_p, stop, seed, presence_penalty, frequency_penalty, logit_bias, logprobs, top_logprobs, response_format, reasoning_effort, verbosity, user, service_tier, stream (false only), prompt_cache_key and routing. Any other field, such as tools, web_search_options, audio or modalities, is refused with 400 naming the line and the field. These body fields are refused on every provider: stream set to true, tools, functions, function_call, prediction, fallbacks, router_candidates, pre_hooks, post_hooks, session_id, tags, extra_headers and extra_body. Fields that set the provider connection or how a call is priced, such as api_key and api_base, are refused as in any other request.

What each provider accepts on a chat line

A refused field fails the whole file with 400 and the message Line N: ... naming the field. An Anthropic line has the same shape as any chat line, with an anthropic/ model and the fields from the table above:

File limits

A batch holds at most 5,000 lines, and the file is at most 100 MB. A file with more than 5,000 requests is refused with 400, and so is a file with no request.

Create a batch

Send the file as multipart/form-data.
The response is the batch object:

Create from an uploaded file

The create route also takes the JSON body the OpenAI SDK’s batches.create sends. Upload the JSONL file with POST /v3/upload, then send its file_id as input_file_id. The OpenAI SDK’s files.create has no route here: upload through /v3/upload instead. The file goes through the same checks as one sent in the form. A file id that does not exist, has expired, or belongs to another user answers 404, and so does a file whose stored content can no longer be read: upload it again. A stored file larger than 100 MB answers 413, and a file that is not JSONL answers 400. Another completion_window, an endpoint outside the three above, or an endpoint other than the one the lines call answers 400.

Check a batch

Poll this route every few minutes until status is completed, failed, expired or cancelled. Request counts refresh about every five minutes, so polling faster returns the same numbers.

List batches

GET /v3/batches returns your batches, newest first. The response holds data (the batch objects), first_id, last_id and has_more.

Cancel a batch

POST /v3/batches/{batch_id}/cancel asks the provider to stop the batch. The response is the batch object, and its status reads cancelling until the provider has stopped it, then cancelled. Requests that completed before the cancel are billed, and their results stay available. A batch that has already finished answers 400.

Results

GET /v3/batches/{batch_id}/results streams the results as JSONL (application/jsonl), one line per request. On OpenAI, results stay available for 30 days after the batch finished. On Anthropic, they stay available for 29 days after the batch was created. Mistral states that batch results do not expire. Once the provider no longer has them, the route answers 410. A request that succeeded carries response, with the status_code and the chat completion body, on every provider. The model in the body is the Eden AI id you sent, such as openai/<model>. A request that failed carries error instead.
Match results to requests with custom_id. Do not rely on the order of the lines.
The results route answers 400 while the batch is still running, and 409 when the batch is finished on Eden AI’s side but the provider has not yet ended it. Retry after a short wait.

Statuses

cost and finished_at are filled in once the batch has finished and Eden AI has settled it. That can be a few minutes after the status reaches a final value.

The 24-hour window

If the batch has not finished 25 hours after it was created, Eden AI cancels it, bills the requests that completed and makes their results available. Cancel a batch yourself at any time before that.

Billing

Batches are billed at the model’s batch rates for input tokens, output tokens and, when the model has one, cached input tokens. These rates are lower than the standard rates of the same model. The rates are in the pricing object of each model in GET /v3/models as input_cost_per_token_batches, output_cost_per_token_batches and cache_read_input_token_cost_batches, in US dollars per token. A model whose entry has no input and output batch rate cannot be batched.

In your usage

The batch shows in usage monitoring as cost. The launch records the reservation and the settlement adds the difference between the final cost and the reservation, so the total is what the batch was charged. The settlement is not counted as a request or as tokens.
  • At create. Eden AI reserves the largest amount the batch could cost and deducts it from your balance. For each line, the reservation covers the prompt tokens plus the line’s max_tokens (or max_completion_tokens, or the model’s maximum output when neither is set), multiplied by n. If your balance or a member budget cannot cover it, the request answers 402 and nothing is sent.
  • At the end. The batch is settled once, from the results. Each request that succeeded bills the tokens the provider reports it used. A request that failed, was cancelled or expired bills nothing. A request that succeeded but reports no usage, or that the provider counts as completed but that has no line in the results, bills an estimate: its prompt tokens, plus the output its response shows and 8,192 tokens per completion, never more output than was reserved for it. The difference between the reservation and the final cost is returned to your balance.
  • When nothing completed. The batch bills nothing and the whole reservation is returned.
  • When results cannot be read. Each request that may have run bills the same estimate, with no output shown. For a batch that has ended, that is as many requests as the provider counts as completed, the largest estimates first. Otherwise it is every request. A batch with a request that may have run is never settled at zero.
Set max_completion_tokens on every line to keep the reservation close to the real cost.

Content moderation

Eden AI checks the text of every line before the batch is sent, response_format included. Sampling does not apply, and the bypass_moderation setting does not skip the check.

Zero data retention

A batch is judged as a call that keeps its data at the provider, so batches cannot honor zero data retention on any provider. A batch is refused when your organization requires zero data retention (403) or when a line sets routing.zero_data_retention (400). A region restriction (allowed_regions) that excludes the region the batch runs in is refused with 451.

Your own provider key

Batches run on Eden AI’s account at the provider only. If your organization has added its own key for the batch’s provider, create requests are refused with 400.

Webhooks

Pass webhook_receiver at create to be notified instead of polling. Eden AI sends a signed POST to the URL once the batch has finished and settled. The signature, headers and verification steps are the ones described in Webhooks. The notification reports success for a completed batch and fail for any other final status. It does not carry the results: read them from the results route. The payload has the shape of every Eden AI job notification. job_id is the batch id, and feature and subfeature are llm and batch:
To fetch the results when the notification arrives, read job_id and call the results route:
Python
The URL must be public. Addresses that resolve to private networks are refused.

Limits and what batches do not do

  • A batch holds at most 5,000 lines and 100 MB.
  • A batch runs one model, on OpenAI, Anthropic or Mistral. Other providers are not supported.
  • Chat completions are supported on all three providers. Other endpoints are not.
  • Lines cannot stream.
  • Lines cannot carry tools, function definitions, function calls or predicted outputs.
  • Lines cannot carry images, audio or files. Messages are text only.
  • Batches run on Eden AI’s provider accounts. Your own provider keys are not used.
  • Fallbacks, hooks, sessions and tags are not available on a line.

Errors

When the provider fails a create, cancel or results call, the error status it returned is passed on with its message.