OmwAIOmwAI
API GuideAPI ReferenceProgramming Tools
Nano Banana Pro

Image Generation (Sync)

Nano Banana Pro synchronous image generation endpoints (Chat Completions and Images API compatible)

In addition to the async task API from the previous page, Nano Banana Pro also supports OpenAI-compatible synchronous generation: the request waits for the image to finish generating and returns the result directly in the response, so no task polling is required.

Pick either of the two sync styles:

  • Chat Completions style: POST /v1/chat/completions
  • Images API style: POST /v1/images/generations

Billing model

Like the async endpoints, the endpoints on this page are billed under the nano-banana-pro model. Configure a group price for it on the channel, and your token must be allowed to use that model's group.

Sync vs async

Sync calls return only after the image has finished generating, so a single request can take a while (depending on queueing) — well suited to "submit and get the image right away". For batch submission or long waits, prefer the async API (submit + poll).

Style 1: Chat Completions (POST /v1/chat/completions)

Call it like a Chat Completions request with model set to nano-banana-pro; authentication works the same as for regular chat models. Clients already wired to OpenAI Chat Completions can reuse the integration as-is.

This style also supports image-to-image: in the example panel below, switch between the Text-to-image / Image-to-image request bodies. For image-to-image, set the content of the user message to an array and pass the reference image (URL or Base64 data URI) in an image_url part — matching OpenAI multimodal input.

POST
/v1/chat/completions

Authorization

BearerAuth

AuthorizationBearer <token>

使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx 令牌需开通对应模型的调用权限。

In: header

Request Body

application/json

model*string

模型名称,同步图片生成固定填 nano-banana-pro

messages*

对话消息列表。生成图片时在 user 消息中传入文本提示词即可;如需参考图(图生图),可在 content 数组中附带 image_url 部件。

n?integer

生成数量(默认 1)。同步接口通常仅支持 1,需要一次生成多张时建议使用异步任务接口

Range1 <= value <= 128
size?string

图片尺寸,如 1024x1024、1536x1024、1024x1536 等

quality?string

画质等级:low / medium / high / auto

background?string

背景:transparent / opaque / auto / none

output_format?string

输出格式:png / jpeg / webp

moderation?string

内容审核:auto / low / high

user?string

终端用户标识,用于审计与追踪

Response Body

application/json

application/json

curl -X POST "https://www.omwai.xyz/v1/chat/completions" \  -H "Content-Type: application/json" \  -d '{    "model": "nano-banana-pro",    "stream": false,    "messages": [      {        "role": "user",        "content": "一只可爱的猫,赛博朋克风格,霓虹灯背景"      }    ],    "size": "1024x1024",    "quality": "high"  }'
{
  "id": "chatcmpl-01J8ABCDEFGHIJKLMNOPQRST",
  "object": "chat.completion",
  "created": 1788256630,
  "model": "nano-banana-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "string"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
{
  "code": "string",
  "message": "string"
}

Style 2: Images API (POST /v1/images/generations)

Call it like the OpenAI Images API with model set to nano-banana-pro. Supported parameters match the async endpoints (prompt, n, size, quality, background, output_format, moderation, etc.). When generation completes, the data array directly contains the final images (url or b64_json fields).

POST
/v1/images/generations

Authorization

BearerAuth

AuthorizationBearer <token>

使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx 令牌需开通对应模型的调用权限。

In: header

Request Body

application/json

model*string

模型名称,同步图片生成固定填 nano-banana-pro

prompt*string

提示词,描述希望生成的图片内容

stream?boolean

是否以 SSE 流式返回生成进度与结果(image_generation.* 事件),默认 false。开启后响应为 text/event-stream,需按 SSE 逐帧解析

style?string

透传参数,网关原样转发上游,仅当上游模型支持时生效

n?integer

生成数量(默认 1)。同步接口通常仅支持 1,需要一次生成多张时建议使用异步任务接口

Range1 <= value <= 128
size?string

图片尺寸,如 1024x1024、1536x1024、1024x1536 等

quality?string

画质等级:low / medium / high / auto

background?string

背景:transparent / opaque / auto / none

output_format?string

输出格式:png / jpeg / webp

moderation?string

内容审核:auto / low / high

user?string

终端用户标识,用于审计与追踪

Response Body

application/json

application/json

curl -X POST "https://www.omwai.xyz/v1/images/generations" \  -H "Content-Type: application/json" \  -d '{    "model": "nano-banana-pro",    "prompt": "a cute cat, cyberpunk style, neon background",    "n": 1,    "size": "1024x1024",    "quality": "high"  }'
{
  "created": 1788256630,
  "data": [
    {
      "url": "string",
      "b64_json": "string",
      "revised_prompt": "string"
    }
  ],
  "usage": {
    "total_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0,
    "input_tokens_details": {
      "text_tokens": 0,
      "image_tokens": 0
    }
  }
}
{
  "code": "string",
  "message": "string"
}

How is this guide?

Last updated on