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

# Create session

> Creates a new LemonSlice session that takes in avatar audio and publishes synchronized video/audio to the specified transport.

> [!WARNING]
>
> **Do not call this endpoint directly with the `livekit` or `daily` transport.** Use the official [LiveKit](https://lemonslice.com/docs/livekit.md) or [Pipecat](https://lemonslice.com/docs/pipecat.md) SDK instead to ensure proper session lifecycle management.

> [!TIP]
>
> To upload an avatar image file directly, switch the request body content type to `multipart/form-data` below.


## OpenAPI

````yaml /openapi.json post /liveai/sessions
openapi: 3.1.0
info:
  title: LemonSlice
  description: An API for real-time, interactive LemonSlice avatar sessions.
  license:
    name: MIT
    identifier: MIT
  version: 1.0.0
servers:
  - url: https://lemonslice.com/api
security:
  - apiKeyAuth: []
paths:
  /liveai/sessions:
    post:
      summary: Create session
      description: >-
        Creates a new LemonSlice session that takes in avatar audio and
        publishes synchronized video/audio to the specified transport.
      operationId: createSession
      requestBody:
        description: >-
          The properties used to create a session. Use `application/json` to
          reference an agent_id or agent_image_url, or `multipart/form-data` to
          upload an image file directly.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SessionInput'
            examples:
              by_agent_image_url:
                summary: Create a session using an agent_image_url
                value:
                  agent_image_url: https://cdn.lemonslice.com/avatars/avatar.png
                  agent_prompt: a person talking
                  transport_type: livekit
                  properties:
                    livekit_url: wss://lemonslice-pb123.livekit.cloud
                    livekit_token: eyJhbGciOiJIUzI1NiIsInR5a...
              by_agent_id:
                summary: Create a session using an agent_id
                value:
                  agent_id: agent_abc123
                  transport_type: livekit
                  properties:
                    livekit_url: wss://lemonslice-pb123.livekit.cloud
                    livekit_token: eyJhbGciOiJIUzI1NiIsInR5a...
              daily_transport:
                summary: Create a session using Daily transport
                value:
                  agent_id: agent_abc123
                  transport_type: daily
                  properties:
                    daily_url: https://your-domain.daily.co/your-room
                    daily_token: eyJhbGciOiJIUzI1NiIsInR5a...
              websocket_livekit:
                summary: Create a WebSocket session with LiveKit egress
                value:
                  agent_image_url: https://cdn.lemonslice.com/avatars/avatar.png
                  transport_type: websocket-livekit
                  livekit_properties:
                    livekit_url: wss://lemonslice-pb123.livekit.cloud
                    livekit_token: eyJhbGciOiJIUzI1NiIsInR5a...
              websocket_daily:
                summary: Create a WebSocket session with Daily egress
                value:
                  agent_id: agent_abc123
                  transport_type: websocket-daily
                  daily_properties:
                    daily_url: https://your-domain.daily.co/your-room
                    daily_token: eyJhbGciOiJIUzI1NiIsInR5a...
          multipart/form-data:
            schema:
              type: object
              required:
                - image
                - payload
              properties:
                image:
                  description: >-
                    The avatar image file. The image should be 368x560 pixels
                    with a maximum size of 4 MB. LemonSlice will automatically
                    center-crop to the target aspect ratio if the dimensions do
                    not match.
                  type: string
                  format: binary
                payload:
                  $ref: '#/components/schemas/SessionFormDataPayload'
            encoding:
              payload:
                contentType: application/json
        required: true
      responses:
        '201':
          description: Session created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Session'
              examples:
                livekit:
                  summary: LiveKit SDK session
                  value:
                    session_id: 3f7c2b91-9e1f-4a6a-8e9d-2c7c3e7d9b5a
                    control_url: https://.../control/3f7c2b91
                daily:
                  summary: Pipecat SDK session
                  value:
                    session_id: 3f7c2b91-9e1f-4a6a-8e9d-2c7c3e7d9b5a
                    control_url: https://.../control/3f7c2b91
                    room_url: https://your-domain.daily.co/your-room
                websocket:
                  summary: WebSocket session (LiveKit or Daily egress)
                  value:
                    session_id: 3f7c2b91-9e1f-4a6a-8e9d-2c7c3e7d9b5a
                    control_url: https://.../control/3f7c2b91
                    websocket_address: wss://.../tunnel
        '400':
          description: Invalid arguments
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Missing required fields
        '401':
          description: Authentication denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Invalid API key
        '402':
          description: Agent owner has insufficient funds
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Agent agent_123abc owner has insufficient funds
        '403':
          description: Agent not owned
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Agent agent_123abc is not owned by the authenticated user
        '404':
          description: Agent not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Agent not found
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
components:
  schemas:
    SessionInput:
      oneOf:
        - $ref: '#/components/schemas/LiveKitSDKSessionInput'
          title: LiveKit SDK
        - $ref: '#/components/schemas/PipecatSDKSessionInput'
          title: Pipecat SDK
        - $ref: '#/components/schemas/WebSocketLiveKitSessionInput'
          title: WebSocket + LiveKit
        - $ref: '#/components/schemas/WebSocketDailySessionInput'
          title: WebSocket + Daily
    SessionFormDataPayload:
      description: >-
        Session parameters used alongside an uploaded avatar image. Select an
        integration to see its complete payload. Send the request as
        `application/json` to specify an agent_id or agent_image_url.
      oneOf:
        - $ref: '#/components/schemas/LiveKitSDKFormDataPayload'
          title: LiveKit SDK
        - $ref: '#/components/schemas/PipecatSDKFormDataPayload'
          title: Pipecat SDK
        - $ref: '#/components/schemas/WebSocketLiveKitFormDataPayload'
          title: WebSocket + LiveKit
        - $ref: '#/components/schemas/WebSocketDailyFormDataPayload'
          title: WebSocket + Daily
    Session:
      description: Response fields vary by transport.
      oneOf:
        - title: LiveKit SDK
          type: object
          required:
            - session_id
            - control_url
          properties:
            session_id:
              description: The ID of the session.
              type: string
            control_url:
              description: Endpoint for sending control events to the session.
              type: string
              format: uri
            edited_image_url:
              description: >-
                Public URL of the reframed image when editing produced or reused
                a variant. Omitted when editing is skipped or falls back to the
                original image.
              type: string
              format: uri
          additionalProperties: false
        - title: Pipecat SDK
          type: object
          required:
            - session_id
            - control_url
            - room_url
          properties:
            session_id:
              description: The ID of the session.
              type: string
            control_url:
              description: Endpoint for sending control events to the session.
              type: string
              format: uri
            room_url:
              description: The Daily room URL used by the session.
              type: string
              format: uri
            edited_image_url:
              description: >-
                Public URL of the reframed image when editing produced or reused
                a variant. Omitted when editing is skipped or falls back to the
                original image.
              type: string
              format: uri
          additionalProperties: false
        - title: WebSocket
          description: >-
            Returned for both `websocket-livekit` and `websocket-daily`. The
            egress provider determines where avatar A/V is published, not the
            response shape.
          type: object
          required:
            - session_id
            - control_url
            - websocket_address
          properties:
            session_id:
              description: The ID of the session.
              type: string
            control_url:
              description: Endpoint for sending control events to the session.
              type: string
              format: uri
            websocket_address:
              description: >-
                WebSocket URL for sending audio and control events to
                LemonSlice.
              type: string
              format: uri
            edited_image_url:
              description: >-
                Public URL of the reframed image when editing produced or reused
                a variant. Omitted when editing is skipped or falls back to the
                original image.
              type: string
              format: uri
          additionalProperties: false
    Error:
      type: object
      properties:
        detail:
          type: string
    ServerError:
      type: object
      properties:
        detail:
          type: string
    LiveKitSDKSessionInput:
      allOf:
        - $ref: '#/components/schemas/SessionInputCommon'
        - $ref: '#/components/schemas/LiveKitSDKTransportParameters'
      unevaluatedProperties: false
      example:
        agent_image_url: https://cdn.lemonslice.com/avatars/avatar.png
        agent_prompt: a person talking
        transport_type: livekit
        properties:
          livekit_url: wss://lemonslice-pb123.livekit.cloud
          livekit_token: eyJhbGciOiJIUzI1NiIsInR5a...
    PipecatSDKSessionInput:
      allOf:
        - $ref: '#/components/schemas/SessionInputCommon'
        - $ref: '#/components/schemas/PipecatSDKTransportParameters'
      unevaluatedProperties: false
    WebSocketLiveKitSessionInput:
      allOf:
        - $ref: '#/components/schemas/SessionInputCommon'
        - $ref: '#/components/schemas/WebSocketLiveKitTransportParameters'
      unevaluatedProperties: false
    WebSocketDailySessionInput:
      allOf:
        - $ref: '#/components/schemas/SessionInputCommon'
        - $ref: '#/components/schemas/WebSocketDailyTransportParameters'
      unevaluatedProperties: false
    LiveKitSDKFormDataPayload:
      allOf:
        - $ref: '#/components/schemas/SessionCommonParameters'
        - $ref: '#/components/schemas/LiveKitSDKTransportParameters'
      unevaluatedProperties: false
    PipecatSDKFormDataPayload:
      allOf:
        - $ref: '#/components/schemas/SessionCommonParameters'
        - $ref: '#/components/schemas/PipecatSDKTransportParameters'
      unevaluatedProperties: false
    WebSocketLiveKitFormDataPayload:
      allOf:
        - $ref: '#/components/schemas/SessionCommonParameters'
        - $ref: '#/components/schemas/WebSocketLiveKitTransportParameters'
      unevaluatedProperties: false
    WebSocketDailyFormDataPayload:
      allOf:
        - $ref: '#/components/schemas/SessionCommonParameters'
        - $ref: '#/components/schemas/WebSocketDailyTransportParameters'
      unevaluatedProperties: false
    SessionInputCommon:
      allOf:
        - $ref: '#/components/schemas/SessionImageParameters'
        - $ref: '#/components/schemas/SessionCommonParameters'
    LiveKitSDKTransportParameters:
      type: object
      required:
        - transport_type
        - properties
      properties:
        transport_type:
          description: Using the LiveKit SDK publishes avatar A/V to a LiveKit room.
          type: string
          const: livekit
        properties:
          $ref: '#/components/schemas/LiveKitTransportProperties'
          description: >-
            LiveKit room credentials LemonSlice uses to join and publish avatar
            A/V.
        simulcast:
          description: >-
            LiveKit only. Enable WebRTC simulcast, which publishes multiple
            resolutions of the avatar video so subscribers receive the best
            quality their bandwidth allows.
          type: boolean
          default: false
        video_codec:
          description: LiveKit only. Video codec for the published avatar track.
          type: string
          enum:
            - vp8
            - h264
            - vp9
            - av1
            - h265
          default: vp8
        scalability_mode:
          description: >-
            LiveKit only. SVC scalability mode. Applied only when `video_codec`
            is `vp9` or `av1`; ignored otherwise.
          type:
            - string
            - 'null'
          enum:
            - L1T1
            - L1T2
            - L1T3
            - L2T1
            - L2T2
            - L2T3
            - L2T1_KEY
            - L2T2_KEY
            - L2T3_KEY
            - L3T1
            - L3T2
            - L3T3
            - L3T1_KEY
            - L3T2_KEY
            - L3T3_KEY
            - null
          default: null
          x-mint:
            post:
              - 'default: null'
    PipecatSDKTransportParameters:
      type: object
      required:
        - transport_type
      properties:
        transport_type:
          description: Using the Pipecat SDK publishes avatar A/V to a Daily room.
          type: string
          const: daily
        properties:
          $ref: '#/components/schemas/DailyTransportProperties'
          description: >-
            Daily room credentials LemonSlice uses to join and publish avatar
            A/V. If not provided, LemonSlice will create a new room at an
            additional cost of 0.51 credits per participant minute.
    WebSocketLiveKitTransportParameters:
      type: object
      required:
        - transport_type
        - livekit_properties
      properties:
        transport_type:
          description: Send audio over WebSocket and publish avatar A/V to LiveKit.
          type: string
          const: websocket-livekit
        livekit_properties:
          $ref: '#/components/schemas/WebSocketLiveKitProperties'
          description: >-
            LiveKit room credentials LemonSlice uses to join and publish avatar
            A/V.
    WebSocketDailyTransportParameters:
      type: object
      required:
        - transport_type
        - daily_properties
      properties:
        transport_type:
          description: Send audio over WebSocket and publish avatar A/V to Daily.
          type: string
          const: websocket-daily
        daily_properties:
          $ref: '#/components/schemas/WebSocketDailyProperties'
          description: >-
            Daily room credentials LemonSlice uses to join and publish avatar
            A/V.
    SessionCommonParameters:
      type: object
      properties:
        agent_prompt:
          description: >-
            A high-level system prompt that subtly influences the avatar's
            movements, expressions, and emotional demeanor. This prompt is best
            used to suggest general affect or demeanor (for example, 'feel
            excited' or 'look sad') rather than precise or deterministic
            actions.
          type: string
          default: a person talking
        agent_idle_prompt:
          description: >-
            A high-level system prompt that influences the avatar's movements,
            expressions, and emotional demeanor during the idle state.
          type: string
          default: a serious person
        idle_timeout:
          description: >-
            Idle timeout in seconds. If a negative number is provided, the
            session will have no idle timeout. We **strongly** discourage
            disabling the idle timeout during development to avoid excessive
            credit usage.
          type: integer
          default: 60
        response_done_timeout:
          description: >-
            Time in seconds to wait without receiving new audio bytes before
            marking the response as complete. Some TTS models do not send an end
            response event, or do not send it in a timely manner. This parameter
            enables detection of response completion when such events are
            missing or delayed. This parameter can also be used to ensure proper
            conversation flow with multi-message LLMs (e.g. `gpt-realtime-2`).
          type:
            - number
            - 'null'
          default: null
          x-mint:
            post:
              - 'default: null'
        audio_sample_rate:
          description: >-
            Sample rate, in Hz, of the audio sent to LemonSlice. LemonSlice
            publishes its audio at the same rate.
          type: integer
          enum:
            - 16000
            - 24000
          default: 16000
        aspect_ratio:
          description: Output aspect ratio for the avatar video.
          type: string
          enum:
            - 2x3
            - 9x16
            - 1x1
          default: 2x3
        model:
          description: >-
            Model variant. Leave `null` to use the normal flagship model.
            `"flash"` is still accepted for backwards compatibility and is the
            same as leaving this unset.
          type:
            - string
            - 'null'
          enum:
            - cwm-1
            - cwm-1-lite
            - cartoon
            - flash
            - pro
            - null
          default: null
          x-mint:
            post:
              - 'default: null'
        edit_image:
          description: >-
            Boolean. If True, the source image is reframed before the session
            starts. Defaults to True for accounts created after September 22,
            2026. See [Avatar image
            tips](/prompting-guide/avatar-image-tips#how-to-get-the-best-quality-avatars).
          type:
            - boolean
            - 'null'
        edit_image_variant:
          description: >-
            Framing to generate when `edit_image` runs: `standing` (default),
            `bust` (default when using CWM), `sitting`, or `portrait`.
          type:
            - string
            - 'null'
          enum:
            - standing
            - bust
            - sitting
            - portrait
            - null
    SessionImageParameters:
      type: object
      properties:
        agent_image_url:
          description: >-
            A URL to an avatar image to use. The image should be 368x560 pixels.
            LemonSlice automatically center-crops images that do not match the
            expected dimensions. Provide either `agent_image_url` or `agent_id`,
            but not both.
          type: string
          format: uri
          example: https://cdn.lemonslice.com/avatars/avatar.png
        agent_id:
          description: >-
            The ID of a LemonSlice avatar. Provide either `agent_id` or
            `agent_image_url`, but not both. If provided, avatar-configured
            settings are used as defaults for `agent_prompt`,
            `agent_idle_prompt`, and `idle_timeout`.
          type: string
          example: agent_abc123
    LiveKitTransportProperties:
      type: object
      required:
        - livekit_url
        - livekit_token
      properties:
        livekit_url:
          type: string
          format: uri
          example: wss://lemonslice-pb123.livekit.cloud
        livekit_token:
          type: string
          example: eyJhbGciOiJIUzI1NiIsInR5a...
      additionalProperties: true
      example:
        livekit_url: wss://lemonslice-pb123.livekit.cloud
        livekit_token: eyJhbGciOiJIUzI1NiIsInR5a...
    DailyTransportProperties:
      type: object
      properties:
        daily_url:
          description: Daily room URL to use.
          type: string
          format: uri
          example: https://your-domain.daily.co/your-room
        daily_token:
          description: Daily token for authenticating with the room.
          type: string
          example: eyJhbGciOiJIUzI1NiIsInR5a...
        enable_recording:
          description: >-
            Enable Daily call recording. If set, recordings_bucket must also be
            provided. Enabling recording incurs an additional charge of 0.378
            credits per minute.
          type: string
          enum:
            - cloud
            - cloud-audio-only
            - local
            - raw-tracks
        recordings_bucket:
          description: >-
            The S3 bucket configuration where recordings will be saved. Follows
            the Daily recording bucket specification.
          type: object
          properties:
            bucket_name:
              description: The name of the S3 bucket.
              type: string
            bucket_region:
              description: The AWS region of the S3 bucket.
              type: string
            assume_role_arn:
              description: The ARN of the IAM role for Daily to assume for storage.
              type: string
            allow_api_access:
              description: >-
                Whether Daily's recording access link API should allow
                downloading the recording.
              type: boolean
          required:
            - bucket_name
            - bucket_region
            - assume_role_arn
      dependentRequired:
        enable_recording:
          - recordings_bucket
      additionalProperties: true
      example:
        daily_url: https://your-domain.daily.co/your-room
        daily_token: eyJhbGciOiJIUzI1NiIsInR5a...
    WebSocketLiveKitProperties:
      description: LiveKit egress room credentials for the `websocket-livekit` transport.
      type: object
      required:
        - livekit_url
        - livekit_token
      properties:
        livekit_url:
          description: >-
            LiveKit server URL of the room LemonSlice should join and publish
            avatar A/V into.
          type: string
          format: uri
          example: wss://your-project.livekit.cloud
        livekit_token:
          description: >-
            LiveKit access token with publish permission that LemonSlice uses to
            join the room.
          type: string
          example: eyJhbGciOiJIUzI1NiIsInR5a...
        simulcast:
          description: >-
            Enable WebRTC simulcast, which publishes multiple resolutions of the
            avatar video so subscribers receive the best quality their bandwidth
            allows. LiveKit only.
          type: boolean
          default: false
        video_codec:
          description: Video codec for the published avatar track. LiveKit only.
          type: string
          enum:
            - vp8
            - h264
            - vp9
            - av1
            - h265
          default: vp8
        scalability_mode:
          description: >-
            SVC scalability mode. Applied only when `video_codec` is `vp9` or
            `av1`; ignored otherwise. LiveKit only.
          type:
            - string
            - 'null'
          enum:
            - L1T1
            - L1T2
            - L1T3
            - L2T1
            - L2T2
            - L2T3
            - L2T1_KEY
            - L2T2_KEY
            - L2T3_KEY
            - L3T1
            - L3T2
            - L3T3
            - L3T1_KEY
            - L3T2_KEY
            - L3T3_KEY
            - null
          default: null
          x-mint:
            post:
              - 'default: null'
      additionalProperties: false
      example:
        livekit_url: wss://your-project.livekit.cloud
        livekit_token: eyJhbGciOiJIUzI1NiIsInR5a...
    WebSocketDailyProperties:
      description: Daily egress room credentials for the `websocket-daily` transport.
      type: object
      required:
        - daily_url
        - daily_token
      properties:
        daily_url:
          description: Daily room URL LemonSlice should join and publish avatar A/V into.
          type: string
          format: uri
          example: https://your-domain.daily.co/room-name
        daily_token:
          description: >-
            Daily meeting token with publish permission that LemonSlice uses to
            join the room.
          type: string
          example: eyJhbGciOiJIUzI1NiIsInR5a...
      additionalProperties: false
      example:
        daily_url: https://your-domain.daily.co/room-name
        daily_token: eyJhbGciOiJIUzI1NiIsInR5a...
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Your LemonSlice API token.

````

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