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

# 同步图片生成

> 客户端能够等待完整 Nano Banana 响应时，使用 Gemini 原生 generateContent。

当客户端能够保持连接直到生成结束时，调用标准 Gemini 原生方法：

```http theme={"system"}
POST /v1beta/models/{model}:generateContent
```

模型 ID 位于路径中，请求体包含 `contents` 和可选的 `generationConfig`，
不存在额外的 YingTu 顶层 envelope。

执行方式不能消除模型差异。Pro 4K 的响应体和生成时间可能明显高于 Lite 1K；
决定保持长连接前，先确认[模型和尺寸](/cn/models/image/nano-banana/comparison)。

## 适用场景

同步方式适合交互工具、服务端操作和简单集成，前提是客户端及中间代理的超时时间明显长于图片生成时间。
HTTP 响应直接包含最终的 Gemini `candidates` 数组。

<Warning>
  客户端或代理超时过短，可能在图片返回前断开连接。调用方无法安全维持长连接时，请改用异步任务。
</Warning>

## 安全读取结果

`content.parts` 中的文字和图片顺序不固定。请遍历并查找所有带 `inlineData` 的部分，
再使用实际返回的 `inlineData.mimeType` 保存 Base64 图片字节。

<Card title="打开同步 Playground" icon="play" href="/cn/api-reference/generate-content">
  查看模型、请求体、身份验证和响应结构。
</Card>
