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

# 快速开始

> 通过两条已认证的来源兼容入口提交并查询 GPT Image 2 文生图任务。

开始前，请先[获取 Yir API Key](/zh/getting-started/authentication)，并设置 `YIR_API_KEY`。

<Note>
  一个幂等键只代表一个逻辑请求。相同请求重试时复用它，新任务则生成新值。
</Note>

<Tabs>
  <Tab title="KIE 兼容">
    提交后从 `data.taskId` 读取任务 ID，再通过 `recordInfo` 查询。

    ```bash theme={null}
    curl --request POST \
      --url "https://gateway.yir.ai/kie/api/v1/jobs/createTask" \
      --header "Authorization: Bearer $YIR_API_KEY" \
      --header "Content-Type: application/json" \
      --header "Idempotency-Key: $YIR_IDEMPOTENCY_KEY" \
      --data '{"model":"gpt-image-2-text-to-image","input":{"prompt":"A quiet observatory above a sea of clouds","resolution":"1K","aspect_ratio":"1:1"}}'
    ```
  </Tab>

  <Tab title="APIMart 兼容">
    提交后从 `data[0].task_id` 读取任务 ID，再通过任务路径查询。

    ```bash theme={null}
    curl --request POST \
      --url "https://gateway.yir.ai/apimart/v1/images/generations" \
      --header "Authorization: Bearer $YIR_API_KEY" \
      --header "Content-Type: application/json" \
      --header "Idempotency-Key: $YIR_IDEMPOTENCY_KEY" \
      --data '{"model":"gpt-image-2","prompt":"A quiet observatory above a sea of clouds","size":"1:1","resolution":"1k","n":1}'
    ```
  </Tab>
</Tabs>

轮询必须设置合理间隔和总期限。网络超时或活动状态只表示结果未知或任务仍在运行，不代表生成已经失败。
