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

# Create realtime client token

> Create a short-lived token on your backend using your API key, then give it to your browser to open the `/v1/realtime` WebSocket with `?token=...`. Do not expose your API key in browser code. Tokens inherit the parent key's account, model access, billing and session limits; they are not model-specific or single-use. They cannot call REST endpoints, including this endpoint or endpoint lookup. Expiry prevents new connections but does not close an already-authenticated stream. See [Client-side streaming](/guides/client-side-streaming) for examples and supported gateway addresses.

See [Client-side streaming with client tokens](https://aircaps.ai/docs/guides/client-side-streaming.md) for the complete server-to-browser flow and supported WebSocket addresses.


## OpenAPI

````yaml POST /v1/realtime/token
openapi: 3.1.0
info:
  title: AirCaps AI API
  version: 1.0.0
  description: >-
    Speech-to-text: A5S Async v1 (REST; English, Spanish, French, German,
    Portuguese, Hindi, Japanese, Korean and Chinese). Real-time speech-to-text
    for voice agents: AirCaps Live 1 (WebSocket, English). Live streaming: A5S
    Streaming v1 (WebSocket, early access for select organizations). Speaker
    identification: AirCaps Speaker ID-v1 (REST, synchronous). Speaker
    diarization: AirCaps Diarization-v1 (REST, enabled on request).
  contact:
    name: AirCaps AI
    url: https://aircaps.ai/contact
servers:
  - url: https://api.aircaps.com
security:
  - bearerAuth: []
tags:
  - name: Transcripts
  - name: Realtime
  - name: Speakers
  - name: Diarizations
  - name: Files
  - name: Account
externalDocs:
  description: AirCaps AI API docs
  url: https://aircaps.ai/docs
paths:
  /v1/realtime/token:
    post:
      tags:
        - Realtime
      summary: Create realtime client token
      description: >-
        Create a short-lived token on your backend using your API key, then give
        it to your browser to open the `/v1/realtime` WebSocket with
        `?token=...`. Do not expose your API key in browser code. Tokens inherit
        the parent key's account, model access, billing and session limits; they
        are not model-specific or single-use. They cannot call REST endpoints,
        including this endpoint or endpoint lookup. Expiry prevents new
        connections but does not close an already-authenticated stream. See
        [Client-side streaming](/guides/client-side-streaming) for examples and
        supported gateway addresses.
      operationId: createRealtimeToken
      requestBody:
        required: false
        description: Optional. Omit the body or expires_in to use the 3,600-second default.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRealtimeTokenRequest'
            example:
              expires_in: 60
      responses:
        '201':
          description: Token created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RealtimeToken'
              example:
                object: realtime_token
                token: aircaps_rt_...
                expires_at: '2026-11-24T23:01:00Z'
                expires_in: 60
        '400':
          description: >-
            Invalid request body, such as expires_in outside 60–3600 seconds or
            an unknown field. Codes: `invalid_request`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  type: invalid_request_error
                  code: invalid_request
                  message: Input should be greater than or equal to 60
                  param: null
                  request_id: req_01k6z3m4q8w7e5r2t1y0u9i8o7
        '401':
          description: 'Missing or invalid API key. Codes: `unauthorized`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  type: authentication_error
                  code: unauthorized
                  message: invalid API key
                  param: null
                  request_id: req_01k6z3m4q8w7e5r2t1y0u9i8o7
        '403':
          description: >-
            Only an API key can create tokens; console login sessions cannot.
            The account must be active. Codes: `api_key_required`,
            `account_disabled`, `account_suspended`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  type: permission_error
                  code: api_key_required
                  message: an API key is required to create realtime client tokens
                  param: null
                  request_id: req_01k6z3m4q8w7e5r2t1y0u9i8o7
        '500':
          description: >-
            Server error. Safe to retry (use the same Idempotency-Key). Codes:
            `internal_error`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  type: api_error
                  code: internal_error
                  message: internal error
                  param: null
                  request_id: req_01k6z3m4q8w7e5r2t1y0u9i8o7
        '503':
          description: >-
            Token creation is temporarily unavailable. Codes:
            `client_tokens_unavailable`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  type: api_error
                  code: client_tokens_unavailable
                  message: realtime client tokens are not available
                  param: null
                  request_id: req_01k6z3m4q8w7e5r2t1y0u9i8o7
components:
  schemas:
    CreateRealtimeTokenRequest:
      type: object
      additionalProperties: false
      properties:
        expires_in:
          type: integer
          minimum: 60
          maximum: 3600
          default: 3600
          example: 60
          description: >-
            Token lifetime in seconds. Use a short lifetime when the browser
            will connect immediately. Expiry prevents new connections; it does
            not end an already-open stream.
    RealtimeToken:
      type: object
      required:
        - object
        - token
        - expires_at
        - expires_in
      properties:
        object:
          type: string
          enum:
            - realtime_token
        token:
          type: string
          description: >-
            Credential for the /v1/realtime WebSocket, passed as the token query
            parameter. Keep it out of logs.
          example: aircaps_rt_...
        expires_at:
          type: string
          format: date-time
          description: Expiry time in UTC. Authenticate a new session before this time.
        expires_in:
          type: integer
          description: >-
            Remaining lifetime in seconds at response time; it may be slightly
            shorter than the requested lifetime.
          example: 60
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
            - request_id
          properties:
            type:
              type: string
              enum:
                - invalid_request_error
                - authentication_error
                - permission_error
                - rate_limit_error
                - api_error
            code:
              type: string
              description: Machine-readable code; see [Errors](/errors).
            message:
              type: string
            param:
              type:
                - string
                - 'null'
              description: The request field at fault, if any.
            request_id:
              type:
                - string
                - 'null'
              description: >-
                Also in the `x-request-id` header. Include it when you contact
                support (https://console.aircaps.ai/support). `null` on 502/504
                from the edge.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your API key: `Authorization: Bearer aircaps_sk_...`'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.