Documentation menu

Customer provider keys

Let a customer run its requests on its own OpenAI, Anthropic or other provider key.

Some customers want to use their own provider account: their negotiated prices, their data agreement, their quota. With bring-your-own-key (BYOK), you store a customer's provider key with Hixel, and that customer's requests run on it. You still get the usage record, the limits and the model controls; the customer's wallet is not charged.

Turn it on#

BYOK is off by default. In the dashboard, under Gateway → Providers & BYOK, turn on “Let customers bring their own keys” and choose the providers customers may bring keys for; or from code, send {"byok": {"enabled": true, "providers": ["openai"]}} to PATCH /v1/gateway with a project key. GET /v1/gateway reads the current setting (byok.enabled, byok.providers).

There is one more switch there, “Use Hixel's keys when the customer's key fails” (byok.fallback_to_platform_key). Off, the default, a request on a customer's key never moves to the environment's keys: if the customer's key fails, the request fails. On, a request that the customer's key cannot serve continues on your own provider key (or Hixel's, where allowed) and is paid as any other request.

Store a customer's key#

curl -X PUT https://api.hixel.dev/v1/customers/org_42/provider_keys/openai \
  -H "Authorization: Bearer $HIXEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "api_key": "sk-proj-…" }'
{
  "id": "pcred_…",
  "customer": "org_42",
  "provider": "openai",
  "form": "api_key",
  "last_four": "Xy7Q",
  "label": null,
  "base_url": null,
  "last_check": { "status": "valid", "http_status": 200, "checked_at": "2026-11-25T10:00:00.000Z" },
  "created_at": "2026-11-25T10:00:00.000Z",
  "updated_at": "2026-11-25T10:00:00.000Z"
}

The key is checked with the provider before it is stored, with the cheapest call the provider answers (listing its models), and the result is in last_check: valid, rejected (the provider refused it), failed (the provider could not be reached) or unchecked (Amazon Bedrock, Google Vertex AI, Azure, Perplexity and Cohere are not checked). A key the check finds wrong is stored all the same, so you can tell your customer at once. A key stored before keys were checked reads unchecked, with checked_at null.

The key is encrypted at rest and never returned by any read: you see only its last four characters. Sending PUT again for the same provider replaces it.

Provider valueNotes
openai, anthropic, google, groq, mistral, together, fireworks, deepseek, xai, openrouter, perplexity, cerebras, cohereapi_key is the provider's API key
azure, customNeed base_url too: an https:// URL on a public host name
bedrockapi_key is a Bedrock API key, or AWS access keys as JSON text: {"access_key_id","secret_access_key","session_token"?}
vertexapi_key is the service account's JSON key file, as Google issues it

base_url (optional for the others) sends the key to that URL instead of the provider's default. It must be https:// on a public host name, without user information, query or fragment; an IP address or a private name such as localhost is refused.

Other calls:

  • GET /v1/customers/{external_id}/provider_keys lists the customer's keys (never the keys themselves), each with its last check.
  • POST /v1/customers/{external_id}/provider_keys/{provider}/check checks the stored key with the provider again and records the result in last_check.
  • DELETE /v1/customers/{external_id}/provider_keys/{provider} removes one.

Which requests use it#

A request uses the customer's key when the environment allows BYOK for the provider, the request names the customer, and the customer holds a key for the provider of the requested model. Then:

  • the request runs on the customer's key only (and on your own key after it only with fallback on);
  • the usage record says "payer": "byok" and "credential": "customer", with billed_micros "0"; cost_micros is the provider cost at catalog prices, for your information;
  • the customer's wallet is not charged, but its spend limits count that cost, and its rate limits and model allowlist apply as usual;
  • errors from the provider are returned as the provider sent them, and the provider's own rate-limit headers are passed through;
  • the request reaches the provider as your client sent it, unless you keep state out of the customer's account (below). Limits are checked while the request runs unless you check them first.

A request that names a customer without a key for the model's provider, where customers may bring keys for it, is refused with 403 and customer_provider_key_missing, the provider in param: show your user a way to add their key. A request that names no customer gets provider_key_missing (or provider_key_required for a model only a customer's key serves).

Keeping no state in the customer's account#

By default nothing is changed in a request on a customer's key, so a request can keep state in the customer's provider account: OpenAI's Responses API stores every response unless the request sends store: false. To rule that out for every request of the environment, turn on “Keep no state in customers' provider accounts” under Gateway → Providers & BYOK, or send {"byok": {"stored_state": "refused"}} to PATCH /v1/gateway. Then, on a customer's key:

  • OpenAI's and Azure's Responses API get store: false and background: false, whatever the request says or leaves out;
  • a request that asks the provider to keep or reuse state is refused with 400 and unsupported_parameter, the field in param: previous_response_id, conversation, background: true, a stored prompt, an item_reference input item, store: true (on the Responses and Chat Completions APIs alike), prompt_cache_options.comparison_response_id, and Anthropic's container and thread;
  • nothing else changes: hosted tools, service tiers, prompt_cache_key and the output limit reach the provider as sent, and Responses' context_management (a compaction billed by the provider, not state) passes too.

Anthropic's Messages API and Google's Gemini have no field that stores a response, so nothing is written on them; a request translated for Gemini or Bedrock is judged on what the client sent. "allowed" is the default.

Failures#

StatuscodeWhen
409byok_disabledStoring a key when the environment does not allow BYOK
409byok_provider_not_allowedStoring a key for a provider the environment does not allow
400invalid_requestA base_url that is not allowed, or a key in the wrong form
403provider_key_requiredA request for a model only a customer's key can serve, without one
403customer_provider_key_missingA request naming a customer that has no key for the model's provider, where customers may bring one
400unsupported_parameterA parameter that keeps state, where the environment refuses stored state
404provider_key_not_foundChecking or removing a provider's key the customer does not have