Overview
This endpoint generates a short-lived, single-use token for the streaming endpoint. Tokens are stored securely in Redis and automatically expire after their TTL period. This is step 1 of the two-step streaming flow.Endpoint
- HTTP Method: GET
-
URL:
/api/v1/token
Features
Single-Use Security
Each token can only be used once — it is deleted from Redis after the first stream request.
Configurable TTL
Set a custom time-to-live between 1 and 300 seconds (default: 60s).
Bearer Key Auth
Tokens are generated under your API key — credits are charged to your organization.
Rate Limited
Server-derived rate limiting ensures fair usage across all consumers.
Authentication
Requires a Bearer token in theAuthorization header.
Request
Query Parameters| Name | Required | Type | Default | Description |
|---|---|---|---|---|
| ttl | No | number | 60 | Token lifetime in seconds (1–300) |
Example Request
Response
A successful response returns the token and its TTL:| Field | Type | Description |
|---|---|---|
| success | boolean | Always true on success |
| token | string | The single-use stream token (format: pub_tok_...) |
| ttl | number | Token lifetime in seconds |
| Header | Description |
|---|---|
| x-ratelimit-limit | Your rate limit per window |
| x-ratelimit-remaining | Remaining requests in window |
Error Responses
401 Unauthorized
401 Unauthorized
402 Payment Required
402 Payment Required
No credits remaining on the account.
429 Too Many Requests
429 Too Many Requests
Rate limit exceeded.
500 Internal Server Error
500 Internal Server Error
Token generation failed.
Code Examples
Python
Python
Node.js
Node.js
cURL
cURL
Additional Notes
- Single-Use: The token is deleted from Redis after its first use in a stream request.
- Auto-Expiry: Tokens expire automatically after the TTL period — unused tokens do not count against your API quota.
- Next Step: Use this token as a query parameter on the Stream Workflow endpoint to start receiving real-time responses.
