LLM Pricing API

This is a community-maintained project! Help us keep the information up-to-date by contributing to the GitHub repository.

Contribute on GitHub

This API provides information about various Large Language Models (LLMs) and their pricing across different providers. The data is maintained by the community to ensure accuracy and timeliness.

Base URL

https://llmpricing.ai

Endpoints

1. List Models

GET /api/models

Returns a list of all available LLM models and their providers.

Example request:

curl https://llmpricing.ai/api/models

Example response:

{
      "OpenAI": [
          "gpt-4o",
          "gpt-4o-2024-08-06",
          ...
      ],
      "Anthropic": [
          "claude-3-5-sonnet-20240620",
          "claude-3-opus-20240229",
          ...
      ],
      ...
  }

2. Calculate Price

GET /api/prices

Calculates the price for a given model based on input and output tokens.

Query Parameters:

Example request:

curl "https://llmpricing.ai/api/prices?provider=OpenAI&model=gpt-4&input_tokens=1000&output_tokens=500"

Example response:

{
      "provider": "OpenAI",
      "model": "gpt-4",
      "input_tokens": 1000,
      "output_tokens": 500,
      "input_cost": 0.03,
      "output_cost": 0.03,
      "total_cost": 0.06
  }

Supported Providers

Error Handling

The API returns appropriate error messages for invalid requests:

Rate Limiting

Please be aware that this API may be subject to rate limiting. Refer to Cloudflare Workers documentation for more information on usage limits.

Contributing

As a community-maintained project, we welcome contributions to keep the pricing and model information up-to-date. If you notice any discrepancies or have information about new models, please contribute by submitting a pull request or opening an issue on our GitHub repository.

Contribute on GitHub