Model Pricing
Configure the per-token cost of each model so Hrida AI Studio can track spend, enforce budgets, and surface cost data in analytics.
Model pricing lets admins record the input and output token costs for every LLM connected to the instance. Once configured, Hrida AI Studio automatically calculates the USD cost of each message and persists it alongside the conversation — feeding the cost columns in Analytics, and powering per-user and per-group Usage Limits.
All model pricing endpoints require an admin account. Regular users can view their own accumulated cost via the Usage Limits GET /me endpoint.
How it works
- Admin sets
input_cost_per_millionandoutput_cost_per_million(in USD) for a model. - When a chat message is saved, the backend reads the token counts from the model response, looks up the pricing entry by
model_id, and storescost_usdon the message row. - The Analytics dashboard aggregates these costs. Usage Limits reads them to enforce quotas.
Cost calculation uses eight decimal places of precision (0.00000001) to accurately represent sub-cent amounts for cheap or short messages.
Default prices
When the instance starts for the first time, the model_pricing table is automatically seeded with pricing for well-known models including:
- OpenAI:
gpt-4o,gpt-4o-mini,gpt-4,gpt-3.5-turbo, o-series reasoning models - Anthropic:
claude-3-5-sonnet-*,claude-3-opus-*,claude-haiku-*,claude-sonnet-4-6, etc. - Google: Gemini models
- Common open-source models via Ollama pricing approximations
If the table already has entries when the instance starts, seeding is skipped — your customizations are preserved.
Managing pricing
Viewing current prices
Go to Admin Panel > Model Pricing to see the full table, or use the API:
GET /api/v1/model-pricing
Authorization: Bearer <admin-token>Response:
[
{
"id": "uuid",
"model_id": "gpt-4o",
"provider": "openai",
"input_cost_per_million": "2.50000000",
"output_cost_per_million": "10.00000000",
"currency": "USD",
"is_active": true
}
]Setting or updating a price
Use an upsert — the same endpoint creates or updates:
PUT /api/v1/model-pricing/gpt-4o
Authorization: Bearer <admin-token>
Content-Type: application/json
{
"provider": "openai",
"input_cost_per_million": 2.50,
"output_cost_per_million": 10.00,
"currency": "USD",
"is_active": true
}The model_id is taken from the URL path and supports slashes (e.g., anthropic/claude-3-5-sonnet-20241022).
Disabling a price without deleting it
Set "is_active": false in the upsert payload. Inactive entries are ignored by the cost calculator — messages for that model will have cost_usd: null.
Deleting a price
DELETE /api/v1/model-pricing/{model_id}
Authorization: Bearer <admin-token>API reference
| Method | Path | Description |
|---|---|---|
GET | /api/v1/model-pricing | List all pricing entries |
PUT | /api/v1/model-pricing/{model_id} | Create or update pricing for a model |
DELETE | /api/v1/model-pricing/{model_id} | Delete pricing for a model |
Tips
- Model IDs must match exactly. The cost calculator does a direct lookup — if your model is registered as
gpt-4o-2024-08-06you need a pricing entry for that exact string, notgpt-4o. - Currency is always USD in the current implementation. The
currencyfield is stored for forward compatibility. - Costs appear in analytics after the next analytics refresh. Already-saved messages with
cost_usd: nullare not back-filled. - Combine with Usage Limits to turn cost tracking into enforcement — see Usage Limits.