Keys
The keys of the calling key's environment.
A key with the inference scope calls models through the gateway; one with the management scope calls this API. A key's secret is shown once, when it is created or rotated, and stored only as a hash.
| Operation | Method | SDK |
|---|---|---|
| List keys | GET | hixel.keys.list |
| Create a key | POST | hixel.keys.create |
| Get a key | GET | hixel.keys.get |
| Update a key | PATCH | hixel.keys.update |
| Revoke a key | POST | hixel.keys.revoke |
| Rotate a key | POST | hixel.keys.rotate |
List keys#
A page of the environment's keys, newest first, revoked and expired ones included.
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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
cursor | query | string | The next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it. |
limit | query | integer | How many items the page holds: an integer from 1 to 100; 50 when left out. |
Response 200: KeyList
| Field | Type | Description |
|---|---|---|
data required | array of Key | |
data[].id required | string | The id of a key (key_…); never the key itself. |
data[].organization_id required | string | The id of your organization (org_…). |
data[].project_id required | string | The id of a project (proj_…). |
data[].environment_id required | string | The id of an environment (env_…). |
data[].name required | string | |
data[].last_four required | string | The key's last four characters, to tell keys apart. |
data[].status required | "active" | "expired" | "revoked" | Where the key stands; expired is an unrevoked key past its expiry. |
data[].scopes required | array of "inference" | "management" | What the key may be used for: inference (calling models through the gateway), management (this API), or both. |
data[].customer required | string | null | Your id for the customer the key is pinned to; null for none. |
data[].member required | string | null | Your id for the member the key is pinned to; null for none. |
data[].allowed_models required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
data[].tags required | array of string | Free labels, up to 64 characters of visible ASCII each. |
data[].expires_at required | string | null | When the key stops working; null for never. |
data[].revoked_at required | string | null | When the key was revoked; null while it is not. |
data[].created_by_user_id required | string | null | The person who created the key in the dashboard; null when a key created it, through this API. |
data[].created_at required | string (date-time) | |
data[].updated_at required | string (date-time) | |
next_cursor required | string | null | Pass back as cursor for the next page; null on the last page. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_cursor: The cursor is not one this list gave.environment_required: a project key was sent withoutx-hixel-environment.invalid_query: 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 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/keys" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.keys.list()) {
console.log(item);
}Create a key#
Creates a key in the calling key's environment and answers its secret, which is never shown again. A key acting through this API cannot give a key more reach than its own (key_reach_exceeded): a scope it lacks, a model its allowlist does not cover, or a later expiry.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Request body: CreateKeyBody
| Field | Type | Description |
|---|---|---|
name required | string | A name to tell the key apart. |
scopes | array of "inference" | "management" | inference, management or both; ["inference"] when left out. A key pinned to a customer cannot have management. |
customer | string | Pins the key to this customer, by your id for it: the key then acts for that customer only. |
member | string | Pins the key to this member of the customer, by your id. |
allowed_models | array of string | Model names and prefix/* patterns the key may use, within what the environment allows; every model it allows when left out. |
tags | array of string | Free labels, up to 64 characters of visible ASCII each. |
expires_at | string (date-time) | When the key stops working; never when left out. |
Response 200: CreatedKey
| Field | Type | Description |
|---|---|---|
key required | Key | A key of the environment, as every read shows it: never the key itself. |
key.id required | string | The id of a key (key_…); never the key itself. |
key.organization_id required | string | The id of your organization (org_…). |
key.project_id required | string | The id of a project (proj_…). |
key.environment_id required | string | The id of an environment (env_…). |
key.name required | string | |
key.last_four required | string | The key's last four characters, to tell keys apart. |
key.status required | "active" | "expired" | "revoked" | Where the key stands; expired is an unrevoked key past its expiry. |
key.scopes required | array of "inference" | "management" | What the key may be used for: inference (calling models through the gateway), management (this API), or both. |
key.customer required | string | null | Your id for the customer the key is pinned to; null for none. |
key.member required | string | null | Your id for the member the key is pinned to; null for none. |
key.allowed_models required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
key.tags required | array of string | Free labels, up to 64 characters of visible ASCII each. |
key.expires_at required | string | null | When the key stops working; null for never. |
key.revoked_at required | string | null | When the key was revoked; null while it is not. |
key.created_by_user_id required | string | null | The person who created the key in the dashboard; null when a key created it, through this API. |
key.created_at required | string (date-time) | |
key.updated_at required | string (date-time) | |
secret required | string | null | The key itself, hx_sk_… (hx_sk_test_… in a test environment): store it now, it is never shown again. null in a response replayed for an Idempotency-Key. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.pinned_key_management: A key pinned to a customer cannot have the management scope.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a 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 key was revoked or expired while the request ran, or an environment's key lost themanagementscope.key_reach_exceededmanagement_scope_required: the environment's key does not have themanagementscope.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, an archived one, or another than the environment key's own. - 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 POST "https://api.hixel.dev/v1/keys" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc."
}'const createdKey = await hixel.keys.create({
name: "Acme Inc.",
});Get a key#
The key, never its secret; key_not_found when the environment has none by this id.
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.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The key's id (key_…). |
Response 200: Key
| Field | Type | Description |
|---|---|---|
id required | string | The id of a key (key_…); never the key itself. |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The id of an environment (env_…). |
name required | string | |
last_four required | string | The key's last four characters, to tell keys apart. |
status required | "active" | "expired" | "revoked" | Where the key stands; expired is an unrevoked key past its expiry. |
scopes required | array of "inference" | "management" | What the key may be used for: inference (calling models through the gateway), management (this API), or both. |
customer required | string | null | Your id for the customer the key is pinned to; null for none. |
member required | string | null | Your id for the member the key is pinned to; null for none. |
allowed_models required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
tags required | array of string | Free labels, up to 64 characters of visible ASCII each. |
expires_at required | string | null | When the key stops working; null for never. |
revoked_at required | string | null | When the key was revoked; null while it is not. |
created_by_user_id required | string | null | The person who created the key in the dashboard; null when a key created it, through this API. |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: 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 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
key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.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/keys/key_123" \
-H "Authorization: Bearer $HIXEL_API_KEY"const key = await hixel.keys.get("key_123");Update a key#
Changes the fields given. A revoked or expired key cannot be changed. A key acting through this API cannot give a key more reach than its own (key_reach_exceeded): a scope it lacks, a model its allowlist does not cover, or a later expiry.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The key's id (key_…). |
Request body: UpdateKeyBody
| Field | Type | Description |
|---|---|---|
name | string | |
scopes | array of "inference" | "management" | |
allowed_models | array of string | null | The models the key may use; null allows every model the environment allows. |
tags | array of string | Replaces the key's tags. |
expires_at | string | null | When the key stops working; null for never. |
Response 200: Key
| Field | Type | Description |
|---|---|---|
id required | string | The id of a key (key_…); never the key itself. |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The id of an environment (env_…). |
name required | string | |
last_four required | string | The key's last four characters, to tell keys apart. |
status required | "active" | "expired" | "revoked" | Where the key stands; expired is an unrevoked key past its expiry. |
scopes required | array of "inference" | "management" | What the key may be used for: inference (calling models through the gateway), management (this API), or both. |
customer required | string | null | Your id for the customer the key is pinned to; null for none. |
member required | string | null | Your id for the member the key is pinned to; null for none. |
allowed_models required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
tags required | array of string | Free labels, up to 64 characters of visible ASCII each. |
expires_at required | string | null | When the key stops working; null for never. |
revoked_at required | string | null | When the key was revoked; null while it is not. |
created_by_user_id required | string | null | The person who created the key in the dashboard; null when a key created it, through this API. |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.pinned_key_management: A key pinned to a customer cannot have the management scope.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,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 key was revoked or expired while the request ran, or an environment's key lost themanagementscope.key_reach_exceededmanagement_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.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.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.key_revoked: This key is revoked.key_expired: This key has expired.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/keys/key_123" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc."
}'const key = await hixel.keys.update("key_123", {
name: "Acme Inc.",
});Revoke a key#
The key stops working. Revoking cannot be undone.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The key's id (key_…). |
Response 200: Key
| Field | Type | Description |
|---|---|---|
id required | string | The id of a key (key_…); never the key itself. |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The id of an environment (env_…). |
name required | string | |
last_four required | string | The key's last four characters, to tell keys apart. |
status required | "active" | "expired" | "revoked" | Where the key stands; expired is an unrevoked key past its expiry. |
scopes required | array of "inference" | "management" | What the key may be used for: inference (calling models through the gateway), management (this API), or both. |
customer required | string | null | Your id for the customer the key is pinned to; null for none. |
member required | string | null | Your id for the member the key is pinned to; null for none. |
allowed_models required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
tags required | array of string | Free labels, up to 64 characters of visible ASCII each. |
expires_at required | string | null | When the key stops working; null for never. |
revoked_at required | string | null | When the key was revoked; null while it is not. |
created_by_user_id required | string | null | The person who created the key in the dashboard; null when a key created it, through this API. |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: 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 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.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.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.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.key_revoked: This key is revoked.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 POST "https://api.hixel.dev/v1/keys/key_123/revoke" \
-H "Authorization: Bearer $HIXEL_API_KEY"const key = await hixel.keys.revoke("key_123");Rotate a key#
Creates the key's successor and answers its secret, which is never shown again. The old key keeps working for grace_period_seconds (none by default, at most 30 days). The body may be empty. A key acting through this API cannot give a key more reach than its own (key_reach_exceeded): a scope it lacks, a model its allowlist does not cover, or a later expiry.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The key's id (key_…). |
Request body: RotateKeyBody
| Field | Type | Description |
|---|---|---|
grace_period_seconds | integer | How long the old key keeps working, in seconds: 0 (the default) to 30 days. |
Response 200: RotatedKey
| Field | Type | Description |
|---|---|---|
previous required | Key | A key of the environment, as every read shows it: never the key itself. |
previous.id required | string | The id of a key (key_…); never the key itself. |
previous.organization_id required | string | The id of your organization (org_…). |
previous.project_id required | string | The id of a project (proj_…). |
previous.environment_id required | string | The id of an environment (env_…). |
previous.name required | string | |
previous.last_four required | string | The key's last four characters, to tell keys apart. |
previous.status required | "active" | "expired" | "revoked" | Where the key stands; expired is an unrevoked key past its expiry. |
previous.scopes required | array of "inference" | "management" | What the key may be used for: inference (calling models through the gateway), management (this API), or both. |
previous.customer required | string | null | Your id for the customer the key is pinned to; null for none. |
previous.member required | string | null | Your id for the member the key is pinned to; null for none. |
previous.allowed_models required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
previous.tags required | array of string | Free labels, up to 64 characters of visible ASCII each. |
previous.expires_at required | string | null | When the key stops working; null for never. |
previous.revoked_at required | string | null | When the key was revoked; null while it is not. |
previous.created_by_user_id required | string | null | The person who created the key in the dashboard; null when a key created it, through this API. |
previous.created_at required | string (date-time) | |
previous.updated_at required | string (date-time) | |
key required | Key | A key of the environment, as every read shows it: never the key itself. |
key.id required | string | The id of a key (key_…); never the key itself. |
key.organization_id required | string | The id of your organization (org_…). |
key.project_id required | string | The id of a project (proj_…). |
key.environment_id required | string | The id of an environment (env_…). |
key.name required | string | |
key.last_four required | string | The key's last four characters, to tell keys apart. |
key.status required | "active" | "expired" | "revoked" | Where the key stands; expired is an unrevoked key past its expiry. |
key.scopes required | array of "inference" | "management" | What the key may be used for: inference (calling models through the gateway), management (this API), or both. |
key.customer required | string | null | Your id for the customer the key is pinned to; null for none. |
key.member required | string | null | Your id for the member the key is pinned to; null for none. |
key.allowed_models required | array of string | null | Model names and prefix/* patterns a request may use; null allows every model the level above allows. |
key.tags required | array of string | Free labels, up to 64 characters of visible ASCII each. |
key.expires_at required | string | null | When the key stops working; null for never. |
key.revoked_at required | string | null | When the key was revoked; null while it is not. |
key.created_by_user_id required | string | null | The person who created the key in the dashboard; null when a key created it, through this API. |
key.created_at required | string (date-time) | |
key.updated_at required | string (date-time) | |
secret required | string | null | The key itself, hx_sk_… (hx_sk_test_… in a test environment): store it now, it is never shown again. null in a response replayed for an Idempotency-Key. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,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 key was revoked or expired while the request ran, or an environment's key lost themanagementscope.key_reach_exceededmanagement_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
key_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.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.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.key_revoked: This key is revoked.key_expired: This key has expired.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 POST "https://api.hixel.dev/v1/keys/key_123/rotate" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"grace_period_seconds": 3600
}'const rotatedKey = await hixel.keys.rotate("key_123", {
grace_period_seconds: 3600,
});