API reference
Every endpoint, what it accepts beyond its upstream API, and what it returns.
Base URL https://api.hackrouter.ai/v1. Send your key as Authorization: Bearer hr-... or x-api-key: hr-.... Amounts are exact decimal strings in US dollars; prices are per million units.
| Endpoint | Key | |
|---|---|---|
POST /chat/completions | OpenAI Chat Completions | Yes |
POST /responses | OpenAI Responses | Yes |
POST /messages | Anthropic Messages | Yes |
POST /images/generations | OpenAI Images | Yes |
GET /models | Models, APIs and prices | No |
GET /account | Balance and the key's limit | Yes |
GET /requests/{id} | What one request used and cost | Yes |
POST /estimates | The charge for a given usage | Yes |
POST /files | An upload link for large media | Yes |
The four model APIs behave as their originals do. Fields not listed below are passed to the model unchanged. Request bodies can be up to 20 MiB.
Chat completions
POST /v1/chat/completions takes OpenAI's Chat Completions request. hackrouter checks:
modelis required, and must offeropenai_chat.max_tokensandmax_completion_tokensare positive integers; if both are set,max_completion_tokenswins. The output is capped at the model's maximum.nis 1 to 128.service_tierisautoordefault.web_search_optionsand non-textmodalitiesare refused: they would be billed by the provider in ways hackrouter does not meter.
Responses
POST /v1/responses takes OpenAI's Responses request, and is stateless: nothing is stored.
previous_response_id,conversationandpromptmust be left unset, andbackgroundfalse.max_output_tokensis a positive integer.service_tierisautoordefault.- Tools are
functionorcustom. Built-in tools are refused.
Messages
POST /v1/messages takes Anthropic's Messages request. The anthropic-version header is passed on, 2023-06-01 if you leave it out.
max_tokensis required.- Tools run on your side: custom tools and Anthropic's client tools (bash, text editor, computer, memory). Server tools such as web search are refused.
service_tierisautoorstandard_only.- Beta features that Anthropic charges extra for are removed from
anthropic-beta.
Images
POST /v1/images/generations takes OpenAI's image request.
modelandpromptare required;nis 1 to 10.- For models priced per image,
sizeandqualitymust beautoor one the model offers. - With
response_format: "url", images come back as links valid for 7 days. Otherwise they come back inline asb64_json.
An image is charged once it has started, even if you disconnect.
Models
GET /v1/models and GET /v1/models/{id} need no key.
{
"object": "list",
"data": [
{
"id": "deepseek-v4-pro",
"object": "model",
"owned_by": "hackrouter",
"context_length": 128000,
"max_output_tokens": 8192,
"endpoints": ["openai_chat", "anthropic_messages"],
"prices": { "input_tokens": "1.32", "output_tokens": "3.96" }
}
]
}endpoints lists the APIs the model can be called through. prices gives each meter in dollars per million units; see what is metered.
Account
GET /v1/account returns the balance, and the monthly limit of the key you called with.
{
"object": "account",
"id": "…",
"balance": "12.48",
"api_key": { "id": "…", "monthly_limit": null }
}Requests
GET /v1/requests/{id} returns what a charged request used and cost. The ID is the x-request-id of its response. Charges are recorded within a minute or two; until then, and for failed requests, it returns 404 request_not_found.
{
"object": "request",
"id": "0193…",
"model": "deepseek-v4-pro",
"usage": { "input_tokens": 1820, "output_tokens": 412 },
"is_estimated": false,
"charge": "0.004034",
"started_at": "…",
"duration_ms": 3120,
"first_byte_ms": 410
}is_estimated is true when the provider did not report usage and it was estimated from the text.
Estimates
POST /v1/estimates prices a usage without sending anything to a model.
curl https://api.hackrouter.ai/v1/estimates \
-H "Authorization: Bearer $HACKROUTER_KEY" \
-H "Content-Type: application/json" \
-d '{ "model": "deepseek-v4-pro", "usage": { "input_tokens": 2000, "output_tokens": 500 } }'usage takes the meters as whole numbers; missing ones count as 0. The answer gives the total charge and the charge per meter.
Files
POST /v1/files gives you a link to upload large media to, and a link to put in your request instead of the bytes.
{ "content_type": "image/png", "bytes": 2048000 }content_typeis an image, video or audio type, orapplication/pdf.bytesis up to 200 MiB.- The answer has an
uploadtoPUTthe file to, valid for 15 minutes, and aurlvalid for 7 days. - Creating a file is free, but needs a balance above zero.
Response headers
| Header | Meaning |
|---|---|
x-request-id | The request's ID, for GET /requests/{id} and support |
x-ratelimit-limit-requests | Requests per minute |
x-ratelimit-remaining-requests | How many can be sent right now |
x-ratelimit-reset-requests | When the full burst is available again |
retry-after | On 429 only: seconds to wait |
Errors and their codes are in Errors.