Documentation menu

Sending requests

Call any model through the gateway in the OpenAI or Anthropic format, for a customer and a member.

The gateway speaks three wire formats, so you keep the SDK you already use and change its base URL and key. Every request can name the customer and the member it is for; the gateway checks their limits and balance, calls the provider, streams the answer back unchanged and records the usage.

Endpoints#

FormatMethod and pathBase URL for the official SDK
OpenAI ResponsesPOST /v1/responseshttps://api.hixel.dev/v1
OpenAI Chat CompletionsPOST /v1/chat/completionshttps://api.hixel.dev/v1
Anthropic MessagesPOST /v1/messageshttps://api.hixel.dev

Any format can call any model in the environment's catalog. When the format you send differs from the provider's own (Chat Completions to a Claude model, Messages to a GPT model), the gateway translates the request and the response, streams included. A parameter the provider has no way to express is refused with unsupported_parameter and the field in param.

Beside chat, the gateway also serves /v1/embeddings, /v1/images/generations, /v1/images/edits, /v1/audio/speech, /v1/audio/transcriptions, /v1/audio/translations, /v1/moderations, /v1/rerank, /v1/completions and /v1/messages/count_tokens. These pass through in the provider's own format, without translation, to models whose provider offers them. GET /v1/models lists the models you can call: see Models.

Your first call in each format#

curl https://api.hixel.dev/v1/responses \
  -H "Authorization: Bearer $HIXEL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-hixel-customer: org_42" \
  -H "x-hixel-member: user_7" \
  -d '{ "model": "gpt-6.2-sol", "input": "Summarise this ticket in one line." }'

Authentication#

Send a key with the inference scope as Authorization: Bearer hx_sk_… or as x-api-key: hx_sk_… (where the Anthropic SDK puts it). A browser or mobile app sends a client token the same way instead. See Authentication for keys and scopes.

Request headers#

HeaderWhat it does
x-hixel-customerYour id for the customer the request is for: 1 to 256 characters of visible ASCII, no spaces, not . or ... Its wallet pays and its limits apply.
x-hixel-memberYour id for the person who made it, same rules. Recorded on the request, and member limits apply to it.
x-hixel-tagsUp to 8 labels for your own reports. See Tags and caching.
x-hixel-cacheDirectives for the response cache, when the environment has it on. See Tags and caching.
x-hixel-mockTest environments only: steer the mock's answer. See Test environments.

None of these is forwarded to the provider. A header that does not follow its rules is refused with 400 and invalid_header, naming the header in param, before anything is charged.

An environment can require a customer on every request (Gateway → Request handling in the dashboard). Then a request without x-hixel-customer is refused with customer_required. A key can also be pinned to one customer: its requests act for that customer, may leave the header out, and are refused with customer_mismatch if they name another.

Response headers#

HeaderValue
x-hixel-request-idThe request's id, req_ and 32 hex characters. It is on the usage record and every event.
x-hixel-modelThe model that answered, by its name in the catalog (an alias resolves to the model it names)
x-hixel-providerThe provider that answered
x-hixel-attemptsHow many provider calls the request took, when more than one
x-hixel-cachehit or miss, when the response cache applied
x-hixel-mocktrue when a test environment's mock answered
x-ratelimit-*Your own rate limits: see Limits

Log x-hixel-request-id with your own request logs. It is the link between a response, its usage record, its webhook events and its trace span.

Streaming#

Ask for a stream the way the format does ("stream": true); the gateway passes the server-sent events through as they arrive. Usage is read off the stream on the way, so a streamed request is metered and billed like any other.

For Chat Completions, the gateway asks the provider for the final usage chunk (stream_options.include_usage) and, if you did not ask for it yourself, removes that chunk before it reaches you, so your stream looks exactly as it would from the provider.

If the client disconnects, the gateway stops reading the provider's stream and records the request with the outcome aborted. Some providers report usage only at the end of a stream; when none was reported, the request is charged at the estimate the gateway reserved for it before calling the provider.

Retries and fallbacks#

The gateway retries a failed provider call and can fall back to another deployment of the same model, within the environment's routing policy (by default at most 3 attempts per request). x-hixel-attempts tells you when that happened. Your own client should still retry on 429 and 503, honouring retry-after when it is present.

Errors#

The gateway's own refusals (a bad key, no balance, a limit reached) use the error envelope. Errors from the provider are passed through with their status and body, rewritten into your format when the request was translated. See Gateway errors.