> ## 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 avatar variants

> Generate optimized avatar images from a source photo. Each requested variant reframes the character into a pose and crop that works well as a LemonSlice avatar reference image. Use the returned URL when creating a session.

> [!NOTE]
>
> **Enterprise only.** This endpoint is available to enterprise customers. Contact [support@lemonslice.com](mailto:support@lemonslice.com) to get access.

## Example variants

Previous variant

Next variant


## OpenAPI

````yaml openapi.json POST /liveai/avatar-variants
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/avatar-variants:
    post:
      summary: Create avatar variants
      description: >-
        Generate optimized avatar images from a source photo. Each requested
        variant reframes the character into a pose and crop that works well as a
        LemonSlice avatar reference image. Use the returned URL when creating a
        session.
      operationId: createAvatarVariants
      requestBody:
        required: true
        description: >-
          Provide `variant_ids` and exactly one image source: `image_url` or
          `image_base64`.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AvatarVariantsInput'
            examples:
              by_image_url:
                summary: Optimize from a public image URL
                value:
                  image_url: https://cdn.lemonslice.com/avatars/avatar.png
                  variant_ids:
                    - standing
              by_image_base64:
                summary: Optimize from inline base64
                value:
                  image_base64: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...
                  variant_ids:
                    - sitting
      responses:
        '200':
          description: >-
            Successfully generated variants. Keys are the requested variant ids;
            values are hosted image URLs. Variants that fail to generate are
            omitted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvatarVariantsResponse'
              example:
                standing: https://cdn.lemonslice.com/variants/standing.jpg
        '400':
          description: >-
            Invalid arguments. Typically missing an image source, providing both
            `image_url` and `image_base64`, sending an empty or unknown
            `variant_ids` list, or an `image_url` that could not be downloaded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error: Provide exactly one of image_url or image_base64
        '401':
          description: Authentication denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error: Invalid API key
        '403':
          description: This workspace is not enabled for Avatar Optimization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error: Endpoint is not enabled for this workspace.
        '422':
          description: The source image was rejected by the content policy.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error: content_policy_violation
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error: Internal server error
        '502':
          description: Variant generation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error: Variant generation failed
        '503':
          description: >-
            Temporarily unavailable. The request did not complete because of a
            transient infrastructure issue; it is safe to retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
              example:
                error: Temporarily unavailable. Please try again.
components:
  schemas:
    AvatarVariantsInput:
      oneOf:
        - $ref: '#/components/schemas/AvatarVariantsUrlInput'
          title: Image URL
        - $ref: '#/components/schemas/AvatarVariantsBase64Input'
          title: Image Bytes
    AvatarVariantsResponse:
      type: object
      description: Map of generated variant id to a hosted image URL.
      additionalProperties:
        type: string
        format: uri
      example:
        standing: https://cdn.lemonslice.com/variants/standing.jpg
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: What went wrong.
    AvatarVariantsUrlInput:
      type: object
      required:
        - image_url
        - variant_ids
      properties:
        image_url:
          description: A publicly reachable URL of the source image.
          type: string
          format: uri
          example: https://cdn.lemonslice.com/avatars/avatar.png
        variant_ids:
          $ref: '#/components/schemas/AvatarVariantIds'
    AvatarVariantsBase64Input:
      type: object
      required:
        - image_base64
        - variant_ids
      properties:
        image_base64:
          description: Raw image bytes, base64-encoded. A `data:` URL prefix is accepted.
          type: string
          example: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...
        variant_ids:
          $ref: '#/components/schemas/AvatarVariantIds'
    AvatarVariantIds:
      description: >-
        Variants to generate. See [Avatar image
        tips](/prompting-guide/avatar-image-tips#how-to-get-the-best-quality-avatars).
      type: array
      minItems: 1
      items:
        type: string
        enum:
          - standing
          - bust
          - sitting
          - portrait
  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.