Skip to Content
hackrouter

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.

EndpointKey
POST /chat/completionsOpenAI Chat CompletionsYes
POST /responsesOpenAI ResponsesYes
POST /messagesAnthropic MessagesYes
POST /images/generationsOpenAI ImagesYes
GET /modelsModels, APIs and pricesNo
GET /accountBalance and the key's limitYes
GET /requests/{id}What one request used and costYes
POST /estimatesThe charge for a given usageYes
POST /filesAn upload link for large mediaYes

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:

  • model is required, and must offer openai_chat.
  • max_tokens and max_completion_tokens are positive integers; if both are set, max_completion_tokens wins. The output is capped at the model's maximum.
  • n is 1 to 128.
  • service_tier is auto or default.
  • web_search_options and non-text modalities are 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, conversation and prompt must be left unset, and background false.
  • max_output_tokens is a positive integer.
  • service_tier is auto or default.
  • Tools are function or custom. 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_tokens is 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_tier is auto or standard_only.
  • Beta features that Anthropic charges extra for are removed from anthropic-beta.

Images

POST /v1/images/generations takes OpenAI's image request.

  • model and prompt are required; n is 1 to 10.
  • For models priced per image, size and quality must be auto or one the model offers.
  • With response_format: "url", images come back as links valid for 7 days. Otherwise they come back inline as b64_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_type is an image, video or audio type, or application/pdf. bytes is up to 200 MiB.
  • The answer has an upload to PUT the file to, valid for 15 minutes, and a url valid for 7 days.
  • Creating a file is free, but needs a balance above zero.

Response headers

HeaderMeaning
x-request-idThe request's ID, for GET /requests/{id} and support
x-ratelimit-limit-requestsRequests per minute
x-ratelimit-remaining-requestsHow many can be sent right now
x-ratelimit-reset-requestsWhen the full burst is available again
retry-afterOn 429 only: seconds to wait

Errors and their codes are in Errors.