Gateway
How the environment's requests are routed, limited, paid for, checked and cached.
| Operation | Method | SDK |
|---|---|---|
| Get the gateway settings | GET | hixel.gateway.get |
| Update the gateway settings | PATCH | hixel.gateway.update |
Get the gateway settings#
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
| Field | Type | Description |
|---|---|---|
environment_id required | string | The id of an environment (env_…). |
revision required | integer | Incremented 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 required | boolean | Whether every request must name a customer. |
markup_bps required | integer | Added to cost when billing customers: billed = cost × (10000 + markup) / 10000. |
catalog required | string | null | The 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 required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
aliases required | object | Alias → model name; an alias never points at another alias. |
byok required | object | |
byok.enabled required | boolean | Whether customers may bring their own provider keys. |
byok.fallback_to_platform_key required | boolean | Whether 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 required | array 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 required | object | |
provider_keys.fallback_to_platform_key required | boolean | Whether 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 required | object | |
params.drop_unsupported required | boolean | Whether parameters a provider does not support are dropped rather than refused. |
routing required | any | Retries, backoff and timeouts of the environment's requests. |
limits required | any | Rate and spend limits of every customer, member and key. |
wallet required | any | Whether a request that names a customer is paid from its wallet. |
guardrails required | any | Content rules on requests and responses. |
cache required | any | The response cache. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-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 themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
environment_not_found:x-hixel-environmentnames 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"const gatewaySettings = await hixel.gateway.get();Update the gateway settings#
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
| Field | Type | Description |
|---|---|---|
require_customer | boolean | Whether every request must name a customer. |
markup_bps | integer | Added to cost when billing customers, in basis points: billed = cost × (10000 + markup) / 10000. |
allowed_models | array of string | null | Model names and prefix/* patterns requests may use; null allows every model. |
aliases | object | Alias → model name, replacing every alias; an alias never points at another. |
byok | object | The fields given change. |
byok.enabled | boolean | Whether customers may bring their own provider keys. |
byok.fallback_to_platform_key | boolean | Whether a request on a customer's own key may go on with the platform's key when the customer's key fails. |
byok.providers | array of "openai" | "anthropic" | "azure" | "google" | "groq" | "mistral" | … | The providers customers may bring keys for. |
provider_keys | object | The fields given change. |
provider_keys.fallback_to_platform_key | boolean | Whether 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. |
params | object | |
params.drop_unsupported | boolean | Whether parameters a provider does not support are dropped rather than refused. |
routing | object | The 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). |
limits | object | The 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). |
wallet | object | The 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). |
guardrails | object | The 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). |
cache | object | The 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
| Field | Type | Description |
|---|---|---|
environment_id required | string | The id of an environment (env_…). |
revision required | integer | Incremented 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 required | boolean | Whether every request must name a customer. |
markup_bps required | integer | Added to cost when billing customers: billed = cost × (10000 + markup) / 10000. |
catalog required | string | null | The 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 required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
aliases required | object | Alias → model name; an alias never points at another alias. |
byok required | object | |
byok.enabled required | boolean | Whether customers may bring their own provider keys. |
byok.fallback_to_platform_key required | boolean | Whether 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 required | array 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 required | object | |
provider_keys.fallback_to_platform_key required | boolean | Whether 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 required | object | |
params.drop_unsupported required | boolean | Whether parameters a provider does not support are dropped rather than refused. |
routing required | any | Retries, backoff and timeouts of the environment's requests. |
limits required | any | Rate and spend limits of every customer, member and key. |
wallet required | any | Whether a request that names a customer is paid from its wallet. |
guardrails required | any | Content rules on requests and responses. |
cache required | any | The response cache. |
Errors
- 400
invalid_parameter,alias_chain,unknown_catalog: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: the project key was sent withoutx-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'smemberrole does not allow this; it takesadmin.
- 404
environment_not_found:x-hixel-environmentnames 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
}'const gatewaySettings = await hixel.environment("env_123").gateway.update({
require_customer: true,
});