Create gateway token key
Create gateway token key within the authenticated Telnyx account. Foreign and unknown resource IDs return the same 404 response. The token secret is returned only on the original create response. A replay returns metadata without the secret. Provisioning is advisory; ready is not a guarantee of inference availability.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const TokenKey = await client.llmTokenGateway.tokenKeys.create({
name: 'name',
token_group_id: 'token_group_id',
'Idempotency-Key': 'idempotency-key',
});
console.log(TokenKey.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
token_key_created = client.llm_token_gateway.token_keys.create(
name="name",
token_group_id="token_group_id",
idempotency_key="idempotency-key",
)
print(token_key_created.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
tokenKey, err := client.LlmTokenGateway.TokenKeys.New(
context.TODO(),
telnyx.LlmTokenGatewayTokenKeyNewParams{
Name: "name",
TokenGroupID: "token_group_id",
IdempotencyKey: "idempotency-key",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", tokenKey.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.llmTokenGateway.tokenKeys.TokenKeyCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TokenKeyCreateParams params = TokenKeyCreateParams.builder()
.name("name")
.tokenGroupId("token_group_id")
.idempotencyKey("idempotency-key")
.build();
var response = client.llmTokenGateway().tokenKeys().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
token_key_created = telnyx.llm_token_gateway.token_keys.create(name: "name", token_group_id: "token_group_id", idempotency_key: "idempotency-key")
puts(token_key_created)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$token_key_created = $client->llmTokenGateway->tokenKeys->create(
name: 'name',
token_group_id: 'token_group_id',
idempotencyKey: 'idempotency-key',
);
var_dump($token_key_created);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx llm-token-gateway:token-keys create \
--api-key 'My API Key' \
--name name \
--token-group-id token_group_id \
--idempotency-key idempotency-keycurl --request POST \
--url https://api.telnyx.com/v2/llm_token_gateway/token_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "support-service",
"token_group_id": "11111111-1111-4111-8111-111111111111",
"max_parallel_requests": 5
}
'{
"data": {
"record_type": "token_key",
"id": "11111111-1111-4111-8111-111111111111",
"created_at": "2026-10-07T08:00:00Z",
"updated_at": "2026-10-07T08:00:00Z",
"version": 1,
"name": "support-backend",
"token_group_id": "11111111-1111-4111-8111-111111111111",
"token_user_id": null,
"max_budget": 1000,
"budget_duration": "1d",
"tpm_limit": 10000000,
"rpm_limit": 6000,
"allowed_models": null,
"expires_at": null,
"blocked": false,
"required_end_user_id": false,
"spend": 0,
"reserved_spend": 0,
"budget_started_at": null,
"resets_at": null,
"max_parallel_requests": 5,
"provisioning": "ready"
}
}{
"data": {
"record_type": "token_key",
"id": "11111111-1111-4111-8111-111111111111",
"created_at": "2026-10-07T08:00:00Z",
"updated_at": "2026-10-07T08:00:00Z",
"version": 1,
"name": "support-backend",
"token_group_id": "11111111-1111-4111-8111-111111111111",
"token_user_id": null,
"max_budget": 1000,
"budget_duration": "1d",
"tpm_limit": 10000000,
"rpm_limit": 6000,
"allowed_models": null,
"expires_at": null,
"blocked": false,
"required_end_user_id": false,
"spend": 0,
"reserved_spend": 0,
"budget_started_at": null,
"resets_at": null,
"token": "ltg_sk_SYNTHETIC_EXAMPLE_NOT_A_VALID_CREDENTIAL",
"max_parallel_requests": 5,
"provisioning": "ready"
}
}{
"errors": [
{
"code": "invalid_request",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "unauthorized",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "unauthorized",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "not_found",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "idempotency_conflict",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "precondition_failed",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "precondition_required",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "rate_limit_exceeded",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "invalid_request",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "enforcement_unavailable",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "invalid_request",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}Authorizations
Management-only Telnyx account credential.
Headers
24h, scoped by account+method+path. Same key/body returns same outcome; changed body 409; in-progress 409 with Retry-After. Token-create replay returns 200 metadata WITHOUT secret.
1 - 128^[A-Za-z0-9_-]+$Body
1 - 256^[^\u0000-\u001f\u007f]+$Optional maximum concurrent reserved/dispatched cache misses across replicas. Null means no concurrency cap. Cache hits do not consume slots; unknown usage retains its budget hold without a slot.
1 <= x <= 1000Omitted or null defaults to the maximum (1000 USD) (on a blocked key, null is kept until the key is unblocked); a value below the minimum (0.000001 USD) or above the maximum is rejected with 400 limit_out_of_range; a malformed value (negative, wrong type or precision) is 400 invalid_request. Block the key (blocked: true) to deny it; blocking is always accepted. The default budget is lifetime unless budget_duration is set. Budgets and spend are an enforcement guard computed at one flat placeholder rate for every Telnyx-hosted model (rate_version telnyx-reference-v1: 5 USD per million input and 15 USD per million output tokens), not the customer's bill; Telnyx Inference usage is billed separately at the model's actual price.
0.000001 <= x <= 1000Must be a multiple of 0.0000011d, 7d, 30d, null Omitted or null defaults to the maximum (10000000) (on a blocked key, null is kept until the key is unblocked); a value below the minimum (1) or above the maximum is rejected with 400 limit_out_of_range; a malformed value (negative, wrong type or precision) is 400 invalid_request. Block the key (blocked: true) to deny it; blocking is always accepted.
1 <= x <= 10000000Omitted or null defaults to the maximum (6000) (on a blocked key, null is kept until the key is unblocked); a value below the minimum (1) or above the maximum is rejected with 400 limit_out_of_range; a malformed value (negative, wrong type or precision) is 400 invalid_request. Block the key (blocked: true) to deny it; blocking is always accepted.
1 <= x <= 600010001 - 256^[^\u0000-\u001f\u007f]+$Require a nonempty caller-asserted end-user ID; not proof of identity.
Response
Idempotency replay: metadata only; lost create response requires revoke/new create.
Show child attributes
Show child attributes
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const TokenKey = await client.llmTokenGateway.tokenKeys.create({
name: 'name',
token_group_id: 'token_group_id',
'Idempotency-Key': 'idempotency-key',
});
console.log(TokenKey.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
token_key_created = client.llm_token_gateway.token_keys.create(
name="name",
token_group_id="token_group_id",
idempotency_key="idempotency-key",
)
print(token_key_created.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
tokenKey, err := client.LlmTokenGateway.TokenKeys.New(
context.TODO(),
telnyx.LlmTokenGatewayTokenKeyNewParams{
Name: "name",
TokenGroupID: "token_group_id",
IdempotencyKey: "idempotency-key",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", tokenKey.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.llmTokenGateway.tokenKeys.TokenKeyCreateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
TokenKeyCreateParams params = TokenKeyCreateParams.builder()
.name("name")
.tokenGroupId("token_group_id")
.idempotencyKey("idempotency-key")
.build();
var response = client.llmTokenGateway().tokenKeys().create(params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
token_key_created = telnyx.llm_token_gateway.token_keys.create(name: "name", token_group_id: "token_group_id", idempotency_key: "idempotency-key")
puts(token_key_created)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$token_key_created = $client->llmTokenGateway->tokenKeys->create(
name: 'name',
token_group_id: 'token_group_id',
idempotencyKey: 'idempotency-key',
);
var_dump($token_key_created);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx llm-token-gateway:token-keys create \
--api-key 'My API Key' \
--name name \
--token-group-id token_group_id \
--idempotency-key idempotency-keycurl --request POST \
--url https://api.telnyx.com/v2/llm_token_gateway/token_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "support-service",
"token_group_id": "11111111-1111-4111-8111-111111111111",
"max_parallel_requests": 5
}
'{
"data": {
"record_type": "token_key",
"id": "11111111-1111-4111-8111-111111111111",
"created_at": "2026-10-07T08:00:00Z",
"updated_at": "2026-10-07T08:00:00Z",
"version": 1,
"name": "support-backend",
"token_group_id": "11111111-1111-4111-8111-111111111111",
"token_user_id": null,
"max_budget": 1000,
"budget_duration": "1d",
"tpm_limit": 10000000,
"rpm_limit": 6000,
"allowed_models": null,
"expires_at": null,
"blocked": false,
"required_end_user_id": false,
"spend": 0,
"reserved_spend": 0,
"budget_started_at": null,
"resets_at": null,
"max_parallel_requests": 5,
"provisioning": "ready"
}
}{
"data": {
"record_type": "token_key",
"id": "11111111-1111-4111-8111-111111111111",
"created_at": "2026-10-07T08:00:00Z",
"updated_at": "2026-10-07T08:00:00Z",
"version": 1,
"name": "support-backend",
"token_group_id": "11111111-1111-4111-8111-111111111111",
"token_user_id": null,
"max_budget": 1000,
"budget_duration": "1d",
"tpm_limit": 10000000,
"rpm_limit": 6000,
"allowed_models": null,
"expires_at": null,
"blocked": false,
"required_end_user_id": false,
"spend": 0,
"reserved_spend": 0,
"budget_started_at": null,
"resets_at": null,
"token": "ltg_sk_SYNTHETIC_EXAMPLE_NOT_A_VALID_CREDENTIAL",
"max_parallel_requests": 5,
"provisioning": "ready"
}
}{
"errors": [
{
"code": "invalid_request",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "unauthorized",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "unauthorized",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "not_found",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "idempotency_conflict",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "precondition_failed",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "precondition_required",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "rate_limit_exceeded",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "invalid_request",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "enforcement_unavailable",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}{
"errors": [
{
"code": "invalid_request",
"title": "Request could not be completed",
"detail": "Check the request and the documented handling for this error.",
"meta": {
"request_id": "11111111-1111-4111-8111-111111111111"
}
}
]
}