> ## 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.

export const AvatarVariantCarousel = () => {
  const assetPrefix = typeof window !== "undefined" && (/^\/docs(\/|$)/).test(window.location.pathname) ? "/docs" : "";
  const asset = path => assetPrefix + path;
  const sets = [{
    id: "set1",
    original: asset("/images/avatar-variants/set1/original.jpg"),
    slides: [{
      id: "portrait",
      label: "Portrait",
      src: asset("/images/avatar-variants/set1/portrait.jpg")
    }, {
      id: "bust",
      label: "Bust",
      src: asset("/images/avatar-variants/set1/bust.jpg")
    }, {
      id: "standing",
      label: "Standing",
      src: asset("/images/avatar-variants/set1/standing.jpg")
    }, {
      id: "sitting",
      label: "Sitting",
      src: asset("/images/avatar-variants/set1/sitting.jpg")
    }]
  }, {
    id: "set2",
    original: asset("/images/avatar-variants/set2/original.jpg"),
    slides: [{
      id: "portrait",
      label: "Portrait",
      src: asset("/images/avatar-variants/set2/portrait.jpg")
    }, {
      id: "bust",
      label: "Bust",
      src: asset("/images/avatar-variants/set2/bust.jpg")
    }, {
      id: "standing",
      label: "Standing",
      src: asset("/images/avatar-variants/set2/standing.jpg")
    }, {
      id: "sitting",
      label: "Sitting",
      src: asset("/images/avatar-variants/set2/sitting.jpg")
    }]
  }, {
    id: "set3",
    original: asset("/images/avatar-variants/set3/original.jpg"),
    slides: [{
      id: "portrait",
      label: "Portrait",
      src: asset("/images/avatar-variants/set3/portrait.jpg")
    }, {
      id: "bust",
      label: "Bust",
      src: asset("/images/avatar-variants/set3/bust.jpg")
    }, {
      id: "standing",
      label: "Standing",
      src: asset("/images/avatar-variants/set3/standing.jpg")
    }, {
      id: "sitting",
      label: "Sitting",
      src: asset("/images/avatar-variants/set3/sitting.jpg")
    }]
  }];
  const [setIndex, setSetIndex] = useState(0);
  const [slideIndex, setSlideIndex] = useState(0);
  const slides = sets[setIndex].slides;
  const slide = slides[slideIndex];
  const goTo = nextSlide => {
    setSlideIndex((nextSlide + slides.length) % slides.length);
  };
  return <div className="av-carousel not-prose" role="region" aria-roledescription="carousel" aria-label="Avatar variant examples" tabIndex={0} onKeyDown={event => {
    if (event.key === "ArrowLeft") {
      event.preventDefault();
      goTo(slideIndex - 1);
    }
    if (event.key === "ArrowRight") {
      event.preventDefault();
      goTo(slideIndex + 1);
    }
  }}>
      <div className="av-carousel-layout">
        <div className="av-carousel-originals">
          {sets.map((item, index) => <button key={item.id} type="button" className="av-carousel-original" aria-pressed={index === setIndex} aria-label={"Original " + (index + 1)} onClick={() => setSetIndex(index)}>
              <img src={item.original} alt="" />
            </button>)}
        </div>

        <div className="av-carousel-main">
          <div className="av-carousel-stage-wrap">
            <button type="button" className="av-carousel-nav av-carousel-nav--prev" aria-label="Previous variant" onClick={() => goTo(slideIndex - 1)}>
              <svg viewBox="0 0 16 16" aria-hidden="true">
                <path d="M10.2 2.8 4.9 8l5.3 5.2" />
              </svg>
            </button>

            <img className="av-carousel-image" src={slide.src} alt={slide.label} />
            <div className="av-carousel-label">{slide.label}</div>

            <button type="button" className="av-carousel-nav av-carousel-nav--next" aria-label="Next variant" onClick={() => goTo(slideIndex + 1)}>
              <svg viewBox="0 0 16 16" aria-hidden="true">
                <path d="M5.8 2.8 11.1 8l-5.3 5.2" />
              </svg>
            </button>
          </div>

          <div className="av-carousel-thumbs">
            {slides.map((item, index) => <button key={item.id} type="button" className="av-carousel-thumb" aria-label={item.label} aria-current={index === slideIndex ? "true" : undefined} onClick={() => setSlideIndex(index)}>
                <img src={item.src} alt="" />
              </button>)}
          </div>
        </div>
      </div>
    </div>;
};

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

## Example variants

<AvatarVariantCarousel />


## 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`, or sending an empty or unknown
            `variant_ids` list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Provide exactly one of image_url or image_base64
        '401':
          description: Authentication denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Invalid API key
        '403':
          description: This workspace is not enabled for Avatar Optimization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: 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/Error'
              example:
                detail: content_policy_violation
        '500':
          description: Unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
        '502':
          description: Variant generation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail: Variant generation failed
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
    Error:
      type: object
      properties:
        detail:
          type: string
    ServerError:
      type: object
      properties:
        detail:
          type: string
    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. `bust` is recommended when
        [actions](/reference/cwm-1) are enabled.
      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.

````