Console
API/API Reference/Requests and usage

Requests and usage

Three request shapes, one bill. Chat Completions for OpenAI clients, Anthropic Messages for Claude Code, Responses for Codex. Each returns the same four token counts in its own usage object.

Four classes, one rule
input_tokens (new, charged), memory_write_tokens (written to Native Context Memory, charged once), memory_read_tokens (served from memory, free) and output_tokens (charged). On every shape, prompt_tokens = input_tokens + memory_read_tokens exactly, and cached_tokens is memory_read_tokens. The price card has the prices; cost = Σ class × price.

POST /v1/chat/completions

The OpenAI shape, what OpenRouter and the OpenAI SDKs read. Set stream: true for server-sent events; the final chunk carries the full usage object, and the adaptiq block is sent even without stream_options.include_usage, because harness status lines depend on it.

bash
curl https://api.adaptiqai.com/v1/chat/completions \
  -H "Authorization: Bearer $ADAPTIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "adaptiq-deepseek-v4.1-flash",
    "messages": [
      {"role": "system", "content": "You are a precise assistant."},
      {"role": "user", "content": "Summarise the decision."}
    ]
  }'
json
"usage": {
  "prompt_tokens": 312000, "completion_tokens": 1840, "total_tokens": 313840,
  "prompt_tokens_details": {"cached_tokens": 310500},
  "completion_tokens_details": {"reasoning_tokens": 1200},
  "adaptiq": {"input_tokens": 1500, "memory_write_tokens": 1500,
              "memory_read_tokens": 310500, "output_tokens": 1840,
              "cost_usd": "0.004580", "price_card": "2026-11-17"}
}

Core fields

FieldRequiredDescription
modelYesA model ID returned by /v1/models
messagesYesOpenAI-compatible message array
streamNoEnable server-sent event streaming
max_tokensNoMaximum generated tokens for this request

POST /v1/messages

The Anthropic Messages shape, what Claude Code reads. cache_creation_input_tokens is memory_write_tokens; cache_read_input_tokens is memory_read_tokens. Streaming: message_start.usage carries the input and cache fields, message_delta.usage the final output_tokens. cache_control on blocks is accepted and ignored: memory is always on.

bash
curl https://api.adaptiqai.com/v1/messages \
  -H "x-api-key: $ADAPTIQ_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "adaptiq-deepseek-v4.1-flash",
    "max_tokens": 1024,
    "system": "You are a precise assistant.",
    "messages": [
      {"role": "user", "content": "Summarise the decision."}
    ]
  }'
json
"usage": {"input_tokens": 1500, "cache_creation_input_tokens": 1500,
          "cache_read_input_tokens": 310500, "output_tokens": 1840}

POST /v1/responses

The Responses shape, what Codex reads. The same adaptiq block as in Chat Completions is sent as a sibling of usage on the final response.completed event.

bash
curl https://api.adaptiqai.com/v1/responses \
  -H "Authorization: Bearer $ADAPTIQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "adaptiq-deepseek-v4.1-flash",
    "input": [
      {"role": "developer", "content": "You are a precise assistant."},
      {"role": "user", "content": "Summarise the decision."}
    ]
  }'
json
"usage": {"input_tokens": 312000, "input_tokens_details": {"cached_tokens": 310500},
          "output_tokens": 1840, "output_tokens_details": {"reasoning_tokens": 1200},
          "total_tokens": 313840}

Headers on every response

All three shapes, streaming included, sent before the body. Rate-limit headers use the OpenAI names and the Anthropic unified names, so both Claude Code's and Codex's status lines show them.

bash
x-adaptiq-request-id: req_...
x-adaptiq-price-card: 2026-11-17
x-adaptiq-cost-usd: 0.004580          # after settlement, where the protocol allows
x-adaptiq-balance-usd: 148.21         # otherwise on the next request
x-ratelimit-limit-requests, x-ratelimit-remaining-requests
x-ratelimit-limit-tokens, x-ratelimit-remaining-tokens, x-ratelimit-reset-tokens
anthropic-ratelimit-unified-status, anthropic-ratelimit-unified-reset,
anthropic-ratelimit-unified-representative-claim
retry-after: <= 60                    # on 429 and 503
Native Memory
A request refused by admission, or failing before the first output token, costs nothing. A stream aborted by the client is billed for what was produced. A child session that inherits its parent's memory reports the inherited context as memory_read_tokens and is never charged a write for it. Memory identity is bound by the authenticated workspace and provider session metadata; do not place private tenant identity in prompt text.
Was this page helpful?