> ## Documentation Index
> Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate streaming token

> Generates a temporary authentication token for Real-time STT. Send `product` set to `streaming`. See [Authenticate with a temporary token](https://www.assemblyai.com/docs/streaming/authenticate-with-a-temporary-token) for the Real-time STT flow, and [Temporary tokens](https://www.assemblyai.com/docs/temporary-tokens) for the request, the products a token can open, and the `access` settings that narrow a token.




## OpenAPI

````yaml api-reference/specs/streaming-token.yaml POST /v1/token
openapi: 3.0.3
info:
  title: AssemblyAI Streaming Token API
  description: API for generating temporary authentication tokens for streaming services
  version: 1.0.0
  termsOfService: https://www.assemblyai.com/legal/terms-of-service
  contact:
    name: API Support
    email: support@assemblyai.com
    url: https://www.assemblyai.com/docs/
servers:
  - url: https://token.assemblyai.com
    description: >-
      Production server, nearest region. Use https://token.us.assemblyai.com or
      https://token.eu.assemblyai.com to mint within a data zone.
    x-fern-server-name: Default
security: []
paths:
  /v1/token:
    post:
      summary: Generate temporary streaming token
      description: >
        Generates a temporary authentication token for Real-time STT. Send
        `product` set to `streaming`. See [Authenticate with a temporary
        token](https://www.assemblyai.com/docs/streaming/authenticate-with-a-temporary-token)
        for the Real-time STT flow, and [Temporary
        tokens](https://www.assemblyai.com/docs/temporary-tokens) for the
        request, the products a token can open, and the `access` settings that
        narrow a token.
      operationId: generateStreamingToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - product
                - expires_in_seconds
              properties:
                product:
                  type: string
                  description: >-
                    The product the token is minted for. Use `streaming` for
                    Real-time STT.
                  example: streaming
                expires_in_seconds:
                  type: integer
                  description: >
                    Token redemption window, in seconds. The token must be used
                    to open a WebSocket connection within this window. If the
                    window has elapsed when the WebSocket is opened, the server
                    rejects the session on the first frame. This does NOT cap
                    the duration of the resulting streaming session — once the
                    WebSocket is open the session runs for up to
                    `max_session_duration_seconds`. The token is not single-use:
                    until this window elapses, the same token can open multiple
                    sessions, including concurrent sessions.
                  minimum: 1
                  maximum: 600
                  example: 60
                max_session_duration_seconds:
                  type: integer
                  description: >
                    Maximum duration of the streaming session started with this
                    token, in seconds. When the limit is reached, the session
                    closes after the current turn ends, or up to 60 seconds
                    later, and this extra time is billed. If you need to
                    finalize work before the session ends, run a client-side
                    timer using the value you passed here.
                  minimum: 60
                  maximum: 10800
                  example: 600
                  default: 10800
                access:
                  type: object
                  description: >
                    Optional per-product settings that narrow what the token can
                    open, keyed by product name. Products you leave out are not
                    restricted. See [Temporary
                    tokens](https://www.assemblyai.com/docs/temporary-tokens)
                    for a tutorial.
                  additionalProperties:
                    $ref: '#/components/schemas/ProductAccess'
      responses:
        '200':
          description: Successfully generated temporary token
          content:
            application/json:
              schema:
                type: object
                required:
                  - token
                  - expires_in_seconds
                properties:
                  token:
                    type: string
                    description: The temporary authentication token
                    example: your-temporary-token
                  expires_in_seconds:
                    type: integer
                    description: >
                      The token redemption window in seconds — the time the
                      client has to use this token to open a WebSocket before it
                      expires unused. This is not the session duration; see
                      `max_session_duration_seconds` for that.
                    example: 60
        '400':
          description: Bad Request - Invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - apiKey: []
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: >
            import os


            from assemblyai.streaming.v3 import RealTimeTranscriber


            client =
            RealTimeTranscriber(api_key=os.environ["ASSEMBLYAI_API_KEY"])


            token = client.create_temporary_token(expires_in_seconds=60)

            print(token)
        - lang: javascript
          label: JavaScript SDK
          source: >
            import { AssemblyAI } from "assemblyai";


            const client = new AssemblyAI({ apiKey:
            process.env.ASSEMBLYAI_API_KEY });


            const token = await client.streaming.createTemporaryToken({
              expires_in_seconds: 60,
            });

            console.log(token);
        - lang: bash
          label: cURL
          source: |
            curl -s -X POST https://token.assemblyai.com/v1/token \
              -H "authorization: $ASSEMBLYAI_API_KEY" \
              -H "content-type: application/json" \
              -d '{"product": "streaming", "expires_in_seconds": 60}' | jq -r .token
        - lang: python
          label: Python
          source: |
            import os

            import requests

            headers = {"authorization": os.environ["ASSEMBLYAI_API_KEY"]}

            response = requests.post(
                "https://token.assemblyai.com/v1/token",
                headers=headers,
                json={"product": "streaming", "expires_in_seconds": 60},
            )

            response.raise_for_status()
            print(response.json()["token"])
        - lang: javascript
          label: JavaScript
          source: >
            const response = await
            fetch("https://token.assemblyai.com/v1/token", {
              method: "POST",
              headers: {
                authorization: process.env.ASSEMBLYAI_API_KEY,
                "content-type": "application/json",
              },
              body: JSON.stringify({ product: "streaming", expires_in_seconds: 60 }),
            });


            const { token } = await response.json();

            console.log(token);
components:
  schemas:
    ProductAccess:
      type: object
      description: Settings for one product in the token's `access`.
      properties:
        enabled:
          type: boolean
          default: true
          description: Set to `false` to stop the token from opening this product.
        models:
          type: object
          description: Limits per model id. Only `llm_gateway` takes `models`.
          additionalProperties:
            $ref: '#/components/schemas/ModelLimit'
      additionalProperties: false
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Error message describing what went wrong
        code:
          type: string
          description: Error code for programmatic handling
        details:
          type: object
          description: Additional error details if available
    ModelLimit:
      type: object
      description: >-
        Limits for one LLM Gateway model. Unset limits use the defaults in the
        Temporary tokens tutorial.
      properties:
        rpm:
          type: integer
          minimum: 1
          description: Requests per minute made with this token. Unset, the model gets 10.
        tpm:
          type: integer
          minimum: 1
          description: >-
            Tokens per minute made with this token. Unset, it is derived from
            `rpm`.
        max_tokens:
          type: integer
          minimum: 1
          description: The largest `max_tokens` a request may set.
        max_prompt_size:
          type: integer
          minimum: 1
          description: The longest prompt, in characters. Unset, 5000.
      additionalProperties: false
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: Your AssemblyAI API key

````