Documentation

Subaxis API Docs

Use Subaxis as an OpenAI-compatible API gateway with your Subaxis API key.

Base URL

Use this as your OpenAI-compatible base URL.

https://subaxis.dev/v1

Authentication

Create an API key in the customer console and send it as a bearer token.

Authorization: Bearer sk-subaxis...

Chat Completions

curl https://subaxis.dev/v1/chat/completions \
  -H "Authorization: Bearer YOUR_SUBAXIS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [
      { "role": "user", "content": "Hello from Subaxis" }
    ]
  }'

Vision + Tool Calling

{
  "model": "gpt-4o-mini",
  "messages": [{
    "role": "user",
    "content": [
      { "type": "text", "text": "Read this image, then call the tool if needed." },
      { "type": "image_url", "image_url": { "url": "data:image/png;base64,..." } }
    ]
  }],
  "tools": [{
    "type": "function",
    "function": {
      "name": "save_result",
      "description": "Save the result",
      "parameters": {
        "type": "object",
        "properties": { "summary": { "type": "string" } },
        "required": ["summary"]
      }
    }
  }]
}

Models

List available models, pricing metadata, vision support, and tool-calling support from the models endpoint.

GET https://subaxis.dev/v1/models

Usage and Balance

Use your Subaxis API key to inspect your own account, balance, request logs, token usage, spend, model breakdowns, key breakdowns, and billing transactions.

curl https://subaxis.dev/v1/me \
  -H "Authorization: Bearer YOUR_SUBAXIS_KEY"

curl https://subaxis.dev/v1/usage/summary?period=7d \
  -H "Authorization: Bearer YOUR_SUBAXIS_KEY"

Account Endpoints

GET /v1/me
GET /v1/balance

/v1/me returns the authenticated account, API key metadata, and linked customer profile. /v1/balance returns the current USD balance for the linked customer.

Usage Endpoints

GET /v1/usage?period=30d
GET /v1/usage/logs?limit=100
GET /v1/usage/summary?period=7d
GET /v1/usage/costs?period=30d
GET /v1/usage/models?period=30d
GET /v1/usage/keys?period=30d

/v1/usage returns usage logs plus a summary. /v1/usage/logs returns request-level logs. /v1/usage/summary returns totals, success/failure counts, tokens, cost, model totals, and endpoint totals. /v1/usage/costs groups spend by day. /v1/usage/models groups usage by model. /v1/usage/keys groups usage by API key.

Usage Filters

Usage endpoints support these query parameters.

period=24h|7d|30d|90d
start_time=1719878400
end_time=1719964800
model=openai/gpt-4o-mini
key_id=key_id_here
endpoint=/v1/chat/completions
limit=100

start_time and end_time accept Unix seconds, Unix milliseconds, or parseable date strings. You can also use aliases start, end, after, and before.

Usage Response Example

{
  "object": "usage.summary",
  "total_requests": 42,
  "successful_requests": 40,
  "failed_requests": 2,
  "input_tokens": 120000,
  "output_tokens": 45000,
  "total_tokens": 165000,
  "total_cost": 0.81,
  "currency": "usd",
  "by_model": [],
  "by_endpoint": []
}

Billing History

List balance transactions for the authenticated customer, including top-ups and usage deductions.

GET /v1/billing/history?limit=100
{
  "object": "list",
  "data": [{
    "object": "balance_transaction",
    "id": "txn_...",
    "created": 1719878400,
    "type": "credit",
    "amount": 10,
    "currency": "usd",
    "metadata": {}
  }],
  "has_more": false
}

Billing

Usage is deducted from your Subaxis balance. Top-ups use Polar checkout once payments are configured.