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

# 文生图

### 文生图

你可以通过文本提示生成图片，文本提示可以是任何描述性的句子，模型会根据这些描述生成相应的图片：

```bash theme={null}
curl --location --request POST 'https://geekai.co/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--data '{
    "model":"gpt-image-1",
    "prompt":"画一只可爱的小猫在草丛中玩耍"
}'
```

### 异步生图

画图操作默认是同步的，即请求会等待直到图片生成完成：

```bash theme={null}
curl --location --request POST 'https://geekai.co/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--data '{
    "model":"gpt-image-2",
    "prompt":"画一只可爱的小猫在草丛中玩耍"
}'
```

如果你需要异步处理，可以在请求中添加 `async` 参数并将其设置为 `true`：

```bash theme={null}
curl --location --request POST 'https://geekai.co/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $GEEKAI_API_KEY' \
--data '{
    "model":"gpt-image-2",
    "prompt":"画一只可爱的小猫在草丛中玩耍",
    "async": true
}'
```

对于异步生成的图片，你需要使用返回的任务 ID 来查询生成状态和获取图片结果：

```bash theme={null}
curl --location --request GET 'https://geekai.co/api/v1/images/{task_id}' \
--header 'Authorization: Bearer $GEEKAI_API_KEY'
```

一旦任务状态为 `succeed`，你就可以获取到生成的图片 URL。

更多画图 API 参数细节，请参考[画图 API 手册](https://docs.geekai.co/cn/api/image/generations)。
