Skip to content

Create a Message

POST/v1/messages
API Access

Use the same AudioLab API URL as your other model requests. Confirm the model is enabled and your key has llm.write access. See the Text setup guide.

Overview

Limited Anthropic Messages translation.

Routing and provider details

Text, image and document (PDF) blocks, client function tools and the web_search server tool are translated. Signed thinking replay, document citations and other server-managed tools require native protocol support and are not accepted. cache_control breakpoints reach Anthropic models. Routing (costream/auto, models, costream/fusion, router/<id>), dropped parameters and the routing explanation work as on Chat Completions; a stream carries routing on its message_delta event, and metadata.user_id keeps a session's route. Full Claude Code compatibility is not certified.

Authorization

Authorizationstring · headerRequired

AudioLab API key sent as Bearer <token>. Authentication guide

Parameters

x-audiolab-cacheheader · string

true stores a successful answer and serves an identical later request from your workspace with no provider call and no charge (usage.cost 0, usage.cache_hit true). The x-audiolab-cache-status response header reads HIT, MISS or BYPASS; zero data retention always bypasses. X-OpenRouter-Cache is accepted too.

x-audiolab-cache-ttlheader · integer

Seconds an answer stays cached, 1 to 86400. Default 300.

x-audiolab-cache-clearheader · string

true replaces the cached answer with a fresh one.

Request Body

application/json
modelstringRequired

Model ID from List Models, costream/auto, costream/fusion, or a named router as router/<id>. A model that several hosts serve routes across them; a host’s own ID selects that host. Add :nitro, :floor or :exacto to rank its hosts by throughput, price or tool-call validity, :free to keep free hosts, or :thinking to keep hosts that reason; an unknown suffix is refused. A ~author/family-latest alias, such as ~z-ai/glm-latest, selects the newest model of that family.

messagesobject[]Required

Conversation messages with roles and content. User content may mix text, image and document (PDF) blocks for models whose input_modalities list them.

Show nested fields

object

max_tokensinteger

Maximum generated output tokens, up to the model’s output cap (top_provider.max_completion_tokens in List Models). Through a named router it is a ceiling on the router’s own limit.

streamboolean

Return protocol-specific server-sent events.

Default: false

toolsobject[]

Client-defined function tools, which the application executes, and web_search_20250305 to turn on the model’s own search.

Show nested fields

object

modelsstring[]

Fallback models, tried in order when the one before fails before any output. Each must support the request’s tools, response format and reasoning settings.

Show nested fields

string

providerobject

OpenRouter provider preferences. only, ignore and order take provider names or slugs, or an endpoint tag such as deepinfra/turbo. sort (price, throughput, latency or exacto, with partition model or none), allow_fallbacks, quantizations, max_price, preferred_min_throughput, preferred_max_latency, zdr and data_collection are honoured; zdr and data_collection can only narrow your workspace’s privacy settings. data_region (us, eu or a country code, or a list of them) routes only to endpoints documented as processing there, fallbacks included; it can narrow the workspace’s Data Region but never widen it, and a request no endpoint can serve is refused with 400 data_region_unavailable. require_parameters: true refuses a request whose sampling parameters the model does not support, or a named router does not let requests override, instead of dropping them. enforce_distillable_text and options are accepted but not honoured, and are named in the x-audiolab-ignored-provider-fields header.

pluginsobject[]

auto-router (allowed_models, cost_quality_tradeoff) with costream/auto; fusion (analysis_models, preset, model); web (the model’s own web search); file-parser (pdf.engine: native, pdf-text or mistral-ocr; max_files); response-healing (repairs a non-streamed JSON answer); context-compression (middle-out).

Show nested fields

object

transformsstring[]

middle-out removes messages from the middle of a conversation until it fits the smallest context among the requested model and its fallbacks.

Show nested fields

string

router_revisioninteger

Named routers only: the published revision to use. Without it, the router’s current revision applies.

Minimum 1 · Maximum 1000

metadataobject

Named routers match their conditions on these values as metadata.<key>. metadata.user_id also keeps a session’s route, like session_id.

service_tierstring

flex (cheaper, slower) or priority (faster) on OpenAI and Gemini models with a reviewed price for that tier, charged at that tier’s rate; the response’s service_tier names the tier that served it. Elsewhere the tier is dropped and named in x-audiolab-dropped-params, or refused under provider.require_parameters. auto and default use the standard tier.

Values: "auto""standard_only""default""flex""priority"

cache_controlobject

Anthropic prompt caching: {"type": "ephemeral"} here caches the prompt up to the last message; the same marker on a text part, system block or tool sets a breakpoint, at most 4. Writes and reads are charged at the model’s cache rates and reported in usage. A one-hour ttl is sent as five minutes. OpenAI and Gemini cache automatically, so the marker is accepted and named in x-audiolab-dropped-params.

session_idstring

Keeps a session on one route: costream/auto reuses the model it chose (without session_id it recognises a conversation by its first messages), and a named router assigns the same A/B variant (without it, each request is assigned afresh).

Responses

200Completed response or SSE stream when stream is true.
application/json

object

400Invalid or unsupported request contract. A named router’s refusal keeps its message and param.
401Invalid gateway credential.
402Insufficient credits.
404Unknown named router or revision.
409This idempotency key already identifies a request; provider inference is not repeated.
422A named router’s revision cannot run under current policy.
429Rate or concurrency limit.
502Every candidate failed with a provider error before any output, on a stream as well.
503Inference disabled or managed accounting not ready.