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

# Mint realtime voice session

> Mint a short-lived WebSocket credential for a realtime speech-to-speech session with xAI Grok Voice. Authenticates the caller, checks the `realtimeVoiceEnabled` org gate, resolves voice ownership, reserves worst-case session funds from the wallet, and returns `wss_url` plus an `ephemeral_key`. The key is an HMAC-SHA-256 signed opaque one-use relay ticket (valid 5 minutes); it encodes only expiry and a nonce — the authorized voice is stored in the session record, keyed by the ticket's SHA-256 hash. The relay verifies the HMAC, reads the session record by hash, and injects the authorized voice server-side at WebSocket open; the client cannot change the voice mid-session. Only audio I/O events are accepted; text output, transcription, tools, and session resumption are not supported in this release.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/realtime/sessions
openapi: 3.0.3
info:
  title: AI Reserve Gateway API
  description: >-
    The AI Reserve API surface — OpenAI-compatible chat completions,
    Anthropic-compatible messages, Bedrock Converse, images, video, files,
    text-to-speech, realtime voice sessions, and GPU Compute pod/volume
    management — all behind one endpoint and one API key.
  version: 1.0.0
servers:
  - url: https://api.aireserve.com
security:
  - bearerAuth: []
paths:
  /v1/realtime/sessions:
    post:
      tags:
        - Realtime
      summary: Mint realtime voice session
      description: >-
        Mint a short-lived WebSocket credential for a realtime speech-to-speech
        session with xAI Grok Voice. Authenticates the caller, checks the
        `realtimeVoiceEnabled` org gate, resolves voice ownership, reserves
        worst-case session funds from the wallet, and returns `wss_url` plus an
        `ephemeral_key`. The key is an HMAC-SHA-256 signed opaque one-use relay
        ticket (valid 5 minutes); it encodes only expiry and a nonce — the
        authorized voice is stored in the session record, keyed by the ticket's
        SHA-256 hash. The relay verifies the HMAC, reads the session record by
        hash, and injects the authorized voice server-side at WebSocket open;
        the client cannot change the voice mid-session. Only audio I/O events
        are accepted; text output, transcription, tools, and session resumption
        are not supported in this release.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - voice
              properties:
                model:
                  type: string
                  enum:
                    - grok-voice
                  description: Must be `grok-voice`.
                voice:
                  type: string
                  description: >-
                    Voice to use for this session. Pass a built-in voice ID
                    (from `GET /v1/voices`) or one of your organization's custom
                    voice IDs. Defaults to `ara` when omitted. Voice is locked
                    at mint and cannot change mid-session.
            example:
              model: grok-voice
              voice: ara
      responses:
        '201':
          description: Session minted. Connect the WebSocket before `expires_at`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RealtimeSessionResponse'
              example:
                session_id: 9c3f1a2b-4d5e-6f7a-8b9c-0d1e2f3a4b5c
                model: grok-voice
                voice: ara
                wss_url: >-
                  wss://voice-relay-uat-abcdefg-ue.a.run.app/v1/realtime?model=grok-voice
                ephemeral_key: >-
                  v1.1756946700.ABCDEFGHIJKLMNOPQRSTuvwxyz01234.signature_base64url_43chars
                expires_at: '2026-09-03T21:05:00.000Z'
                key_ttl_seconds: 300
                max_session_seconds: 3540
                browser_subprotocols:
                  - openai-beta.realtime-v1
                  - >-
                    openai-insecure-api-key.v1.1756946700.ABCDEFGHIJKLMNOPQRSTuvwxyz01234.signature_base64url_43chars
        '402':
          description: Wallet cannot cover the worst-case session cost.
        '403':
          description: >-
            `realtimeVoiceEnabled` is off, or `customVoicesEnabled` is required
            for the requested custom voice.
        '404':
          description: Custom voice ID not found or owned by another organization.
        '503':
          description: Voice relay service is not deployed in this environment.
components:
  schemas:
    RealtimeSessionResponse:
      type: object
      description: >-
        Realtime session mint response. Use `wss_url` and `ephemeral_key` to
        open the WebSocket.
      required:
        - session_id
        - model
        - voice
        - wss_url
        - ephemeral_key
        - expires_at
        - key_ttl_seconds
        - max_session_seconds
        - browser_subprotocols
      properties:
        session_id:
          type: string
          format: uuid
          description: Unique session identifier used for billing and logging.
        model:
          type: string
          enum:
            - grok-voice
        voice:
          type: string
          description: Voice bound to this session (cannot change mid-session).
        wss_url:
          type: string
          description: >-
            Environment-specific WebSocket URL returned by the session mint; use
            it verbatim.
          example: >-
            wss://voice-relay-uat-abcdefg-ue.a.run.app/v1/realtime?model=grok-voice
        ephemeral_key:
          type: string
          description: >-
            HMAC-SHA-256 signed opaque one-use relay ticket. Encodes expiry and
            a random nonce only — voice authorization is stored in the session
            record keyed by this ticket's SHA-256 hash, not in the token itself.
            Valid until `expires_at`; consumed on first successful connection
            (replay rejected). Do not log or share.
        expires_at:
          type: string
          format: date-time
          description: >-
            Timestamp after which `ephemeral_key` is rejected. Connect promptly
            — `key_ttl_seconds` is short by design.
        key_ttl_seconds:
          type: integer
          description: Seconds from mint until `ephemeral_key` expires (300 s / 5 min).
        max_session_seconds:
          type: integer
          description: >-
            Hard session length ceiling enforced by the relay (3,540 s). Mint a
            new session to continue.
        browser_subprotocols:
          type: array
          items:
            type: string
          description: >-
            Pass this array verbatim as the WebSocket subprotocols from a
            browser (browsers cannot set Authorization headers). Server-side
            callers should use `Authorization: Bearer <ephemeral_key>` instead.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your AI Reserve API key (aireserve_api_…) from the API Keys page in the
        portal (https://portal.aireserve.com/keys).

````