API Documentation

OpenAI-compatible API gateway. One line change in your code.

Quickstart

Replace base_url and api_key. Everything else stays the same.

cURL

curl https://api.costllm.ai/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-v4-flash", "messages": [ {"role": "user", "content": "Hello, how are you?"} ] }'

Python (OpenAI SDK)

from openai import OpenAI client = OpenAI( base_url="https://api.costllm.ai/v1", api_key="YOUR_API_KEY" ) response = client.chat.completions.create( model="deepseek-v4-flash", messages=[{"role": "user", "content": "Hello!"}] ) print(response.choices[0].message.content)

Node.js

import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'https://api.costllm.ai/v1', apiKey: 'YOUR_API_KEY' }); const response = await client.chat.completions.create({ model: 'deepseek-v4-flash', messages: [{ role: 'user', content: 'Hello!' }] }); console.log(response.choices[0].message.content);

Authentication

Include your API key in the Authorization header:

Authorization: Bearer sk-costllm-xxxxxxxxxxxxxxxx

Generate API keys from your Dashboard after signing up.

Available Models

Model IDInput / 1M tokensOutput / 1M tokensContextBest for
deepseek-v4-flash$0.14$0.28128KChat, drafts, quick tasks
deepseek-v4-pro$0.44$0.87128KCode, analysis, reasoning

Rate Limits

PlanRequests / MinuteAPI Keys
Free51
Starter305
Pro10020
Team30050
BusinessUnlimitedUnlimited

Rate limit info is returned in response headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.

Response Headers

HeaderDescription
X-RateLimit-LimitMax requests per minute for your plan
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets
X-CacheHIT if served from cache, MISS otherwise

Error Codes

StatusMeaning
200Success
401Invalid or missing API key
429Rate limit exceeded. Wait and retry
500Server error. Check /health

Privacy

Data handling: CostLLM routes requests to third-party AI model providers. We log token counts and metadata, not prompt content. Please do not submit sensitive personal, legal, medical, financial, or confidential business data through the API. Some model providers may process data outside your country depending on the selected route.