API Docs

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.

Base URLhttps://api.autark.ai/v1
AuthAuthorization: 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_0a1b2c3d4e5f60718293a4b5c6d7e8f90a1b2c3d4e5f6071
// Load the key from the environment — never hard-code it.

Create 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)
// Same request shape as OpenAI. Routing happens on our side.

Error Handling

Autark uses standard HTTP status codes. All errors return a JSON body with an error object.

200

Success

The request completed successfully.

400

Bad request

Invalid JSON, missing required fields, or the request was blocked by our safety filters.

401

Unauthorized

Invalid or missing API key. Check your Authorization header.

402

Insufficient credits

Your account is out of credits. Add credits in the dashboard.

403

Spend cap exceeded

This key or gateway hit its monthly spend cap. Raise or clear the cap in Settings.

422

Unprocessable entity

Valid JSON, but one or more parameter values are invalid.

429

Rate limit exceeded

More than 60 requests per minute for this key. Retry after the Retry-After header duration.

500

Internal server error

Something went wrong on our end. Contact support if it persists.

503

Service unavailable

A provider is down or Redis is unreachable. Retry with exponential backoff.

{
  "error": {
    "message": "Insufficient credits",
    "type": "insufficient_funds",
    "code": 402
  }
}
// Every error response follows this shape.

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-Limit

Your per-minute request limit.

X-RateLimit-Remaining

Requests remaining in the current window.

X-RateLimit-Reset

Unix 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)
// Retry 429s with exponential backoff, honoring Retry-After.

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-pro

Autark Pro

Smart routing. Every request goes to the best model for that specific task. The default choice for balanced quality and cost.

autark-agent

Autark Agent

Agentic routing. Built for tool calling and multi-step agent workloads. Same smart routing, tuned for agents.

autark-deep

Autark 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-private

The 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)
// Standard SSE stream. Lines arrive as data: {...}, ending with data: [DONE].

Request parameters

Every field the /v1/chat/completions endpoint accepts. Anything OpenAI-compatible works; these are the fields we honour.

model
string

autark-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).

messages
array

Standard OpenAI message format.

stream
boolean

Enable SSE streaming. Default: false.

max_tokens
integer

Max output tokens. Default: 8192, max: 131072.

temperature
float

Sampling temperature 0-2. Default: 0.7.

top_p
float

Nucleus sampling 0-1. Default: 1.0.

n
integer

Number of completions. Default: 1, max: 10.

stop
string[]

Up to 4 sequences where generation stops.

user
string

End-user identifier for abuse monitoring.

response_format
object

{"type": "json_object"} or {"type": "json_schema", "json_schema": {...}} for structured output.

tools
array

Function calling tools. OpenAI-compatible.

tool_choice
string | object

Force a specific tool, or 'auto' / 'none'.

parallel_tool_calls
boolean

Allow multiple tool calls in one turn.

Custom Headers

Request headers

x-autark-modeComing soon

Override the routing contract (autark-pro, autark-deep, or autark-agent) per request without changing the model field.

x-autark-no-optimize

Set to "true" to skip prompt optimization. Use this if you have already crafted your system prompt and want it sent verbatim.

x-autark-no-bandit

Advanced. 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-id

Unique 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
  }
}
// Token counts and savings breakdown live in your dashboard.

Endpoints

POST/v1/chat/completions

Create a chat completion. OpenAI-compatible request and response.

API key
GET/v1/models

List the models available to your account.

API key
GET/v1/usage

Current token usage and estimated savings for your account.

API key
GET/v1/me

Your account profile, current balance, and this-month usage.

API key
GET/v1/me/balance

Current credit balance for the authenticated account.

API key
GET/v1/me/daily

Per-day token usage for the current month.

API key
GET/v1/keys

List your API keys and their spend caps.

API key
POST/v1/keys

Create an API key (optionally with a spend cap).

API key
PATCH/v1/keys/{key_id}

Update a key's name or spend cap.

API key
DELETE/v1/keys/{key_id}

Revoke an API key.

API key
GET/health

Health check with provider status. No authentication required.

Public

Endpoint examples

All requests use the same base URL and bearer token shown above.

GET/v1/models

List 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)
// Returns the modes you can pass in the model field.
GET/v1/usage

Fetch 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())
// Page through history with limit/offset; filter by mode.
GET/v1/me

Get 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"])
// Returns email, balance, and usage for the current key.

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.