CostScope API

Access real-time pricing data programmatically. Compare prices across ... providers including OpenAI, Anthropic, Google, Mistral, and more.

Rate Limits

API requests are tracked per user account. Limits reset daily at midnight UTC.

Loading limits...

Response Headers: Every response includes X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset

Base URL

url
https://api.costscope.app

Authentication

Most endpoints are public and don't require authentication. Some endpoints require a JWT token.

How to get your API Token

  1. Create an account or sign in at costscope.app/auth
  2. Go to your Dashboard Settings
  3. Copy your API token from the API Access section
  4. Include it in your requests as a Bearer token

Public Endpoints (No Auth Required)

bash
curl "https://api.costscope.app/api/prices"

Authenticated Endpoints

bash
# Set your token
export TOKEN="your_jwt_token_here"

# Make authenticated request
curl -H "Authorization: Bearer $TOKEN" \
  "https://api.costscope.app/api/usage"

Prices

GET
/api/prices

Get all current prices for all providers and models. Data is grouped by provider.

Request Examples

bash
curl "https://api.costscope.app/api/prices"

Response

json
{
  "data": {
    "openai": {
      "provider_name": "OpenAI",
      "provider_slug": "openai",
      "services": {
        "gpt-4o": {
          "id": "uuid",
          "name": "GPT-4o",
          "slug": "gpt-4o",
          "unit_type": "tokens",
          "prices": [
            { "type": "input", "value": 2.5, "currency": "USD" },
            { "type": "output", "value": 10.0, "currency": "USD" }
          ]
        }
      }
    }
  },
  "total_prices": 494
}
GET
/api/prices/changes

Get recent price changes across all providers.

Request Examples

bash
curl "https://api.costscope.app/api/prices/changes?limit=10"

Response

json
{
  "data": [
    {
      "service_name": "GPT-4o",
      "provider_name": "OpenAI",
      "price_type": "input",
      "old_value": 3.0,
      "new_value": 2.5,
      "diff_percent": -16.67,
      "detected_at": "2026-02-01T12:00:00Z"
    }
  ],
  "count": 10
}
GET
/api/prices/compare

Compare prices across providers, sorted by price. Great for finding the cheapest option.

Request Examples

bash
curl "https://api.costscope.app/api/prices/compare?type=input"
GET
/api/prices/history/:serviceId

Get historical price data for a specific service.

Request Examples

bash
curl "https://api.costscope.app/api/prices/history/abc123?days=30"

Full Code Examples

Complete examples in different programming languages

javascript
// Fetch all prices and find the cheapest model
const response = await fetch('https://api.costscope.app/api/prices');
const { data } = await response.json();

// Get all providers
const providers = Object.keys(data);
console.log('Available providers:', providers.join(', '));

// Find cheapest input price
let cheapest = { provider: '', model: '', price: Infinity };

for (const [provider, info] of Object.entries(data)) {
  for (const [model, service] of Object.entries(info.services)) {
    const inputPrice = service.prices.find(p => p.type === 'input');
    if (inputPrice && inputPrice.value < cheapest.price && inputPrice.value > 0) {
      cheapest = { provider, model, price: inputPrice.value };
    }
  }
}

console.log('Cheapest:', cheapest.provider, '-', cheapest.model, 'at $' + cheapest.price + '/1M tokens');