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.cloudwithout/v1: the client appends/v1/messagesitself.
Two API families, one Gateway
| Family | Endpoints | Typical clients | Error format |
|---|---|---|---|
| OpenAI-compatible | /v1/chat/completions, /v1/completions, /v1/responses | OpenAI SDKs and OpenAI-style tools | OpenAI-style envelope with trace_id |
| Anthropic-compatible | /v1/messages | Claude clients, Anthropic SDKs | Anthropic 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: Beareronly. An OpenAI SDK sends it natively when you pass your PAT asapi_key. - Anthropic-compatible family:
Authorization: Beareras well, plus the requiredanthropic-versionheader (for example2023-06-01). Unpricedanthropic-betavalues are rejected (see Messages). x-api-keyis never an identity, on either family: a client sending only that header receives401. Configure your Claude client to send the PAT as a Bearer token.X-Argy-Agent-Idis 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
| Family | Method | Path | Purpose | Streaming |
|---|---|---|---|---|
| OpenAI-compatible | POST | /v1/chat/completions | Chat, tools, RAG, cache | Yes, real time |
| OpenAI-compatible | POST | /v1/completions | Text completion | Yes, replayed |
| OpenAI-compatible | POST | /v1/responses | Responses API | Yes, replayed |
| Anthropic-compatible | POST | /v1/messages | Messages API, native Anthropic format | Yes, real time |
| Shared | GET | /v1/models | Tenant model catalogue | No |
| Shared | GET | /v1/usage | Current-month usage and credits | No |
| Shared | POST | /v1/images/generations | Image generation | No |
| Shared | POST | /v1/ocr | Image 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
| Parameter | Type | Default | Description |
|---|---|---|---|
messages | array | required | Conversation messages; roles system, user, assistant, tool |
messages[].content | string or array | required | Text, or an array of text/image parts |
model | string | auto | Model identifier or auto (Gateway-side selection) |
model_hint | string | - | Argy extension; takes precedence over model when non-empty |
max_output_tokens | integer | capped | Accepted aliases: max_completion_tokens, max_tokens |
temperature | number | - | Contract: 0 to 2 |
stream | boolean | false | true enables SSE streaming |
tools | array | - | function-type tools only (see Tool use) |
tool_choice | string or object | - | auto, none, required, a function name or a function object |
tool_results | array | - | Argy tool results: {tool_call_id, result, error} |
reasoning_effort | string | - | none, minimal, low, medium, high, xhigh, max; alias reasoningEffort |
reasoning | object | - | reasoning.summary: auto, concise or detailed |
rag | object | - | enabled, top_k (1–20), collections, require_acl, filters; collections are managed through the RAG API |
cache | object | - | enabled, ttl_seconds (0–86400) |
response_format | object | - | passed through to the model |
task_type | string | chat | chat, code, agent, rag, ocr; otherwise taken from X-Argy-Task-Type |
session_id | string | - | Taken from the x-argy-session header when absent |
metadata | object | - | 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
usageblock is emitted by default in the last SSE event, including for OpenAI SDKs; thestream_options.include_usageparameter 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 (402or503). - 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_choiceacceptsauto,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.argumentsas a JSON string) andfinish_reason: "tool_calls". - Check
capabilities.tools: truein/v1/modelsfor 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt | string | required | Prompt converted into a user message |
model | string | - | Requested model identifier |
temperature | number | - | Used if numeric |
max_tokens | integer | - | Used if numeric |
stream | boolean | false | true enables streaming |
reasoning_effort | string | - | 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:
| Parameter | Handling |
|---|---|
model | Required; Anthropic models only, auto not supported; it must be allowed by your tenant policy (otherwise 403 MODEL_NOT_ALLOWED) |
max_tokens | Required |
messages, system | Text or content blocks, forwarded as sent |
stream | true enables native Anthropic streaming |
tools, tool use | Standard tools (tool_use and tool_result blocks) are supported |
thinking | Extended thinking is supported; thinking blocks and their signatures are returned unchanged |
cache_control | Preserved and forwarded to the model; only the 5m TTL is accepted (see Prompt caching) |
metadata.user_id | Accepted; it must be a string |
speed, mcp_servers, container, web search, web fetch and code execution tools | Rejected with 400 capability_rejected (not priced) |
| Other fields | Preserved and forwarded to the model |
Specifics of this route:
- The
anthropic-versionheader is required; thecontext-1m-2025-08-07andfast-mode-2026-02-01betas are rejected with400. The?beta=truequery 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 with400capability_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
errorevent, 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
}'
| Parameter | Type | Default | Description |
|---|---|---|---|
input | string or array | required | String, or message items, function_call, function_call_output |
instructions | string | - | Becomes a system message |
model | string | auto | Identifier or auto |
max_output_tokens | integer | capped | max_tokens alias accepted |
stream | boolean | false | true enables streaming |
tools, tool_choice | - | - | Same rules as chat |
reasoning | object | - | reasoning.effort and reasoning.summary (validated) |
reasoning_effort | string | - | 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt | string | required | Description of the image to generate |
model | string | auto | Image model or auto |
size | string | - | passed through as-is |
n | integer | 1 | Number of images |
quality | string | - | 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
image_input | string | required | Base64-encoded image or PDF; imageInput alias accepted |
model | string | - | 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_LIMITEDwith theRetry-Afterheader (seconds before retrying). /v1/models,/v1/usageand/v1/ocrcarry no rate limit of their own.- The legacy
/v1/agent/stepsendpoint 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, not429.
Common errors
| Problem | Likely cause | Fix |
|---|---|---|
401 UNAUTHENTICATED with x-api-key only | The Gateway only accepts Bearer | Use Authorization: Bearer $ARGY_PAT |
404 on /v1/v1/messages | Claude base URL configured with /v1 | Configure https://llm.argy.cloud without /v1 |
400 INVALID_REQUEST on tools | Unsupported tool type | Only function tools are accepted |
400 capability_rejected on /v1/messages | Unpriced option (1 h cache TTL, 1M-context beta, server tools) | Remove the option |
402 CREDITS_EXHAUSTED | Tenant AI credits exhausted | Top up your credit pack |
429 RATE_LIMITED | Rate limit reached | Honour Retry-After before retrying |
503 QUOTA_VERIFICATION_UNAVAILABLE | Quota verification unavailable | Distinct from an exhausted quota; retry the request |
SSE frame {"error": ...} instead of an HTTP status | Error occurred after the stream opened | Send the request again; the stream is not resumable |
See also
- API overview: shared conventions, errors, limits
- RAG API: collections and augmented retrieval
- IAM authentication: create and manage your PATs
- Security model