Skip to content
Hardcount
Run it locally
Pre-1.0 · one maintainer · Stripe and cards only · no SDKs (client libraries) yet · no production users yet. Docs describe v0.12.0 (30 Nov 2026) · What’s new →

List provider cost rates

GET
/v1/provider-costs
curl --request GET \
--url 'http://localhost:8080/v1/provider-costs?limit=50&offset=0' \
--header 'Authorization: Bearer <token>'

Your provider cost rates: what you pay AI providers per token, one rate per provider, model and token type, ordered by provider, model and token type. A rate is edited in place. The cost stamped on each usage event when it arrived is the history, so changing a rate never changes past events.

limit
integer
default: 50 >= 1 <= 100

Rows per page, from 1 to 100. Default 50. Any other value, one that is not a whole number, or limit sent twice is a 422 with param: limit. It is never clamped.

offset
integer
0

Rows to skip, 0 or more. Default 0. A negative value, one that is not a whole number, or offset sent twice is a 422 with param: offset.

One page of rates, and how many there are.

Media typeapplication/json
object
data
required
Array<object>

What you pay an upstream AI provider per token, for one provider, model and token type. When a usage event with matching provider, model and token_type labels arrives, Hardcount stamps this cost on it, unless the event already brings a cost the provider reported. The margin report adds the stamps up. Editing or deleting a rate changes only events that arrive later. The /v1/provider-costs routes manage rates.

object
id
required

The rate’s ID, hc_pcr_ and 24 hex characters.

string
tenant_id

The account the rate belongs to.

string
provider
required

The provider, in lower case, such as anthropic. It must equal the provider label of the usage events it costs.

string
model
required

The model, such as claude-sonnet-4.5. An event matches on its model_raw label first, then on its model label.

string
token_type
required

The kind of token, in lower case, such as input, output or cache_read. It must equal the token_type label of the usage events it costs.

string
unit_cost_cents
required

US cents per token, as a decimal string (e.g. “0.0003” = $3.00 per 1,000,000 tokens).

string
currency
required

Always USD. Cost and margin count every rate in US cents.

string
Allowed values: USD
created_at
required

When the rate was first set.

string format: date-time
updated_at
required

When the rate was last set.

string format: date-time
total
required

How many rows match the request’s filters, on every page, not only this one. The audit log and the customer list’s search and name or email sort say where they stop counting.

integer

Example

{
"data": [
{
"id": "hc_pcr_9c3e5a7b1d2f4e6a8c0b2d4f",
"tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00",
"provider": "anthropic",
"model": "claude-sonnet-4.5",
"token_type": "input",
"unit_cost_cents": "0.0002",
"currency": "USD",
"created_at": "2026-09-15T09:10:00Z",
"updated_at": "2026-09-15T09:10:00Z"
},
{
"id": "hc_pcr_9c3e5a7b1d2f4e6a8c0b2d61",
"tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00",
"provider": "anthropic",
"model": "claude-sonnet-4.5",
"token_type": "output",
"unit_cost_cents": "0.001",
"currency": "USD",
"created_at": "2026-09-15T09:10:00Z",
"updated_at": "2026-09-15T09:10:00Z"
}
],
"total": 2
}

No valid credential: the API key or session is missing, wrong, expired or revoked. With no API key and no valid session cookie, the message starts with missing credentials. A wrong, expired and revoked key all get the same message, invalid or expired API key.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "authentication_error",
"code": "unauthorized",
"message": "invalid or expired API key",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

The credential is valid but may not call this route. A usage-only key (hc_ingest_…) can only send usage, read a customer’s live credit balance and call GET /v1/whoami; use a secret key. The message names the permission the key lacks. A browser request that would change data (POST, PUT, PATCH or DELETE) from a page on another site gets this 403 too, with the message cross-site request blocked.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "authentication_error",
"code": "forbidden",
"message": "insufficient permissions: this key type does not have customer:read access",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

limit or offset is out of range, not a whole number or sent twice, or the request sends the removed after cursor (param names it)

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "limit must be a whole number from 1 to 100",
"request_id": "req_dbjg652q3gpgqfoq5cd0",
"param": "limit"
}
}

Too many requests. Wait for the number of seconds in Retry-After, then retry. The answers that pass the limit carry the X-RateLimit-* headers too.

Each API key has its own limit, by default 1,000 requests a minute (HARDCOUNT_RATE_LIMIT_GENERAL_PER_MIN), and 1,000 a second on the usage routes (HARDCOUNT_RATE_LIMIT_INGEST_PER_SEC). The dashboard sessions of one account share one limit per mode. The routes under /v1/auth and /v1/bootstrap (sign-in, password reset, invite accept, setup) count per client address, by default 100 a minute (HARDCOUNT_RATE_LIMIT_AUTH_PER_MIN). The public invoice, payment-update and cost-dashboard pages allow 60 a minute per client address.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "too many requests — please retry after the rate limit resets",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}
Retry-After
integer
Example
12

Seconds to wait before the next request can pass, rounded up to a whole second and at least 1.

X-RateLimit-Limit
integer
Example
1000

How many requests the limit allows in its period (a minute, or a second on the usage routes).

X-RateLimit-Remaining
integer
Example
0

How many requests are left in the current period.

X-RateLimit-Reset
integer format: int64
Example
1793870460

When the whole limit is available again, as Unix seconds. One request may pass sooner; Retry-After says when.

Stuck, or found a bug? Ask in Discussions · Open an issue