Create a message

Compatible with Anthropic Messages, for inference on conversational models. The official SDK works as-is.

post/v1/messages

Request

  • Base URL: https://gateway.amux.ai
  • URL: https://gateway.amux.ai/v1/messages
  • Auth: API key in header x-api-key

Headers

Content-Typestring required

Always application/json.

Request body

modelstring required

Canonical ID shaped like vendor/model. The colon suffix pins a provider (:provider) or chooses a routing strategy (:@price and friends); the two cannot be combined. See the overview.

max_tokensinteger required

Maximum output tokens. This endpoint requires a positive integer and rejects missing or invalid values at ingress. When converting in from another protocol without one, we fill in the model's ceiling.

systemstring

Top-level system prompt. Either a string or an array of text blocks carrying cache_control.

temperaturenumber

Sampling temperature, 0–1 (not 0–2). Values above 1 coming from Chat or Gemini are clamped. ⚠️ Anthropic has deprecated all three sampling parameters: on models released after Claude Opus 4.6, temperature accepts only 1, top_p only ≥0.99, and top_k is rejected outright. We do not gate them on the upstream's behalf (that would mean deciding for you which model counts as "new"), so the upstream is what rejects them. The reliable move on this link is not to send them.

top_pnumber

Nucleus sampling. Removed when thinking is on — Anthropic's reasoning mode rejects it. See temperature for the deprecation on newer models.

top_kinteger

Top-k sampling. The OpenAI protocols have no such parameter, so it is dropped when converting out. Also removed when thinking is on. ⚠️ Watch the Gemini → Anthropic link: Gemini's topK converts into this top_k, and models after Opus 4.6 reject top_k, failing the whole request with a 400. Not sending topK avoids it.

stop_sequencesstring[]

Stop sequences. Chat allows at most 4 and Gemini 5; anything beyond is truncated with a note.

streamboolean

Return an SSE stream. Anthropic's event sequence must be strictly paired; we close any unclosed blocks when finishing.

toolsobject[]

Callable tools, shaped { name, description, input_schema }. Note the schema field is input_schema, not parameters.

tool_choiceobject

{ type: "auto" | "any" | "none" | "tool" }. any corresponds to OpenAI's required. The parallel switch lives here too, as disable_parallel_tool_use.

containerobject

Container reuse — either a string ID or { id, skills: [{ skill_id, type, version }] } (at most 20 skills). Anthropic-only, passed through unchanged — it is upstream-side state, so it is only dependable once you pin a provider.

inference_geo'global' | 'us'

Where inference runs. Not supported — we forward it to no upstream, on either path. ⚠️ Do not rely on this parameter for a regulatory locality requirement: once stripped, inference goes through global routing rather than US-only infrastructure. To bind a region, pin a provider (the :provider suffix) on a channel that is itself region-bound. What was stripped is reported back: amux.droppedParams in the body, or the x-amux-dropped-params header when streaming.

service_tier'auto' | 'standard_only'

Service tier. Not supported — we forward it to no upstream, on either path. Little is lost: auto is Anthropic's default anyway. What was stripped is reported back: amux.droppedParams in the body, or the x-amux-dropped-params header when streaming.

Example request

{
  "model": "anthropic/claude-opus-5",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}

Response

Inference succeeded. model is the canonical ID — the same value you sent.

idstring

The ID of this message.

typestring

Object type; always message.

rolestring

Who is speaking; always assistant on a reply.

modelstring

The Amux model ID — the same value you sent.

stop_reasonstring

Why generation stopped, e.g. end_turn, max_tokens, tool_use.

Example response

{
  "id": "msg_01ABC",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-opus-5",
  "content": [
    {
      "type": "text",
      "text": "Hello!"
    }
  ],
  "stop_reason": "end_turn"
}

Changes

No recorded changes to this operation across all 1 revision of this API.