Est. 2026

API Reference

View llms.txt

Pricing, specs, and capabilities for AI models across all major providers. No authentication required.

Base https://api.subquery.ai/v1

Authentication

No authentication is required. All endpoints are open and free to use without an API key.

Optionally authenticate to track usage:

Authorization: Bearer sk_live_your_api_key

What's Included

Feature Access
Requests Unlimited
Pricing data Yes
Model specs (context, capabilities, modalities) Yes
API IDs (native, bedrock, vertex) Yes
Max page size 100
Data freshness Real-time

Errors

Standard HTTP status codes. Errors return JSON:

{
  "error": {
    "code": "model_not_found",
    "message": "Model 'gpt-5' not found in provider 'openai'",
    "details": {
      "available_models": ["gpt-4o", "gpt-4-turbo", "..."]
    }
  }
}
Code Description
400 Bad request — invalid parameters
401 Unauthorized — missing or invalid API key
404 Not found — resource doesn't exist
429 Rate limited — too many requests
500 Server error

List Models

GET /models

Returns all models with pricing and capabilities. Supports filtering by provider.

Query Parameters

provider string
Filter by provider ID (e.g., openai, anthropic)
limit integer
Max results to return. Default: 20, Max: 100
offset integer
Number of results to skip for pagination
Example Request
curl https://api.subquery.ai/v1/models?provider=openai
const response = await fetch(
  'https://api.subquery.ai/v1/models?provider=openai'
);
const data = await response.json();
import requests

response = requests.get(
    'https://api.subquery.ai/v1/models',
    params={'provider': 'openai'}
)
data = response.json()
Response
{
  "data": [
    {
      "id": "gpt-4o",
      "provider": "openai",
      "name": "GPT-4o",
      "context_window": 128000,
      "max_output_tokens": 16384,
      "capabilities": ["vision", "function_calling", "json_mode"],
      "pricing": {
        "standard": {
          "input": 2.50,
          "output": 10.00,
          "unit": "1M tokens"
        }
      }
    }
  ],
  "meta": {
    "total": 200,
    "limit": 20,
    "offset": 0
  }
}

Get Model

GET /models/:provider/:model_id

Returns detailed information for a specific model including full pricing tiers, capabilities, and specs.

Path Parameters

provider string required
Provider ID: openai, anthropic, google, mistral, xai, groq, fireworks, deepseek, together, cohere, perplexity, bedrock
model_id string required
The model ID (e.g., gpt-4o, claude-3-opus-20240229)
Example Request
curl https://api.subquery.ai/v1/models/anthropic/claude-3-opus-20240229
Response
{
  "data": {
    "id": "claude-3-opus-20240229",
    "provider": "anthropic",
    "name": "Claude 3 Opus",
    "description": "Most powerful model for complex tasks",
    "context_window": 200000,
    "max_output_tokens": 4096,
    "knowledge_cutoff": "2023-08",
    "capabilities": ["vision", "function_calling", "json_mode"],
    "modalities": {
      "input": ["text", "image"],
      "output": ["text"]
    },
    "api_ids": {
      "native": "claude-3-opus-20240229",
      "bedrock": "anthropic.claude-3-opus-20240229-v1:0",
      "vertex": "claude-3-opus@20240229"
    },
    "aliases": ["claude-3-opus"],
    "deprecated": false,
    "pricing": {
      "standard": {
        "input": 15.00,
        "output": 75.00,
        "unit": "1M tokens"
      },
      "batch": {
        "input": 7.50,
        "output": 37.50
      }
    }
  }
}

List Providers

GET /providers

Returns all available providers with model counts.

Response
{
  "data": [
    { "id": "openai", "name": "OpenAI", "model_count": 45 },
    { "id": "anthropic", "name": "Anthropic", "model_count": 12 },
    { "id": "google", "name": "Google", "model_count": 18 },
    { "id": "mistral", "name": "Mistral", "model_count": 15 },
    { "id": "xai", "name": "xAI", "model_count": 8 },
    { "id": "groq", "name": "Groq", "model_count": 8 },
    { "id": "fireworks", "name": "Fireworks", "model_count": 24 },
    { "id": "deepseek", "name": "DeepSeek", "model_count": 4 },
    { "id": "together", "name": "Together AI", "model_count": 30 },
    { "id": "cohere", "name": "Cohere", "model_count": 6 },
    { "id": "perplexity", "name": "Perplexity", "model_count": 5 },
    { "id": "bedrock", "name": "AWS Bedrock", "model_count": 20 }
  ]
}

Calculate Cost

POST /calculate

Calculate the cost of an API call. Accepts raw API responses or usage objects — provider is auto-detected from the usage format.

Request Body

model string required
Model ID (or extracted from payload if present)
usage object
Token usage object — or just pass the entire API response
provider string
Provider ID (auto-detected if not specified)
is_batch boolean
Use batch pricing if available
tier string
Pricing tier to use (e.g., standard, batch)
context_tokens integer
Total context length for threshold-based pricing (xAI, Anthropic). Required for accurate pricing on models with context-dependent rates.
Simplest Usage
curl -X POST https://api.subquery.ai/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "usage": { "input_tokens": 1000, "output_tokens": 500 }
  }'
Raw API Response

Pass an entire API response — we extract model and usage:

curl -X POST https://api.subquery.ai/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{
    "id": "resp_123",
    "model": "gpt-4o-2024-08-06",
    "usage": {
      "input_tokens": 500,
      "input_tokens_details": { "cached_tokens": 100 },
      "output_tokens": 1000,
      "output_tokens_details": { "reasoning_tokens": 200 }
    }
  }'
Response
{
  "data": {
    "provider": "openai",
    "model": "gpt-4o",
    "total_cost": 0.0075,
    "currency": "usd",
    "breakdown": { "input": 0.0025, "output": 0.005 },
    "detected": {
      "provider": "openai",
      "model": "gpt-4o",
      "usage_type": "tokens"
    }
  }
}

Supported Usage Formats

Provider is auto-detected from the usage structure. All official SDK formats are supported:

Provider Usage Fields
OpenAI prompt_tokens, completion_tokens + cached_tokens, reasoning_tokens
Anthropic input_tokens, output_tokens + cache_creation_input_tokens, cache_read_input_tokens
Google prompt_token_count, candidates_token_count + cached_content_token_count
Mistral prompt_tokens, completion_tokens + prompt_audio_seconds
xAI prompt_tokens, completion_tokens + cached_tokens, reasoning_tokens
Groq prompt_tokens, completion_tokens + prompt_time, completion_time
Fireworks prompt_tokens, completion_tokens + cached_tokens
DeepSeek prompt_tokens, completion_tokens + prompt_cache_hit_tokens
Together prompt_tokens, completion_tokens
Cohere input_tokens, output_tokens + search_units
Perplexity prompt_tokens, completion_tokens + citation_tokens
Bedrock inputTokens, outputTokens (or snake_case)

Changelog

GET /changelog

Returns recent changes to models, pricing, and providers.

Query Parameters

version string
Filter changes by catalog version
limit integer
Max results to return. Default: 20
Response
{
  "data": [
    {
      "version": "2024.01.15.001",
      "change_type": "model_added",
      "provider": "openai",
      "entity_id": "gpt-4.5-preview",
      "summary": "New model added",
      "created_at": "2024-01-15T12:00:00Z"
    }
  ]
}

Versions

GET /versions

List historical catalog versions. Each sync creates a new version.

Response
{
  "data": [
    {
      "version": "2024.01.15.001",
      "created_at": "2024-01-15T12:00:00Z",
      "model_count": 127,
      "provider_count": 5
    }
  ]
}
GET /versions/:version

Get full catalog snapshot at a specific version. Use latest for current data.

Health

GET /health

Check API health and get current pricebook/catalog info.

Response
{
  "data": {
    "status": "ok",
    "uptime_seconds": 86400,
    "pricebook": {
      "version": "2024.01.15.003"
    },
    "catalog": {
      "version": "2024.01.15.001",
      "model_count": 127
    }
  }
}

Rate Limits

The API is rate limited to 60 requests per minute per IP address. Rate limit headers are included in all responses:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1705363260

If you exceed the limit, you'll receive a 429 response. Wait until the reset time before retrying.

Versioning

The API is versioned via the URL path (/v1/). Backwards compatibility is maintained within major versions.

Data versions (pricebook and catalog) are separate from API versions. Each sync creates a new data version, allowing you to query historical snapshots.