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

# Realtime Client Secrets API

> A short-lived secret a browser opens the realtime WebSocket with, so your API key stays on your server.

A browser cannot put an `Authorization` header on a WebSocket, and anything a page sends, its visitors can read. So your server makes a client secret with its API key and hands it to the page, and the page connects straight to `wss://api.morphllm.com/v1/realtime` with it. Audio never passes through your server.

This is OpenAI's `POST /v1/realtime/client_secrets`, for transcription sessions: the same request, the same response, and the same browser connection. Sessions take `audio/pcm` input (24 kHz, or 16 kHz as an extension) with `server_vad` or manual turns; `audio/pcmu`, `audio/pcma` and `semantic_vad` are refused, and `noise_reduction` and `include` have no effect. See [Connect from a browser](https://docs.morphllm.com/api-reference/endpoint/realtime-transcription.md#connect-from-a-browser) for the page side.

* The secret opens new sessions until `expires_at` (10 seconds to 2 hours, default 10 minutes). It is not single use, and a session already open keeps running after it expires.
* A `session` given here is where every connection on the secret starts. The URL's `model` and `chunk_ms`, and `session.update` events, change it as usual.
* Sessions on the secret are authenticated, rate limited and billed as the API key that made it. Making a secret is free.
* A client secret cannot make another one, and it works only on the realtime WebSocket.


## OpenAPI

````yaml POST /v1/realtime/client_secrets
openapi: 3.1.0
info:
  title: Morph API
  version: 1.2.0
  description: >-
    The Morph public API at api.morphllm.com: OpenAI- and Anthropic-compatible
    inference (chat completions, messages), Fast Apply code editing, Compact
    context compression, System One typed decisions, speech to text (audio
    transcription and translation), model listing, and dedicated endpoint
    management, agentic credit top-ups paid over x402, account usage and billing
    settings, and organization member budgets. Model ids, prices, and context
    windows are served live at https://www.morphllm.com/api/models/json.
  contact:
    name: Morph
    url: https://morphllm.com
    email: info@morphllm.com
  license:
    name: Proprietary
    url: https://morphllm.com/privacy/tos
servers:
  - url: https://api.morphllm.com
    description: Production
security: []
tags:
  - name: chat
    description: >-
      OpenAI- and Anthropic-compatible chat inference, including Fast Apply and
      WarpGrep models.
  - name: compact
    description: Context compression for long agent conversations.
  - name: systemone
    description: 'Typed decisions: a state in, a probability distribution per question out.'
  - name: audio
    description: >-
      Speech to text: transcription and translation of audio files,
      OpenAI-compatible.
  - name: models
    description: Model listing.
  - name: dedicated
    description: Dedicated endpoint discovery, status, and cancellation.
  - name: compute
    description: >-
      Dedicated compute: reserve whole GPU nodes by the month, manage SSH keys,
      give notice. Limited preview.
  - name: credits
    description: Agentic credit top-ups paid in USDC over x402.
  - name: account
    description: >-
      Usage and spend per day; billing settings: extra usage, spend limit and
      alert, auto-reload.
  - name: organization
    description: Organization member budgets.
  - name: telemetry
    description: Usage reporting hooks.
paths:
  /v1/realtime/client_secrets:
    post:
      tags:
        - audio
      summary: Create a realtime client secret
      description: >-
        Make a short-lived secret a browser opens the realtime WebSocket with,
        so the API key stays on your server. OpenAI-compatible: OpenAI's client
        secrets request and response, for transcription sessions with
        `audio/pcm` input (24 kHz, or 16 kHz as an extension) and `server_vad`
        or manual turns. `audio/pcmu`, `audio/pcma` and `semantic_vad` are
        refused, and `noise_reduction` and `include` have no effect. Sessions on
        the secret are authenticated, rate limited and billed as the API key
        that made it. Making a secret is free.
      operationId: createRealtimeClientSecret
      requestBody:
        required: false
        description: How long the secret lasts and the session it opens. Both optional.
        content:
          application/json:
            example:
              expires_after:
                anchor: created_at
                seconds: 60
              session:
                type: transcription
                audio:
                  input:
                    format:
                      type: audio/pcm
                      rate: 16000
                    transcription:
                      model: morph-transcribe-live
                      language: en
                    turn_detection: null
            schema:
              $ref: '#/components/schemas/RealtimeClientSecretRequest'
      responses:
        '200':
          description: The secret, when it expires, and the session it opens.
          content:
            application/json:
              example:
                value: ek_68af296e8e408191a1120ab6383263c2
                expires_at: 1796020133
                session:
                  id: sess_294cdbd77c2c40b089bc33e1
                  object: realtime.transcription_session
                  type: transcription
                  audio:
                    input:
                      format:
                        type: audio/pcm
                        rate: 16000
                      transcription:
                        model: morph-transcribe-live
                        language: en-US
                        chunk_ms: 560
                      turn_detection: null
                      noise_reduction: null
                  include: []
              schema:
                $ref: '#/components/schemas/RealtimeClientSecret'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/SpendLimitReached'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
      security:
        - bearerAuth: []
components:
  schemas:
    RealtimeClientSecretRequest:
      type: object
      properties:
        expires_after:
          type: object
          properties:
            anchor:
              type: string
              enum:
                - created_at
              description: What `seconds` counts from. Only `created_at`.
            seconds:
              type: integer
              minimum: 10
              maximum: 7200
              description: >-
                How long the secret can open new sessions, 10 to 7200. Default
                600. A session already open runs on after it expires.
              example: 60
          example:
            anchor: created_at
            seconds: 60
        session:
          $ref: '#/components/schemas/RealtimeTranscriptionSession'
      description: >-
        Both fields are optional; an empty body makes a 10-minute secret for the
        default session.
    RealtimeClientSecret:
      type: object
      properties:
        value:
          type: string
          description: >-
            The client secret: `ek_` and 32 hex characters. A browser passes it
            as the WebSocket protocol `openai-insecure-api-key.<value>` beside
            `realtime`. It opens sessions until `expires_at`; it is not single
            use.
          example: ek_68af296e8e408191a1120ab6383263c2
        expires_at:
          type: integer
          description: When the secret stops opening sessions, in Unix seconds.
          example: 1796020133
        session:
          type: object
          properties:
            id:
              type: string
            object:
              type: string
              enum:
                - realtime.transcription_session
            type:
              type: string
              enum:
                - transcription
            audio:
              type: object
              properties:
                input:
                  $ref: '#/components/schemas/RealtimeAudioInput'
              required:
                - input
            include:
              type: array
              items:
                type: string
          required:
            - id
            - object
            - type
            - audio
            - include
          description: >-
            The session a connection on this secret starts with, as
            `session.created` reports it.
          example:
            id: sess_294cdbd77c2c40b089bc33e1
            object: realtime.transcription_session
            type: transcription
            audio:
              input:
                format:
                  type: audio/pcm
                  rate: 16000
                transcription:
                  model: morph-transcribe-live
                  language: en-US
                  chunk_ms: 560
                turn_detection: null
                noise_reduction: null
            include: []
      required:
        - value
        - expires_at
        - session
      description: A client secret, when it expires, and the session it opens.
    RealtimeTranscriptionSession:
      type: object
      properties:
        type:
          type: string
          enum:
            - transcription
        audio:
          type: object
          properties:
            input:
              $ref: '#/components/schemas/RealtimeAudioInput'
      required:
        - type
      description: >-
        A transcription session in the shape `session.update` takes. The URL's
        `model` and `chunk_ms`, and later `session.update` events, change it.
      example:
        type: transcription
        audio:
          input:
            format:
              type: audio/pcm
              rate: 16000
            transcription:
              model: morph-transcribe-live
              language: en
            turn_detection: null
    RealtimeAudioInput:
      type: object
      properties:
        format:
          type: object
          properties:
            type:
              type: string
              enum:
                - audio/pcm
              description: 16-bit little-endian mono PCM.
            rate:
              type: integer
              default: 24000
              description: 24000 (default) or 16000.
              enum:
                - 24000
                - 16000
              example: 16000
        transcription:
          type: object
          properties:
            model:
              type: string
              description: '`morph-transcribe-live` (default) or `morph-transcribe`.'
              example: morph-transcribe-live
            language:
              type:
                - string
                - 'null'
              description: A locale or ISO 639-1 code; null detects it.
              example: en
            chunk_ms:
              type: integer
              default: 560
              description: 'morph-transcribe-live only: 320, 560 (default) or 1120.'
              enum:
                - 320
                - 560
                - 1120
              example: 560
          description: >-
            The model and its options. morph-transcribe also takes `prompt`,
            `keyterms` and `style`.
        turn_detection:
          type:
            - object
            - 'null'
          properties:
            type:
              type: string
              enum:
                - server_vad
            threshold:
              type: number
              minimum: 0
              maximum: 1
              default: 0.5
            prefix_padding_ms:
              type: integer
              minimum: 0
              maximum: 2000
              default: 300
            silence_duration_ms:
              type: integer
              minimum: 100
              maximum: 10000
              default: 500
          description: '`server_vad` (default) or null for manual commits.'
      description: 'The input audio: its format, the transcription model and turn detection.'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: invalid_request_error
              description: Machine-readable error code.
            message:
              type: string
              example: The request body is missing the `model` field.
              description: Human-readable explanation of the failure.
          required:
            - code
            - message
      required:
        - error
      description: Standard error envelope returned by every non-2xx response.
      example:
        error:
          code: invalid_request_error
          message: The request body is missing the `model` field.
  responses:
    BadRequest:
      description: Malformed request — missing or invalid fields.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_request_error
              message: The request body is missing the `model` field.
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Invalid API key provided.
    SpendLimitReached:
      description: The account reached its monthly spend limit.
      content:
        application/json:
          example:
            error:
              message: Monthly spend limit reached.
              type: quota_exceeded_error
              param: null
              code: monthly_quota_exceeded
    RateLimited:
      description: Rate limited — retry after the interval in the Retry-After header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: rate_limited
              message: Too many requests. Retry in 12 seconds.
    InternalError:
      description: Internal error — safe to retry with backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: internal_error
              message: Something went wrong on our side.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: opaque
      description: >-
        Morph API key, passed as `Authorization: Bearer sk-...`. Create keys at
        https://www.morphllm.com/dashboard/api-keys.

````

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