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

# Quickstart

> Submit your first image task and wait for its result.

This guide uses the unified asynchronous task API. You need an API key and a
runtime that can make HTTPS requests.

<Warning>
  Keep API keys on the server. Never embed them in browser code, mobile apps,
  screenshots, or public repositories.
</Warning>

## 1. Submit a task

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.yingtu.ai/v1/task/submit \
    --header 'Authorization: Bearer $YINGTU_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "gemini-3.1-flash-image",
      "input": {
        "prompt": "A paper-cut landscape under soft studio light",
        "aspect_ratio": "1:1",
        "resolution": "1K"
      }
    }'
  ```

  ```python Python theme={null}
  import os
  import requests

  response = requests.post(
      "https://api.yingtu.ai/v1/task/submit",
      headers={"Authorization": f"Bearer {os.environ['YINGTU_API_KEY']}"},
      json={
          "model": "gemini-3.1-flash-image",
          "input": {
              "prompt": "A paper-cut landscape under soft studio light",
              "aspect_ratio": "1:1",
              "resolution": "1K",
          },
      },
      timeout=30,
  )
  response.raise_for_status()
  task = response.json()
  print(task["task_id"])
  ```

  ```javascript Node.js theme={null}
  const response = await fetch("https://api.yingtu.ai/v1/task/submit", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.YINGTU_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "gemini-3.1-flash-image",
      input: {
        prompt: "A paper-cut landscape under soft studio light",
        aspect_ratio: "1:1",
        resolution: "1K",
      },
    }),
  });

  if (!response.ok) throw new Error(`Submit failed: ${response.status}`);
  const task = await response.json();
  console.log(task.task_id);
  ```
</CodeGroup>

A successful submission returns HTTP `202`:

```json theme={null}
{
  "task_id": "task_01JY8K6M6B4YQ3R8H4T6V2Z1AB",
  "status": "queued",
  "created_at": "2026-09-02T00:00:00Z"
}
```

## 2. Read the task

```bash theme={null}
curl --request GET \
  --url https://api.yingtu.ai/v1/task/task_01JY8K6M6B4YQ3R8H4T6V2Z1AB \
  --header 'Authorization: Bearer $YINGTU_API_KEY'
```

<Tabs>
  <Tab title="In progress">
    Keep polling while `status` is `queued` or `processing`. Use bounded
    exponential backoff instead of a tight loop.
  </Tab>

  <Tab title="Succeeded">
    Read `output.assets`, then copy the media to storage you control if the URL
    is temporary.
  </Tab>

  <Tab title="Failed">
    Inspect `error.code` and retry only when the error class is retryable.
  </Tab>
</Tabs>

<Card title="Open the interactive request builder" icon="play" href="/en/api-reference/submit-task">
  Explore the request schema and generated examples in the API Playground.
</Card>
