Autark API docs. One line to get started.
Autark is a drop-in replacement for the OpenAI API. Point your existing SDK at our base URL, swap your API key, and keep everything else the same. The best model handles each request behind the scenes.
https://api.autark.ai/v1Authorization: Bearer autark_sk_...Get an API key from cloud.autark.ai. Usage and savings show up in your dashboard.
Connecting an agent or editor? Use Autark with Cursor, Hermes, OpenCode and other tools.
Authentication
Authenticate every request with a bearer token in the Authorization header. Keys are formatted as autark_sk_ followed by 48 hexadecimal characters.
Authorization: Bearer autark_sk_0a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f6071Create a key
Sign in at cloud.autark.ai and go to Settings → API Keys.
Manage keys
Create multiple keys, set a spend cap per key, and revoke any key at any time from the dashboard.
Keep keys safe
Store keys in environment variables and never commit them to version control. Use per-key spend caps as a safety net against runaway usage.
Quick start
Works with the official OpenAI SDKs. No custom headers, no provider config.
from openai import OpenAI
client = OpenAI(
api_key="autark_sk_YOUR_KEY",
base_url="https://api.autark.ai/v1",
)
response = client.chat.completions.create(
model="autark-pro",
messages=[{"role": "user", "content": "Summarize this contract..."}],
)
print(response.choices[0].message.content)Error Handling
Autark uses standard HTTP status codes. All errors return a JSON body with an error object.
200Success
The request completed successfully.
400Bad request
Invalid JSON, missing required fields, or the request was blocked by our safety filters.
401Unauthorized
Invalid or missing API key. Check your Authorization header.
402Insufficient credits
Your account is out of credits. Add credits in the dashboard.
403Spend cap exceeded
This key or gateway hit its monthly spend cap. Raise or clear the cap in Settings.
422Unprocessable entity
Valid JSON, but one or more parameter values are invalid.
429Rate limit exceeded
More than 60 requests per minute for this key. Retry after the Retry-After header duration.
500Internal server error
Something went wrong on our end. Contact support if it persists.
503Service unavailable
A provider is down or Redis is unreachable. Retry with exponential backoff.
{
"error": {
"message": "Insufficient credits",
"type": "insufficient_funds",
"code": 402
}
}Rate Limits
API requests are limited to 60 requests per minute per API key. When you exceed the limit you'll receive a 429 response with a Retry-After header indicating how many seconds to wait.
Rate-limit headers are included on throttled responses:
X-RateLimit-LimitYour per-minute request limit.
X-RateLimit-RemainingRequests remaining in the current window.
X-RateLimit-ResetUnix timestamp when the window resets.
import time
import openai
from openai import OpenAI
client = OpenAI(
api_key="autark_sk_YOUR_KEY",
base_url="https://api.autark.ai/v1",
)
def create_with_backoff(max_retries=5, **kwargs):
delay = 1.0
for attempt in range(max_retries):
try:
return client.chat.completions.create(**kwargs)
except openai.RateLimitError as err:
# Honor Retry-After when present, else exponential backoff.
retry_after = getattr(err, "response", None) and \
err.response.headers.get("Retry-After")
wait = float(retry_after) if retry_after else delay
time.sleep(wait)
delay *= 2
raise RuntimeError("Rate limit: retries exhausted")
response = create_with_backoff(
model="autark-pro",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)Routing modes
Set the model field to control how Autark handles each request. Pick the contract that matches your workload — that is what selects the routing.
Autark routes your request to the best underlying model. You specify the capability tier — not a model name — and we handle model selection automatically.
autark-proAutark Pro
Smart routing. Every request goes to the best model for that specific task. The default choice for balanced quality and cost.
autark-agentAutark Agent
Agentic routing. Built for tool calling and multi-step agent workloads. Same smart routing, tuned for agents.
autark-deepAutark Deep
Deep reasoning for the hardest problems. Multi-step analysis, thinking enabled, investment-grade deliverables.
Zero data retention
Append -private to any contract name for the zero-data-retention variant: same quality, restricted to providers that never train on your prompts.
autark-pro-privateautark-agent-privateautark-deep-privateThe legacy names flash, pro, ultra and autark-flash, autark-open, autark are still accepted for backwards compatibility but are deprecated — prefer the names above.
You can also pin a specific provider model by name if you need to. Autark still handles auth, failover, and billing. See pricing for tier rates.
Streaming
Streaming works the same way as OpenAI. Pass "stream": true and read Server-Sent Events from the response.
stream = client.chat.completions.create(
model="autark-pro",
messages=[{"role": "user", "content": "Write a short poem."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)Request parameters
Every field the /v1/chat/completions endpoint accepts. Anything OpenAI-compatible works; these are the fields we honour.
modelautark-pro, autark-agent or autark-deep (plus -private variants). Pick the contract that matches your workload. Omit it and the request uses `auto`, which resolves to your dashboard's default contract (Autark Pro unless changed).
messagesStandard OpenAI message format.
streamEnable SSE streaming. Default: false.
max_tokensMax output tokens. Default: 8192, max: 131072.
temperatureSampling temperature 0-2. Default: 0.7.
top_pNucleus sampling 0-1. Default: 1.0.
nNumber of completions. Default: 1, max: 10.
stopUp to 4 sequences where generation stops.
userEnd-user identifier for abuse monitoring.
response_format{"type": "json_object"} or {"type": "json_schema", "json_schema": {...}} for structured output.
toolsFunction calling tools. OpenAI-compatible.
tool_choiceForce a specific tool, or 'auto' / 'none'.
parallel_tool_callsAllow multiple tool calls in one turn.
Custom Headers
Request headers
x-autark-modeComing soonOverride the routing contract (autark-pro, autark-deep, or autark-agent) per request without changing the model field.
x-autark-no-optimizeSet to "true" to skip prompt optimization. Use this if you have already crafted your system prompt and want it sent verbatim.
x-autark-no-banditAdvanced. Set to "false" to opt into legacy bandit-only routing instead of the default A-TEM routing. Any other value (or leaving it unset) uses A-TEM.
Response headers
Headers returned on every response.
x-request-idUnique request identifier — include it when contacting support.
Response format
Responses follow the standard OpenAI chat completion shape. The model field in the response matches what you sent. Routing details stay on our side.
{
"id": "autark_req_abc123",
"object": "chat.completion",
"model": "autark-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here is a summary of the contract..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 142,
"completion_tokens": 58,
"total_tokens": 200
}
}Endpoints
/v1/chat/completionsCreate a chat completion. OpenAI-compatible request and response.
API key/v1/modelsList the models available to your account.
API key/v1/usageCurrent token usage and estimated savings for your account.
API key/v1/meYour account profile, current balance, and this-month usage.
API key/v1/me/balanceCurrent credit balance for the authenticated account.
API key/v1/me/dailyPer-day token usage for the current month.
API key/v1/keysList your API keys and their spend caps.
API key/v1/keysCreate an API key (optionally with a spend cap).
API key/v1/keys/{key_id}Update a key's name or spend cap.
API key/v1/keys/{key_id}Revoke an API key.
API key/healthHealth check with provider status. No authentication required.
PublicEndpoint examples
All requests use the same base URL and bearer token shown above.
/v1/modelsList the models and routing modes available to your account.
from openai import OpenAI
client = OpenAI(
api_key="autark_sk_YOUR_KEY",
base_url="https://api.autark.ai/v1",
)
models = client.models.list()
for model in models.data:
print(model.id)/v1/usageFetch your per-request usage log. Supports pagination with limit and offset, plus a mode filter (autark-pro, autark-deep, autark-agent).
import requests
resp = requests.get(
"https://api.autark.ai/v1/usage",
headers={"Authorization": "Bearer autark_sk_YOUR_KEY"},
params={"limit": 50, "offset": 0, "mode": "autark-pro"},
)
print(resp.json())/v1/meGet the authenticated account's profile, current balance, and this-month usage.
import requests
resp = requests.get(
"https://api.autark.ai/v1/me",
headers={"Authorization": "Bearer autark_sk_YOUR_KEY"},
)
me = resp.json()
print(me["email"], me["balance_display"])Data and security
Prompts are processed and discarded. We do not retain request content or use it for training. Compliance metadata (timestamps, model used, token counts) is logged separately from your prompt data.
For the full breakdown, see our trust page.