Documentation menu

Gateway

How the environment's requests are routed, limited, paid for, checked and cached.

OperationMethodSDK
Get the gateway settingsGEThixel.gateway.get
Update the gateway settingsPATCHhixel.gateway.update

Get the gateway settings#

GET/v1/gatewayhixel.gateway.get

The environment's gateway settings, every policy with its defaults filled in.

Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.

Response 200: GatewaySettings

FieldTypeDescription
environment_id requiredstringThe id of an environment (env_…).
revision requiredintegerIncremented on every change; 0 while the environment has the defaults.
standing required"good" | "depleted" | "suspended"Whether your account with the platform lets the environment's traffic through: good, depleted or suspended. Set by the platform, not you.
require_customer requiredbooleanWhether every request must name a customer.
markup_bps requiredintegerAdded to cost when billing customers: billed = cost × (10000 + markup) / 10000.
catalog requiredstring | nullThe platform's catalog the environment draws on; null for none. The platform sets it, not you: a catalog's routes are priced at the catalog's provider prices and run on your own provider keys (or the platform's, where allowed).
allowed_models requiredarray of string | nullModel names and prefix/* patterns a request may use; null allows every model the level above allows.
aliases requiredobjectAlias → model name; an alias never points at another alias.
byok requiredobject
byok.enabled requiredbooleanWhether customers may bring their own provider keys.
byok.fallback_to_platform_key requiredbooleanWhether a request that runs on a customer's own key may go on with the platform's key when the customer's key fails or cannot serve the request, after trying it. Off: the customer's key is the only one used.
byok.providers requiredarray of "openai" | "anthropic" | "azure" | "google" | "groq" | "mistral" | …The providers customers may bring keys for.
platform_keys required"allowed" | "not_allowed"Whether requests may run on the platform's own provider keys for a provider you have connected no key for: allowed or not_allowed. Set by the platform, not you; not_allowed unless the platform agreed otherwise with you.
provider_keys requiredobject
provider_keys.fallback_to_platform_key requiredbooleanWhether a request on your own provider key may go on with the platform's key when yours fails, after trying it. Honoured only while the platform's keys are allowed for the environment. Off: your key is the only one used for its provider.
params requiredobject
params.drop_unsupported requiredbooleanWhether parameters a provider does not support are dropped rather than refused.
routing requiredanyRetries, backoff and timeouts of the environment's requests.
limits requiredanyRate and spend limits of every customer, member and key.
wallet requiredanyWhether a request that names a customer is paid from its wallet.
guardrails requiredanyContent rules on requests and responses.
cache requiredanyThe response cache.

Errors

  • 400
    • invalid_request: The request is malformed or fails validation; param names the field.
    • environment_required: a project key was sent without x-hixel-environment.
  • 401 api_key_required, invalid_api_key, expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired.
  • 403
    • key_inactive: the key was revoked or expired while the request ran, or an environment's key lost the management scope.
    • management_scope_required: the environment's key does not have the management scope.
  • 404 environment_not_found: x-hixel-environment names an environment outside the project key's project, an archived one, or another than the environment key's own.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503 database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/gateway" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Update the gateway settings#

PATCH/v1/gatewayhixel.gateway.update

Changes the fields given, as the dashboard's settings do; each policy given replaces the environment's whole policy, and the change is published to the gateway. Takes a project key with the admin role and x-hixel-environment; an environment's key answers project_key_required (403), as on the project's own endpoints: changing how an environment's requests are routed, limited and paid for is above the keys it serves.

Takes a project key with the admin role, naming the environment in x-hixel-environment; an environment's own key may not. Accepts an Idempotency-Key header: a retry with the same key runs once.

Request body: UpdateGatewaySettingsBody

FieldTypeDescription
require_customerbooleanWhether every request must name a customer.
markup_bpsintegerAdded to cost when billing customers, in basis points: billed = cost × (10000 + markup) / 10000.
allowed_modelsarray of string | nullModel names and prefix/* patterns requests may use; null allows every model.
aliasesobjectAlias → model name, replacing every alias; an alias never points at another.
byokobjectThe fields given change.
byok.enabledbooleanWhether customers may bring their own provider keys.
byok.fallback_to_platform_keybooleanWhether a request on a customer's own key may go on with the platform's key when the customer's key fails.
byok.providersarray of "openai" | "anthropic" | "azure" | "google" | "groq" | "mistral" | …The providers customers may bring keys for.
provider_keysobjectThe fields given change.
provider_keys.fallback_to_platform_keybooleanWhether a request on your own provider key may go on with the platform's key when yours fails; honoured only while platform_keys is allowed.
paramsobject
params.drop_unsupportedbooleanWhether parameters a provider does not support are dropped rather than refused.
routingobjectThe policy as the gateway reads it, in its own snake_case JSON (the shape GET /v1/gateway answers); a field left out takes the gateway's default. It replaces the environment's whole policy. A field out of bounds is invalid_request naming its path in param (limits.customer.spend.1.id).
limitsobjectThe policy as the gateway reads it, in its own snake_case JSON (the shape GET /v1/gateway answers); a field left out takes the gateway's default. It replaces the environment's whole policy. A field out of bounds is invalid_request naming its path in param (limits.customer.spend.1.id).
walletobjectThe policy as the gateway reads it, in its own snake_case JSON (the shape GET /v1/gateway answers); a field left out takes the gateway's default. It replaces the environment's whole policy. A field out of bounds is invalid_request naming its path in param (limits.customer.spend.1.id).
guardrailsobjectThe policy as the gateway reads it, in its own snake_case JSON (the shape GET /v1/gateway answers); a field left out takes the gateway's default. It replaces the environment's whole policy. A field out of bounds is invalid_request naming its path in param (limits.customer.spend.1.id).
cacheobjectThe policy as the gateway reads it, in its own snake_case JSON (the shape GET /v1/gateway answers); a field left out takes the gateway's default. It replaces the environment's whole policy. A field out of bounds is invalid_request naming its path in param (limits.customer.spend.1.id).

Response 200: GatewaySettings

FieldTypeDescription
environment_id requiredstringThe id of an environment (env_…).
revision requiredintegerIncremented on every change; 0 while the environment has the defaults.
standing required"good" | "depleted" | "suspended"Whether your account with the platform lets the environment's traffic through: good, depleted or suspended. Set by the platform, not you.
require_customer requiredbooleanWhether every request must name a customer.
markup_bps requiredintegerAdded to cost when billing customers: billed = cost × (10000 + markup) / 10000.
catalog requiredstring | nullThe platform's catalog the environment draws on; null for none. The platform sets it, not you: a catalog's routes are priced at the catalog's provider prices and run on your own provider keys (or the platform's, where allowed).
allowed_models requiredarray of string | nullModel names and prefix/* patterns a request may use; null allows every model the level above allows.
aliases requiredobjectAlias → model name; an alias never points at another alias.
byok requiredobject
byok.enabled requiredbooleanWhether customers may bring their own provider keys.
byok.fallback_to_platform_key requiredbooleanWhether a request that runs on a customer's own key may go on with the platform's key when the customer's key fails or cannot serve the request, after trying it. Off: the customer's key is the only one used.
byok.providers requiredarray of "openai" | "anthropic" | "azure" | "google" | "groq" | "mistral" | …The providers customers may bring keys for.
platform_keys required"allowed" | "not_allowed"Whether requests may run on the platform's own provider keys for a provider you have connected no key for: allowed or not_allowed. Set by the platform, not you; not_allowed unless the platform agreed otherwise with you.
provider_keys requiredobject
provider_keys.fallback_to_platform_key requiredbooleanWhether a request on your own provider key may go on with the platform's key when yours fails, after trying it. Honoured only while the platform's keys are allowed for the environment. Off: your key is the only one used for its provider.
params requiredobject
params.drop_unsupported requiredbooleanWhether parameters a provider does not support are dropped rather than refused.
routing requiredanyRetries, backoff and timeouts of the environment's requests.
limits requiredanyRate and spend limits of every customer, member and key.
wallet requiredanyWhether a request that names a customer is paid from its wallet.
guardrails requiredanyContent rules on requests and responses.
cache requiredanyThe response cache.

Errors

  • 400
    • invalid_parameter, alias_chain, unknown_catalog: The request is malformed or fails validation; param names the field.
    • invalid_idempotency_key: an Idempotency-Key is 1 to 255 characters of visible ASCII.
    • environment_required: the project key was sent without x-hixel-environment.
    • invalid_payload, malformed_body, body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
  • 401 api_key_required, invalid_api_key, expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired.
  • 403
    • key_inactive: the project key was revoked or expired while the request ran.
    • project_key_required: an environment's key was sent; this endpoint takes a project key.
    • role_not_allowed: the project key's member role does not allow this; it takes admin.
  • 404 environment_not_found: x-hixel-environment names an environment outside the project key's project, or an archived one.
  • 409
    • project_archived: This project is archived.
    • environment_archived: This environment is archived.
    • idempotency_key_reused, idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503
    • database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
    • database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X PATCH "https://api.hixel.dev/v1/gateway" \
  -H "Authorization: Bearer $HIXEL_PROJECT_KEY" \
  -H "x-hixel-environment: env_123" \
  -H "Content-Type: application/json" \
  -d '{
    "require_customer": true
  }'