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

# /compose/token

> Create a session token for a streaming session

Call this from your server: it takes your API key, and only the token goes to the browser. The token is valid for 5 minutes, so create one for each session, right before you open its WebSocket. The Trinity-2 fields, `streaming_width`, `streaming_height`, `avatar_position_x`, `avatar_position_y`, `camera`, `background_id` and `foreground_id`, are covered in [Trinity-2](https://docs.simli.com/api-reference/trinity-2.md#framing-the-video). For the whole flow, see [Custom JS Simli Client](https://docs.simli.com/api-reference/simli-webrtc.md).


## OpenAPI

````yaml POST /compose/token
openapi: 3.1.0
info:
  title: Simli
  version: 1.0.0
servers:
  - url: https://api.simli.ai/
    description: API server
security:
  - ApiKeyAuth: []
paths:
  /compose/token:
    post:
      summary: Compose Session Token
      description: Create a temporary Simli Compose Session Token
      operationId: start_audio_to_video_session_compose_token_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StartStreamingSessionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  session_token:
                    type: string
                  warnings:
                    type: array
                    items:
                      type: string
                    description: >-
                      Starting camera fields outside their supported range,
                      region overrides, and background_id / foreground_id
                      dropped as not your account's (the avatar's own is used).
                      The token is minted regardless.
        '400':
          description: Invalid Data
          content:
            application/json:
              schema:
                type: object
                properties:
                  session_token:
                    type: string
                    description: FAIL TOKEN
                  detail:
                    type: string
                    description: Fail Reason
        '403':
          description: >-
            The face is private and belongs to another account. A face can be
            used by the account that created it, and, when it is public, by any
            account that has its face ID.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: FACE_NOT_ALLOWED
                  reason:
                    type: string
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    StartStreamingSessionRequest:
      properties:
        faceId:
          type: string
          title: Faceid
        apiVersion:
          type: string
          title: Apiversion
          const: v2
          default: v2
        sessionAggregator:
          anyOf:
            - type: string
            - type: 'null'
          title: Sessionaggregator
        handleSilence:
          type: boolean
          title: Handlesilence
          default: true
        maxSessionLength:
          type: integer
          title: Maxsessionlength
          default: 3600
        maxIdleTime:
          type: integer
          title: Maxidletime
          default: 300
        startFrame:
          type: integer
          title: Startframe
          default: 0
        audioInputFormat:
          type: string
          title: Audioinputformat
          default: pcm16
        streaming_width:
          type: integer
          title: Streaming Width
          default: 768
          minimum: 512
          description: >-
            Width of the streamed video in pixels, Trinity-2 faces only (the
            others keep their own frame size). At least 512, and with
            streaming_height one of 1:1, 16:9 or 9:16, otherwise a 422. A canvas
            larger than the avatar's frame is padded with its background; a
            smaller one crops a window out of it.
        streaming_height:
          type: integer
          title: Streaming Height
          default: 768
          minimum: 512
          description: Height of the streamed video in pixels. See streaming_width.
        avatar_position_x:
          type: number
          title: Avatar Position X
          default: 0.5
          minimum: 0
          maximum: 1
          description: >-
            Where the avatar sits across the canvas, from 0 (left) to 1 (right).
            Trinity-2 only.
        avatar_position_y:
          type: number
          title: Avatar Position Y
          default: 1
          minimum: 0
          maximum: 1
          description: >-
            Where the avatar sits down the canvas, from 0 (top) to 1 (bottom).
            Trinity-2 only.
        camera:
          anyOf:
            - $ref: '#/components/schemas/CameraSetting'
            - type: 'null'
          description: >-
            The camera the session starts with, on top of the avatar's own
            framing. Trinity-2 only. Leave it out to keep the avatar's framing.
            A streaming session can move it afterwards with CAM_ messages.
        background_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Background Id
          description: >-
            One of your uploaded backgrounds, by the id POST /assets/backgrounds
            returned, to show behind the avatar, cropped to fill the canvas.
            Trinity-2 only. Leave it out for the avatar's own. An id that is not
            one of your account's is dropped with a warning, and the session
            uses the avatar's own. An image is not accepted: upload it first. A
            streaming session can change it afterwards with BG_ messages.
        foreground_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Foreground Id
          description: >-
            One of your uploaded foregrounds, by the id POST /assets/foregrounds
            returned, laid over the avatar through its transparency and cropped
            to fill the canvas. Trinity-2 only; otherwise as background_id. A
            streaming session can change it afterwards with FG_ messages.
      type: object
      required:
        - faceId
      title: StartStreamingSessionRequest
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CameraSetting:
      type: object
      title: CameraSetting
      description: >-
        Camera offsets on top of the avatar's own framing. Every field is
        optional and neutral when left out. A value outside its supported range
        is still applied, and the response lists a warning for it; NaN and
        infinity are a 422.
      properties:
        pos_x_off:
          type: number
          default: 0
          description: >-
            Moves the avatar right, in half canvas widths. Supported range -10
            to 10.
        pos_y_off:
          type: number
          default: 0
          description: >-
            Moves the avatar down, in half canvas heights. Supported range -10
            to 10.
        pos_z_off:
          type: number
          default: 0
          description: >-
            Metres the camera backs away from the avatar (negative moves in).
            Supported range -5 to 5.
        rot_x_off:
          type: number
          default: 0
          description: Degrees the camera tilts up (pitch). Supported range -180 to 180.
        rot_y_off:
          type: number
          default: 0
          description: Degrees the camera pans right (yaw). Supported range -180 to 180.
        rot_z_off:
          type: number
          default: 0
          description: Degrees the camera rolls clockwise. Supported range -180 to 180.
        zoom:
          type: number
          default: 1
          description: >-
            Multiplies the avatar's zoom; 1 is no change. Supported range above
            0, up to 4.
        orbit_x_off:
          type: number
          default: 0
          description: >-
            Degrees the camera orbits up over the avatar's head (elevation).
            Supported range -80 to 80.
        orbit_y_off:
          type: number
          default: 0
          description: >-
            Degrees the camera orbits round to its right (azimuth). Supported
            range -180 to 180.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-simli-api-key

````

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