Documentation menu

Your provider keys

Connect your own OpenAI, Anthropic and Google keys; your requests run on them and the provider bills you.

Your requests run on your own provider accounts. Connect a key per provider to each environment, and every request to that provider's models runs on it: the provider bills you directly, at your prices and quotas, while Hixel meters each request, charges your customers' wallets your price, and enforces their limits.

Connect a key#

In the dashboard, open Gateway → Providers & BYOK in the environment and use Connect a key under "Your provider keys". From code, store it with a project key that has the admin role, naming the environment:

curl -X PUT https://api.hixel.dev/v1/provider_keys/openai \
  -H "Authorization: Bearer $HIXEL_PROJECT_KEY" \
  -H "x-hixel-environment: env_…" \
  -H "Content-Type: application/json" \
  -d '{ "api_key": "sk-proj-…" }'
{
  "id": "pcred_…",
  "environment_id": "env_…",
  "provider": "openai",
  "form": "api_key",
  "last_four": "Xy7Q",
  "label": null,
  "base_url": null,
  "last_check": { "status": "valid", "http_status": 200, "checked_at": "2026-11-26T10:00:00.000Z" },
  "created_at": "2026-11-26T10:00:00.000Z",
  "updated_at": "2026-11-26T10: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 check it again with POST /v1/provider_keys/{provider}/check once you fixed it on the provider's side.

The key is encrypted at rest and never returned by any read: you see its last four characters. Sending PUT again for the same provider replaces it; each environment has its own keys. The key forms are those of customer provider keys: an API key, Bedrock access keys or a Bedrock API key, a Vertex service account's key file, and a base_url for Azure and a custom endpoint.

Other calls:

  • GET /v1/provider_keys lists the environment's keys (never the keys themselves); any key that reads the gateway settings may call it.
  • DELETE /v1/provider_keys/{provider} removes one.

Which key a request runs on#

  1. A customer's own key, when you let customers bring their own and the request names a customer that stored one for the model's provider.
  2. Otherwise your key for the model's provider.
  3. Otherwise Hixel's own key, only where Hixel allowed its keys for your environment by agreement (platform_keys in GET /v1/gateway says allowed). By default it is not_allowed, and such a request is refused.

A key that fails never hands the request to another payer's key on its own. If the provider refuses your key, the request ends with the provider's error, unless Hixel's keys are allowed for the environment and you turned on "Use Hixel's keys when yours fails" (provider_keys.fallback_to_platform_key in PATCH /v1/gateway).

What is charged#

A request on your key is metered and priced exactly as any other: the usage record carries "credential": "tenant", the customer's wallet is charged your price (cost plus your markup) when wallets are on, and spend limits and budgets count it. The provider bills you for the tokens; Hixel charges your organization no provider cost for it. Settings › Billing shows the token spend of every request by whose key ran it.

Failures#

StatuscodeWhen
403provider_key_missingA live request to a model whose provider has no key of yours, and the platform's keys are not allowed
401(the provider's)The provider refused your key; its answer is passed through unchanged
400invalid_requestStoring a key in the wrong form, or a base_url that is not allowed
403project_key_requiredStoring, checking or removing a key with an environment's key instead of a project key
404provider_key_not_foundChecking or removing a provider's key the environment does not have