Skip to content

LLM Gateway API Reference

Argy LLM Gateway reference: chat, messages, responses, models, images, OCR, streaming, tool use and errors.

The LLM Gateway exposes OpenAI-compatible and Anthropic-compatible APIs behind a single Argy authentication: an OpenAI SDK, a Claude client or a plain curl all reach the same governed models, with the same quotas, filters and audit trail. This page is the complete reference for both families: endpoints, authentication, parameters, streaming, tool use and error formats.

Shared conventions (error envelopes, codes, limits) are described in the API overview; this page only covers what is specific to the Gateway.

Base URL

https://llm.argy.cloud/v1

The base URL for OpenAI-compatible clients is https://llm.argy.cloud/v1 and includes the /v1 prefix. The paths on this page are given from the host root: /v1/chat/completions therefore designates the full URL https://llm.argy.cloud/v1/chat/completions. Bodies are JSON; responses are JSON or, when streaming is requested, text/event-stream. Request body size is capped by a default limit, configurable per deployment; ask your administrator.

For Claude clients, the base URL to configure is https://llm.argy.cloud without /v1: the client appends /v1/messages itself.

Two API families, one Gateway

FamilyEndpointsTypical clientsError format
OpenAI-compatible/v1/chat/completions, /v1/completions, /v1/responsesOpenAI SDKs and OpenAI-style toolsOpenAI-style envelope with trace_id
Anthropic-compatible/v1/messagesClaude clients, Anthropic SDKsAnthropic envelope ("type": "error")

Both families run through the same pipeline: your tenant's model policy, credit quotas, input and output filters, audit. They share the same PAT and the same /v1/models catalogue. Models, usage, images and OCR are shared endpoints that follow the OpenAI-style conventions.

Authentication

Authorization: Bearer $ARGY_PAT
  • Accepted tokens: signed Argy PAT (prefix pat_), legacy opaque PAT (compatibility) and platform-signed Argy JWT. To create and manage a PAT, follow IAM authentication; to configure it in Argy Code, see Argy Code configuration.
  • OpenAI-compatible family: Authorization: Bearer only. An OpenAI SDK sends it natively when you pass your PAT as api_key.
  • Anthropic-compatible family: Authorization: Bearer as well, plus the required anthropic-version header (for example 2023-06-01). Unpriced anthropic-beta values are rejected (see Messages).
  • x-api-key is never an identity, on either family: a client sending only that header receives 401. Configure your Claude client to send the PAT as a Bearer token.
  • X-Argy-Agent-Id is optional and purely informational (audit label); it grants no permission.

Authentication errors follow the envelope of the called family: the OpenAI-style envelope described in the overview everywhere, except on /v1/messages where they are rendered in the Anthropic error format.

Endpoints

FamilyMethodPathPurposeStreaming
OpenAI-compatiblePOST/v1/chat/completionsChat, tools, RAG, cacheYes, real time
OpenAI-compatiblePOST/v1/completionsText completionYes, replayed
OpenAI-compatiblePOST/v1/responsesResponses APIYes, replayed
Anthropic-compatiblePOST/v1/messagesMessages API, native Anthropic formatYes, real time
SharedGET/v1/modelsTenant model catalogueNo
SharedGET/v1/usageCurrent-month usage and creditsNo
SharedPOST/v1/images/generationsImage generationNo
SharedPOST/v1/ocrImage or PDF OCR (base64)No

POST /v1/agent/steps is a legacy endpoint, not recommended: use /v1/chat/completions.

The Gateway does not offer audio, transcription, realtime, public embeddings, /v1/messages/count_tokens, files, batch or assistants.

Error formats by family

OpenAI-compatible family and shared endpoints:

{
  "error": {
    "message": "messages is required",
    "type": "invalid_request_error",
    "param": null,
    "code": "INVALID_REQUEST"
  },
  "trace_id": "…",
  "request_id": "…"
}

Anthropic-compatible family (/v1/messages):

{
  "type": "error",
  "error": {
    "type": "authentication_error",
    "message": "…"
  },
  "request_id": "…"
}

On /v1/messages, the Anthropic error.type is derived from the HTTP status: 401 gives authentication_error, 403 permission_error, 404 not_found_error, 413 request_too_large, 429 rate_limit_error, 529 overloaded_error, other 5xx api_error, other 4xx invalid_request_error. Errors returned by the model provider are relayed in their native format. The codes of the OpenAI-style envelope are listed in the API overview.

Chat completions

POST /v1/chat/completions

Recommended endpoint for any OpenAI-compatible client. Minimal example:

curl -s https://llm.argy.cloud/v1/chat/completions \
  -H "Authorization: Bearer $ARGY_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Explain automatic routing in one sentence."}
    ],
    "max_tokens": 256
  }'

messages must include at least one user-role message. The response is a chat.completion object with choices[0].message.content, the effective model in model, the usage object and the Argy extensions (trace_id, model_effective, rag, billing, filters).

Parameters

ParameterTypeDefaultDescription
messagesarrayrequiredConversation messages; roles system, user, assistant, tool
messages[].contentstring or arrayrequiredText, or an array of text/image parts
modelstringautoModel identifier or auto (Gateway-side selection)
model_hintstring-Argy extension; takes precedence over model when non-empty
max_output_tokensintegercappedAccepted aliases: max_completion_tokens, max_tokens
temperaturenumber-Contract: 0 to 2
streambooleanfalsetrue enables SSE streaming
toolsarray-function-type tools only (see Tool use)
tool_choicestring or object-auto, none, required, a function name or a function object
tool_resultsarray-Argy tool results: {tool_call_id, result, error}
reasoning_effortstring-none, minimal, low, medium, high, xhigh, max; alias reasoningEffort
reasoningobject-reasoning.summary: auto, concise or detailed
ragobject-enabled, top_k (1–20), collections, require_acl, filters; collections are managed through the RAG API
cacheobject-enabled, ttl_seconds (0–86400)
response_formatobject-passed through to the model
task_typestringchatchat, code, agent, rag, ocr; otherwise taken from X-Argy-Task-Type
session_idstring-Taken from the x-argy-session header when absent
metadataobject-Free-form metadata

Fields that are not listed here (for example top_p, stop, n, seed or stream_options) are accepted and ignored. An absent, empty or auto model delegates selection to the Gateway; the model actually used is returned in model and model_effective. An unknown or unauthorised identifier does not trigger an error on this route: automatic selection takes over.

Streaming

With stream: true, the response is an SSE stream (text/event-stream) fed in real time by the provider: data: {json} lines of type chat.completion.chunk, a final event carrying finish_reason, model, usage and the Argy extensions, then data: [DONE].

curl -N https://llm.argy.cloud/v1/chat/completions \
  -H "Authorization: Bearer $ARGY_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "stream": true,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

What to know about streaming:

  • The usage block is emitted by default in the last SSE event, including for OpenAI SDKs; the stream_options.include_usage parameter is not read by the Gateway.
  • An error occurring after the stream opens (HTTP status already sent) is emitted as an SSE frame {"error": {...}} and the stream then closes; a quota rejection before the stream opens is a regular JSON HTTP response (402 or 503).
  • The stream is never resumable: on interruption, send the request again.

Tool use

The Gateway supports OpenAI function calling on /v1/chat/completions, /v1/completions and /v1/responses, and native Anthropic tool use on /v1/messages (tool_use and tool_result blocks, see Messages). On the OpenAI-compatible routes only function-type tools are accepted; no built-in tools (web search, code interpreter) and no Anthropic server tools.

curl -s https://llm.argy.cloud/v1/chat/completions \
  -H "Authorization: Bearer $ARGY_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "What time is it in Paris?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_time",
        "description": "Returns the local time of a city",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

Tool validation rules:

  • The function name is required, non-empty, 256 characters maximum, with no control characters.
  • tool_choice accepts auto, none, required (case-insensitive), a forced function name, or {"type":"function","function":{"name":...}}.
  • When the model calls a tool, the response contains choices[0].message.tool_calls[] (id, function.name, function.arguments as a JSON string) and finish_reason: "tool_calls".
  • Check capabilities.tools: true in /v1/models for the chosen model.

Models

GET /v1/models

Returns the catalogue of models allowed by your tenant policy: {object: "list", data: [...], trace_id}, with cache-control: no-store. Each entry describes id, display_name, owned_by, capabilities (tool_call, chat, code, reasoning, vision, ocr, streaming, search, ...), context_window, max_output_tokens, avg_latency_ms and credit cost indicators.

curl -s https://llm.argy.cloud/v1/models \
  -H "Authorization: Bearer $ARGY_PAT"

With the X-Argy-Models-Contract: virtual-auto-v1 header, a virtual auto entry is added at the top of the list. It deliberately carries no capabilities and no pricing: the model actually used (and billed) is only known per request.

The auto model

model: "auto" (or absent) delegates model selection to the Gateway. The effective model is returned in the response's model and model_effective. A tenant can force automatic routing or disable auto; no selection criteria are published.

Usage and credits

GET /v1/usage

Returns your tenant's usage for the current calendar month: credits_total, credits_used, credits_remaining, tokens_used, period{type: "monthly", start, end}, trace_id. Credit packs and their administrative tracking are managed in the portal: see Portal billing.

curl -s https://llm.argy.cloud/v1/usage -H "Authorization: Bearer $ARGY_PAT"

Text completions

POST /v1/completions

OpenAI-compatible text completion. The prompt (string) is converted into a user message; only the string form is supported. Response: object: "text_completion" with choices[] (text, index, finish_reason) and usage.

ParameterTypeDefaultDescription
promptstringrequiredPrompt converted into a user message
modelstring-Requested model identifier
temperaturenumber-Used if numeric
max_tokensinteger-Used if numeric
streambooleanfalsetrue enables streaming
reasoning_effortstring-Used if present
tools, tool_choice--Same rules as chat

Streaming on this route replays the full response over SSE after it has been produced: it is not a real-time provider stream, so do not expect a fast first token.

Messages (Anthropic)

POST /v1/messages

Native Anthropic Messages API: JSON and native SSE streaming in the Anthropic format. A standard Claude client can point directly at the Gateway.

# Identifier of an Anthropic (Claude) model listed by /v1/models
export ANTHROPIC_MODEL="<Claude model id>"

curl -s https://llm.argy.cloud/v1/messages \
  -H "Authorization: Bearer $ARGY_PAT" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$ANTHROPIC_MODEL"'",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Required body: model (non-empty, Anthropic models only), max_tokens (strictly positive integer), messages (at least one element with role and content). Optional body: system, stream, tools, metadata.user_id.

Prompt caching

On this endpoint, the cache definitions sent by the client (cache_control) are preserved and forwarded to the model. Only the 5m TTL is accepted: any other ttl value (including 1h) is rejected with 400 capability_rejected. The OpenAI-compatible family does not forward client cache definitions to the model: it offers its own cache parameter.

Supported and ignored parameters on this route:

ParameterHandling
modelRequired; Anthropic models only, auto not supported; it must be allowed by your tenant policy (otherwise 403 MODEL_NOT_ALLOWED)
max_tokensRequired
messages, systemText or content blocks, forwarded as sent
streamtrue enables native Anthropic streaming
tools, tool useStandard tools (tool_use and tool_result blocks) are supported
thinkingExtended thinking is supported; thinking blocks and their signatures are returned unchanged
cache_controlPreserved and forwarded to the model; only the 5m TTL is accepted (see Prompt caching)
metadata.user_idAccepted; it must be a string
speed, mcp_servers, container, web search, web fetch and code execution toolsRejected with 400 capability_rejected (not priced)
Other fieldsPreserved and forwarded to the model

Specifics of this route:

  • The anthropic-version header is required; the context-1m-2025-08-07 and fast-mode-2026-02-01 betas are rejected with 400. The ?beta=true query string used by some Claude clients is accepted.
  • model: "auto" is not supported here: only Anthropic models are accepted; pick a Claude identifier from /v1/models. A non-Anthropic or unknown model is refused with 400 capability_rejected.
  • Errors follow the Anthropic format ({"type": "error", "error": {"type", "message"}, "request_id"}), see Error formats by family.

Messages streaming

With stream: true, the Gateway relays the native Anthropic events in order (message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop), as soon as the provider emits them, with ping events during quiet periods.

curl -N https://llm.argy.cloud/v1/messages \
  -H "Authorization: Bearer $ARGY_PAT" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "'"$ANTHROPIC_MODEL"'",
    "max_tokens": 512,
    "stream": true,
    "messages": [{"role": "user", "content": "Hello"}]
  }'
  • An error after the first event is emitted as a native Anthropic error event, then the stream closes; a quota or input-filter refusal before the provider call is a regular HTTP response in the Anthropic error format.
  • Your tenant's output filters apply to the stream: a blocked output never reaches the client.
  • The stream is never resumable: on interruption, send the request again.

Responses

POST /v1/responses

OpenAI Responses API.

curl -s https://llm.argy.cloud/v1/responses \
  -H "Authorization: Bearer $ARGY_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "instructions": "Answer in English.",
    "input": "Summarize the zero-trust principle in two sentences.",
    "max_output_tokens": 300
  }'
ParameterTypeDefaultDescription
inputstring or arrayrequiredString, or message items, function_call, function_call_output
instructionsstring-Becomes a system message
modelstringautoIdentifier or auto
max_output_tokensintegercappedmax_tokens alias accepted
streambooleanfalsetrue enables streaming
tools, tool_choice--Same rules as chat
reasoningobject-reasoning.effort and reasoning.summary (validated)
reasoning_effortstring-Used when reasoning.effort is absent

Response: a response object with output[] (message, function_call, reasoning items), status (completed, incomplete, failed), finish_reason, usage and the Argy extensions. Like /v1/completions, streaming replays the full response over SSE: it is not a real-time stream.

Images

POST /v1/images/generations

Image generation from a prompt. Available image models depend on your tenant (see /v1/models); billing is token-based.

ParameterTypeDefaultDescription
promptstringrequiredDescription of the image to generate
modelstringautoImage model or auto
sizestring-passed through as-is
ninteger1Number of images
qualitystring-passed through as-is

The response contains model_effective and data[] with url or b64_json depending on the case.

OCR

POST /v1/ocr

Text recognition on an image or PDF supplied as base64.

ParameterTypeDefaultDescription
image_inputstringrequiredBase64-encoded image or PDF; imageInput alias accepted
modelstring-Otherwise the Gateway's default OCR model
curl -s https://llm.argy.cloud/v1/ocr \
  -H "Authorization: Bearer $ARGY_PAT" \
  -H "Content-Type: application/json" \
  -d '{"image_input": "<base64>", "model": "..."}'

The response contains at minimum trace_id, model, provider and data. A quota check reserves a token estimate before execution.

OpenAI and Anthropic clients

The Gateway exposes the OpenAI chat/completions and responses contracts and the Anthropic messages contract: a standard OpenAI SDK or a Claude client works without protocol adaptation by pointing its base URL at the Gateway. This is also the API that powers Argy Code and Argy Chat for inference.

OpenAI SDK (base URL with /v1):

from openai import OpenAI
import os

client = OpenAI(base_url="https://llm.argy.cloud/v1", api_key=os.environ["ARGY_PAT"])
r = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)

For Claude clients, configure the base URL as https://llm.argy.cloud without /v1 (the client appends /v1/messages); otherwise the /v1/v1/messages path returns 404. Authentication remains the Argy Bearer: never send x-api-key alone.

Rate limits

By default, inference routes (/v1/chat/completions, /v1/completions, /v1/messages, /v1/responses and aliases, and /v1/images/generations) are subject to a requests-per-minute limit, applied per (tenant, user) pair. Its default value is configurable per deployment and is not a contractual commitment; ask your administrator for it.

  • On breach: 429 RATE_LIMITED with the Retry-After header (seconds before retrying).
  • /v1/models, /v1/usage and /v1/ocr carry no rate limit of their own.
  • The legacy /v1/agent/steps endpoint has its own, tighter limit; prefer /v1/chat/completions.
  • Monthly credit quotas (tenant, plus optional organization and user caps) are distinct from the rate limit: an exhausted quota returns 402, not 429.

Common errors

ProblemLikely causeFix
401 UNAUTHENTICATED with x-api-key onlyThe Gateway only accepts BearerUse Authorization: Bearer $ARGY_PAT
404 on /v1/v1/messagesClaude base URL configured with /v1Configure https://llm.argy.cloud without /v1
400 INVALID_REQUEST on toolsUnsupported tool typeOnly function tools are accepted
400 capability_rejected on /v1/messagesUnpriced option (1 h cache TTL, 1M-context beta, server tools)Remove the option
402 CREDITS_EXHAUSTEDTenant AI credits exhaustedTop up your credit pack
429 RATE_LIMITEDRate limit reachedHonour Retry-After before retrying
503 QUOTA_VERIFICATION_UNAVAILABLEQuota verification unavailableDistinct from an exhausted quota; retry the request
SSE frame {"error": ...} instead of an HTTP statusError occurred after the stream openedSend the request again; the stream is not resumable

See also