API reference

API reference · API

Ask several models at once and combine the answers

POST/v1/ensembleAPI key

Every member is priced at its worst case before anything is sent, and the sum is held to max_cost_micros, the key's per request ceiling, the monthly cap and what the account can spend. Each member then runs as its own keyed chat completion (no presets, aliases or fallback), with its own request id, hold and usage row under the ensemble's id as session, and spends one request of the key's per minute window. The combined answer is computed: a vote, a field by field JSON vote, or the cheapest answer that passes a check; only the judge rule asks a model, the one the caller names, billed as one more member. A failed member does not fail the ensemble; all of them failing is a 502 ensemble_failed. stream is refused: the combined answer exists only at the end. On a deployment with $ANTI holder tiers the ensemble is for holders: a key whose minting account does not hold the lowest tier is refused with 403 holder_only.

Request body

application/json, required

Request body fields
FieldTypeWhat it is
membersarray of string or objectThe models, as ids or autopilot ids, each optionally with its own max_tokens and temperature. Give these or preset. An autopilot id is routed before anything is priced, inside the key's allowlist and blocklist.
presetstringA member list by name: tiers is antimatter/auto:cheap, antimatter/auto, antimatter/auto:quality. Two tiers that land on one model run it once. One of "tiers".
combineobjectThe rule: majority (match, min_agreement), json-consensus (needs a JSON response_format), first-valid (the JSON check, pattern, or both) or judge (judge_model, which you name and pay for). majority when absent.
combine.rulerequiredstringOne of "majority", "json-consensus", "first-valid", "judge".
combine.matchstringOne of "normalized", "exact".
combine.min_agreementnumberFrom 0 to 1.
combine.patternstringAt most 1000 characters.
combine.judge_modelstringAt most 200 characters.
max_cost_microsintegerRefuse the ensemble, sending nothing, when the worst case of every member and the judge together is over this, in micro dollars. At most 9007199254740991.
member_timeout_msintegerHow long one member may run, 120000 ms when absent. A member past it is reported as timed out; one aborted after it reached the upstream is billed. From 1000 to 240000.
messagesrequiredarray of anyThe conversation every member answers. The rest of the body is a chat request every member shares; stream, model and models are refused.

Example

{
  "messages": []
}

Answer 200

Every member's answer, cost and latency, and the combined answer.

Headers: x-antimatter-request-id, x-request-id, x-antimatter-cost-micros, x-ratelimit-limit, x-ratelimit-remaining, x-ratelimit-reset

Fields of the 200 answer
FieldTypeWhat it is
idstringens_ and the request id's digits; every member's usage row carries it as its session.
object"ensemble"
createdinteger
rulestringOne of "majority", "json-consensus", "first-valid", "judge".
combinedobjectThe combined answer. ok false with a reason when no answer qualified (every answer failed the check, the plurality was under min_agreement, the judge named no candidate); the members are still there, and still billed.
combined.okboolean
combined.contentstring or null
combined.memberinteger or nullWhose answer it is; null for a field by field JSON merge.
combined.agreementnumberThe share of answering members behind it.
combined.chosen_bystringOne of "computed", "model_judgment".
combined.methodstringOne of "field-wise", "whole".
combined.votesarray of object
combined.checksarray of object
combined.fieldsarray of object
combined.tie_broken_by_priceboolean
combined.notestring
combined.reasonstring
membersarray of object
members[].indexinteger
members[].requestedstringThe id as given, autopilot ids included.
members[].modelstringThe model that answered and was billed.
members[].statusinteger
members[].okboolean
members[].contentstring or null
members[].tool_callsarray of object
members[].finish_reasonstring or null
members[].usageobject or null
members[].cost_microsintegerWhat this member was billed.
members[].worst_case_microsintegerWhat it was priced at before sending.
members[].latency_msinteger
members[].request_idstringIts own request id: GET /v1/requests/{id}.
members[].timed_outboolean
members[].errorobject
members[].error.typestring
members[].error.messagestring
judgeobject
judge.indexinteger
judge.requestedstringThe id as given, autopilot ids included.
judge.modelstringThe model that answered and was billed.
judge.statusinteger
judge.okboolean
judge.contentstring or null
judge.tool_callsarray of object
judge.finish_reasonstring or null
judge.usageobject or null
judge.cost_microsintegerWhat this member was billed.
judge.worst_case_microsintegerWhat it was priced at before sending.
judge.latency_msinteger
judge.request_idstringIts own request id: GET /v1/requests/{id}.
judge.timed_outboolean
judge.errorobject
judge.error.typestring
judge.error.messagestring
usageobjectEvery member's tokens summed, and cost in dollars.
cost_microsinteger
worst_case_microsinteger
max_cost_microsinteger

Errors

  • 400OpenAI shaped error.
  • 401OpenAI shaped error.
  • 402OpenAI shaped error.
  • 403OpenAI shaped error.
  • 404OpenAI shaped error.
  • 413OpenAI shaped error.
  • 429Rate limited, or a spent budget or spend cap. The type distinguishes rate_limit_error, policy_exceeded, and spend_cap_exceeded.
  • 502OpenAI shaped error.
  • 503OpenAI shaped error.

Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.

Antimatter