# Run an AI Image Generator task V2 for text to image.

AI tasks are asynchronous. Prefer webhook-based completion handling when the feature supports webhooks. Configure your webhook endpoint, verify webhook signatures, and use the received `task_id` to query the task result after a `success` or `error` notification. See the [webhook integration guide](/develop/webhook.md) for setup and verification details.
If webhooks are not supported for the feature, or if your integration cannot use webhooks, implement polling. After starting an AI task, keep polling the task status endpoint at the given `polling_interval` until the task status is either `success` or `error`.
Do not stop polling a running task for longer than the allowed polling window. If the task is not polled in time, the task may expire; a later status check can return `InvalidTaskId` even if processing finished, and the consumed units may still be charged.

Endpoint: POST /s2s/v2.0/task/text-to-image/youcam
Security: BearerAuthenticationV2

## Request fields (application/json):

  - `model` (string, required)
    Model name.
    Enum: "youcam-image-v2"

  - `prompt` (string, required)
    A positive prompt describing the image content, style, and composition you want. Supports Chinese and English. Maximum length is 800 characters. Each Chinese character, letter, digit, or symbol counts as one character.
    Example: A sitting orange cat with a joyful expression, lively and adorable, highly realistic.

  - `negative_prompt` (string)
    A negative prompt describing what you do not want in the image. Supports Chinese and English. Maximum length is 500 characters.
    Example: Low resolution, low quality, distorted limbs, malformed fingers, oversaturated colors, wax-like appearance, no facial details, overly smooth surfaces, AI-generated look. Chaotic composition. Blurry or…

  - `size` (string)
    Output image resolution, formatted as width*height.  Supported resolutions and their aspect ratios: - 1664*928 (default): 16:9 - 1472*1104: 4:3 - 1328*1328: 1:1 - 1104*1472: 3:4 - 928*1664: 9:16
    Enum: "1664*928", "1472*1104", "1328*1328", "1104*1472", "928*1664"

  - `prompt_extend` (boolean)
    Enable smart prompt rewriting. The model optimizes the positive prompt. Does not affect the negative prompt.
    Enum: true, false

## Response 200 fields (application/json):

  - `status` (integer)
    Response status
    Example: 200

  - `data` (object)

  - `data.task_id` (string)
    ID of this task. Task result is valid to query by this ID for 24 hours.
    Example: grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe

## Response 400 fields (application/json):

  - `status` (integer)
    Response status
    Example: 400

  - `error` (string)
    Error message
    Example: The operation could not be completed

  - `error_code` (string)
    Error code:
* InvalidParameters - Invalid request parameters
* CreditInsufficiency - Insufficient unit to run
* BadRequest - Unexpected request parameter
* InvalidStyleGroup - Invalid style group id
* InvalidStyle - Invalid style id
    Enum: "InvalidParameters", "CreditInsufficiency", "InvalidStyleGroup", "InvalidStyle", "BadRequest"

## Response 401 fields (application/json):

  - `status` (integer)
    Response status
    Example: 401

  - `error` (string)
    Example: Invalid API key

## Response 429 fields (application/json):

  - `status` (integer)
    Response status
    Example: 429

  - `error` (string)
    Example: Too many requests

