API Reference
One OpenAI-compatible endpoint for the whole above.dev model catalog. You name the model you want and get that model, with the full upstream cache discount passed through on every token class.
Overview
above.dev exposes inference endpoints under https://api.above.dev/v1. You choose the model with the standard model field in the request body, or with the x-model header. If you name no model, the request is served by a fixed default.
Two routing modes are available:
- Default mode — if you name no model, the request is served by a single fixed default model. Nothing inspects your prompt.
- Direct mode — You specify exactly which model to use via
x-model.
Some models are TEE-enabled. The model catalog shows which models support TEE.
Authentication
All requests require a Bearer token in the Authorization header. API keys are issued after purchase at above.dev/pricing and follow the format sk-gw-….
Authorization: Bearer sk-gw-<your-api-key>Quick start
Send your first request in under a minute:
curl -X POST https://api.above.dev/v1/messages \
-H "Authorization: Bearer sk-gw-<your-key>" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "user", "content": "Summarise the key steps of a RAG pipeline." }
],
"max_tokens": 1024
}'POST /v1/messages
The primary inference endpoint. Accepts a messages payload and returns a completion.
Serves the model you name in the request body or the x-model header, and a fixed default if you name none.
Request body
| Parameter | Type | Description | |
|---|---|---|---|
| messages | array | Required | Array of message objects with role and content fields. |
| max_tokens | integer | Optional | Maximum tokens to generate. Defaults to 4096. |
| stream | boolean | Optional | Set to true to stream the response as SSE. |
| temperature | number | Optional | Sampling temperature. Passed through to the model. |
| top_p | number | Optional | Nucleus sampling threshold. |
| tools | array | Optional | Tool definitions. Presence influences routing toward tool-capable models. |
| tool_choice | object | Optional | Tool choice control. Passed through to the model. |
| response_format | object | Optional | Structured output format. Presence scores toward structured-output models. |
POST /v1/chat/completions
An OpenAI-compatible alias that delegates to /v1/messages. Use this as a drop-in replacement if your SDK or framework targets the OpenAI API format.
Identical behaviour to /v1/messages. All routing headers apply.
Routing headers
These request headers control how above.dev routes your request. All are optional — omitting them serves the request with the default model. You can also select a model with the standard OpenAI model field in the request body, which most clients set for you.
| Header | Values | Description |
|---|---|---|
| x-mode | auto · direct | Routing mode. direct serves the model named in x-model. auto (default) serves the default model. |
| x-model | model slug | Target model slug, e.g. deepseek-v4-pro. Takes precedence over the model field in the request body. |
| x-session-id | opaque string | Groups related requests into one session for your usage reporting. Also accepted as session_id in the body. |
Auto mode
If you omit model (and the x-model header), the request runs in auto mode and is served by deepseek-v4.1-flash — the cheapest model in the catalog. The aliases smart-select, gateway-auto and auto resolve the same way, so clients that expect a routing model id keep working.
Auto mode is a sensible default, not a classifier: it does not inspect your prompt to pick a model. For anything where model choice matters, name the model explicitly with direct mode below — that is the recommended path for production traffic.
curl -X POST https://api.above.dev/v1/messages \
-H "Authorization: Bearer sk-gw-<your-key>" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "Fix this bug: ..." }],
"max_tokens": 2048
}'Direct mode
Use x-mode: direct with x-model to target a specific model, or just set the model field in the body, which most clients do for you. Either way your request goes to exactly the model you name. This is the recommended path for production traffic.
curl -X POST https://api.above.dev/v1/messages \
-H "Authorization: Bearer sk-gw-<your-key>" \
-H "Content-Type: application/json" \
-H "x-mode: direct" \
-H "x-model: deepseek-v4-pro" \
-d '{
"messages": [{ "role": "user", "content": "..." }],
"max_tokens": 4096
}'Response headers
Every response includes metadata headers describing what happened:
| Header | Description |
|---|---|
| x-model-used | Slug of the model that handled the request, e.g. deepseek-v4-pro. |
| x-tier | Tier of the selected model (1–4). |
| x-score | Internal selection score for the model that served the request (0–100). |
| x-cost-micro | Cost of this request in µ$ (micro-dollars). $1 = 1,000,000 µ$. |
| x-cost-usd | Cost in USD as a decimal string, e.g. 0.000312. |
| x-balance-remaining-micro | Remaining balance in µ$ after this request. |
| x-balance-remaining-usd | Remaining balance in USD, e.g. 18.4231. |
| x-input-cache-hit-tokens | Input tokens served from the provider's prompt cache and billed at the cheaper cache-hit rate. |
| x-input-cache-miss-tokens | Input tokens billed at the full rate. |
| x-input-cache-hit-rate | Cache hits as a fraction of total input tokens, e.g. 0.9553. Only sent when the provider reports cache data. |
| x-request-id | UUID for this request — include in support queries. |
Streaming
Set "stream": true in your request body to receive a Server-Sent Events stream. Each event follows the standard SSE format with a data: prefix. The stream terminates with data: [DONE].
import requests, json
resp = requests.post(
"https://api.above.dev/v1/messages",
headers={
"Authorization": "Bearer sk-gw-<your-key>",
"Content-Type": "application/json",
},
json={
"messages": [{"role": "user", "content": "Write a sorting algorithm."}],
"max_tokens": 2048,
"stream": True,
},
stream=True,
)
for line in resp.iter_lines():
if line and line.startswith(b"data: "):
data = line[6:]
if data == b"[DONE]":
break
chunk = json.loads(data)
print(chunk, flush=True)Limits
Limits apply per account, across all of your API keys.
| Limit | Value | On exceeding |
|---|---|---|
| Request rate | 300 requests / minute | 429 rate_limit_exceeded with Retry-After |
| Request body | 8 MB | 413 request_too_large |
| Input tokens | Up to the model's context window (1,000,000 for the current catalog) | 413 input_too_large |
| Large-context requests | One 500k+ token request per 2 minutes | 429 large_context_rate_limit_exceeded |
| Output tokens | 131,072 | Silently clamped to the cap |
A model's own context window is the ceiling; exceeding it returns 413 input_too_large_for_model, naming that model's ceiling.
Every model in the catalog accepts up to 131,072 output tokens. The two free-tier routes, glm-5.3-flash-modal and deepseek-v4.1-flash-modal, are capped at 16,384 instead, because they share a fixed concurrency pool. A max_tokens above the cap is reduced to it rather than rejected, and each model reports its own figure as max_completion_tokens in GET /v1/models.
Need higher limits? Email support@realtimecomms.co.uk.
Errors
All errors return JSON with an error field describing the issue.
| Status | Meaning |
|---|---|
| 400 | Bad request — invalid JSON body or missing messages array. |
| 401 | Unauthorised — missing, malformed, or inactive API key. |
| 402 | Payment required — insufficient balance. Top up at above.dev/pricing. |
| 403 | model_not_allowed_for_key — the key is restricted to a subset of models, or the model is in private beta and needs to be enabled for your key. |
| 413 | Too large — the body exceeds 8 MB, or the estimated input exceeds the model's context window. The response names the limit it hit. |
| 429 | rate_limit_exceeded — more than 300 requests per minute. A Retry-After header tells you when to retry. Note that provider_error with status 429 is different: that is the upstream provider rate-limiting, not us. |
| 500 | Internal server error — routing failure. |
| 503 | service_unavailable — a dependency (balance or model-access lookup) is temporarily unreachable. Retry after a short delay. |
| 504 | provider_timeout — the upstream model did not respond in time. |
| varies | provider_error — the upstream provider returned an error, and its status is passed through with a request_id you can quote to support. |
Model catalog
The active model catalog is exposed through GET /v1/models. Provider names are shown as above.dev in customer-facing surfaces.
| Model | Slug | Tier | Context | Input /1M | Cache hit /1M | Output /1M |
|---|---|---|---|---|---|---|
| DeepSeek V4.1 Flash | deepseek-v4.1-flashalso deepseek-v4-flash | T1 | 1 million | $0.165–$0.33 | $0.0033–$0.0066 | $0.66–$1.32 |
| DeepSeek V4 Pro | deepseek-v4-pro | T2 | 1 million | $0.726–$1.452 | $0.0242–$0.0484 | $2.178–$4.356 |
| GLM 5.2 | glm-5.2 | T2 | 1 million | $1.54 | $0.154 | $4.84 |
| GLM 5.3 Flash | glm-5.3-flash | T1 | 1 million | $0.165 | $0.0319 | $0.55 |
| GLM 5.2 Fast | glm-5.2-fast | T3 | 1 million | $2.31 | $0.231 | $7.26 |
| Qwen 3.8 Max | qwen3.8-max | T3 | 1 million | $2.20 | $0.275 | $6.60 |
| MiMo V2.6 Pro | mimo-v2.6-proalso mimo-v2.5-pro | T2 | 1 million | $0.5077 | $0.0042 | $1.0154 |
| MiMo V2.6 Flash | mimo-v2.6-flash | T1 | 1 million | $0.1692 | $0.0034 | $0.3385 |
| MiMo V2.6 Pro UltraSpeed | mimo-v2.6-pro-ultraspeed | T3 | 1 million | $5.0769 | $0.0423 | $10.1538 |
Where two prices are shown, the model uses time-of-day pricing: peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays, and all other hours bill at the lower off-peak rate. Weekends are entirely off-peak: the provider defines its weekend in Beijing time, so that runs from 16:00 UTC Friday to 16:00 UTC Sunday. Cache-hit input is billed separately and more cheaply wherever the upstream provider reports it. Every response carries its exact cost in the x-cost-usd header, so billing is verifiable per request.
Why cache pricing dominates agent costs
An agent session re-sends the growing conversation on every tool call. After 50 calls the original prompt has been billed roughly 50 times, and on typical coding-agent traffic 80 to 95% of all input tokens are served from the provider's prompt cache. That makes the cache-hit rate, not the headline input price, the number that decides what a session costs. We pass the full upstream cache discount through: DeepSeek's 97% discount (cache hits from $0.0077/M off-peak on V4 Flash) and Fireworks' 10x discount on GLM 5.2 ($0.154/M, where the official API's own rate is $0.26/M). You can verify your cache performance on every response via the x-input-cache-hit-rate header.
Tier system
Models are grouped into four capability tiers. Tiers are descriptive, to help you pick a model: nothing routes on them automatically.
| Tier | Characteristics | Best for |
|---|---|---|
| T1 | Balanced — fast, cost-efficient | Summarisation, classification, high-throughput pipelines |
| T2 | Agentic — multi-step, tool-capable | Agentic workflows, tool use, reasoning chains |
| T3 | Highest capability in the catalog | Complex coding, deep reasoning, long-context tasks |
| T4 | Enterprise — restricted premium models | Enterprise accounts only |