Skip to content
API referenceCreate a message

Create a message

POST/v1/messages

Create a message.

Drop-in compatible with Anthropic's Messages API: the body is a Messages request and the answer a Messages response, in Anthropic's format. With an Anthropic or Claude on Vertex key the request goes to Claude as sent (apart from what the gateway sets: the model the key allows, guardrail redactions); with a key for another provider it is translated, and a field that provider cannot take is a 400 naming it. Server tools, mcp_servers and container are not supported (400).

Credentials, in this order: x-virtual-key; Authorization: Bearer vk-...; x-config (a routing config, with x-organization); x-api-key, which is what the Claude SDKs send from ANTHROPIC_API_KEY; any other Authorization: Bearer token. A value starting vk- is a virtual key's API key; anything else is the provider's own key (Anthropic, unless x-provider names another provider). No credential is a 401.

What the gateway adds is the same as on chat completions: the response cache (x-cache-mode), retries and fallbacks (x-retry-*, x-fallback-*), and guardrails (the virtual key's plus x-guardrail) on the input and the answer. The response carries x-cache-status, x-retry-count, x-fallback-provider (when a fallback answered), x-virtual-key-slug and x-guardrail-status (when guardrails apply). anthropic-beta is forwarded to Anthropic and Claude on Vertex.

Streaming. With stream: true the response is text/event-stream with Anthropic's events (message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop). A failure after the stream has started ends it with an error event.

Errors are in Anthropic's shape, {"type":"error","error":{"type":...,"message":...}}, so the SDK raises the matching exception: 400 for an invalid request, 401 for a missing or invalid credential, 403 when the virtual key is disabled, expired or out of credit or the model is not allowed, 422 when a guardrail blocks (with x-guardrail-status: BLOCK), 429 for a rate limit.

Compatible with the Anthropic Messages API. The request and response bodies are the provider's own format, passed through by the gateway: see the Anthropic Messages API reference for every field. The credentials and headers below are what VectorAxis adds.

Authorization

  • AuthorizationBearer <slug>.<secret>

    A virtual key's API key (vk-....<secret>), as Authorization: Bearer. What the OpenAI SDK sends from its api_key. Used by the inference endpoints.

  • orx-virtual-keyheader

    A virtual key's API key in the x-virtual-key header, for clients that keep Authorization for something else.

  • orx-api-keyheader

    Direct credentials: the provider's own API key in x-api-key, with the provider named in x-provider (for example openai). On /v1/messages a virtual key is accepted in x-api-key too, which is what the Claude SDK sends.

Headers

  • x-providerstring

    With direct credentials: the provider x-api-key belongs to, for example openai or anthropic (case and dashes are normalised). Not used with a virtual key.

  • x-cache-modestring

    Turns on the response cache for this request: simple (exact match) or semantic (a similar earlier request). Without it nothing is read from or written to the cache. The outcome is in the x-cache-status response header.

  • x-cache-ttlinteger<int32>

    How long, in seconds, a response stored by this request stays in the cache. When the organization has a cache TTL set, this can shorten it but not extend it.

  • x-cache-force-refreshboolean

    true skips the cache lookup, calls the provider and replaces the stored response (x-cache-status: REFRESH).

  • x-retry-countinteger<int32>

    How many times to retry a failed provider call, 0 to 5. Without the header, chat completions, Claude Messages and prompt completions do not retry, and the other endpoints retry up to 3 times. Retries back off exponentially from 1 second and honour a numeric Retry-After. The number made is in the x-retry-count response header.

  • x-retry-status-codesstring

    Comma-separated provider status codes to retry on. Default 429,500,502,503,504,529.

  • x-fallback-1-providerstring

    The provider to try when the request fails after its retries. Up to five fallbacks, tried in order: x-fallback-1-* to x-fallback-5-*. The provider that answered is in the x-fallback-provider response header.

  • x-fallback-1-api-keystring

    The API key for fallback 1's provider.

  • x-fallback-1-modelstring

    The model fallback 1 uses. Optional: the request's own model otherwise.

  • x-guardrailstring

    A guardrail slug (gr-...) to apply to this request, in addition to any the virtual key carries. A BLOCK is a 422 with x-guardrail-status: BLOCK.

  • x-configstring

    A routing config slug: the config chooses the provider, model and key (load balancing, fallback or conditional routing). Without a virtual key, send x-organization with it to name the config's organization.

  • x-organizationstring

    The organization slug. Required with x-config; with a virtual key the key's organization is used.

  • x-workspace-idstring

    Workspace id (UUID) to attribute the request to in logs and analytics.

  • x-metadatastring

    A JSON object of your own string key/value pairs, stored with the request's log entry for filtering.

  • x-prompt-slugstring

    Attributes the request to a prompt from the prompt library, for its analytics.

  • x-prompt-versioninteger<int32>

    The prompt version the request used, with x-prompt-slug.

  • x-vertex-projectstring

    Google Vertex AI keys only: the GCP project to call, instead of the one stored with the key.

  • x-vertex-regionstring

    Google Vertex AI keys only: the region to call (or global), instead of the one stored with the key.

  • anthropic-betastring

    Anthropic beta features, comma-separated (for example context-management-2025-06-27). Forwarded to Anthropic and Claude on Vertex only; at most 32 names of lower-case letters, digits and dashes.

Responses

200application/json

The message. With stream: true, a stream of Anthropic Messages events.

NVIDIA Inception Program member

VectorAxis is built by GK Labs, a member of NVIDIA Inception.