Models API
Get available models and calculate usage costs.
GET
/v1/modelsGet available models with current pricing information.
List models
curl -X GET "https://api.credits.dev/v1/models?provider=openai&tier=flagship" \
-H "X-API-Key: YOUR_API_KEY"Response
{
"success": true,
"models": [
{
"modelId": "gpt-4o",
"provider": "openai",
"displayName": "GPT-4o",
"modelType": "multimodal",
"pricing": {
"text": {
"inputPerMillion": 2.5,
"outputPerMillion": 10,
"cachedInputPerMillion": 1.25
},
"contextWindow": 128000
},
"tier": "flagship"
}
]
}GET
/v1/models?modelId=gpt-4oGet a specific model by ID.
Get model by ID
curl -X GET "https://api.credits.dev/v1/models?modelId=gpt-4o" \
-H "X-API-Key: YOUR_API_KEY"Response
{
"success": true,
"model": {
"modelId": "gpt-4o",
"provider": "openai",
"displayName": "GPT-4o",
"pricing": {
"text": {
"inputPerMillion": 2.5,
"outputPerMillion": 10
}
}
}
}POST
/v1/models/calculateCalculate estimated cost for a given model and token count without recording usage.
Calculate usage cost
curl -X POST "https://api.credits.dev/v1/models/calculate" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"modelId": "gpt-4o",
"inputTokens": 5000,
"outputTokens": 1000,
"cachedTokens": 2000
}'Request Body
{
"modelId": "gpt-4o",
"inputTokens": 5000,
"outputTokens": 1000,
"cachedTokens": 2000
}Response
{
"success": true,
"modelId": "gpt-4o",
"modelName": "GPT-4o",
"estimatedCostUsd": 0.0175,
"pricing": {
"inputPerMillion": 2.5,
"outputPerMillion": 10,
"cachedInputPerMillion": 1.25
}
}