openapi: 3.0.1
info:
title: ''
description: ''
version: 1.0.0
paths:
/v1/chat/completions:
post:
summary: 图片生成
deprecated: false
description: >-
Gemini 也提供了图像生成能力,作为一种替代方案。与 Imagen 3.0 相比,Gemini
的图像生成更适合于需要上下文理解和推理的场景,而非追求极致的艺术表现和视觉质量。
更高的视觉质量 → 相比 exp 版,图像更锐利、更丰富、更清晰。
更准确的文本呈现 → 生成的视觉中,文本更加精准、干净、易读。
显著减少过滤拦截 → 得益于更智能、宽松的过滤机制,创作时几乎不再被打断。
说明:
模型 id:gemini-2.0-flash-preview-image-generation
费率(输入→输出):
0.1
→
0.1→0.4/M tokens
需要新增参数来体验新特性 "modalities":["text","image"]
图片以 Base64 编码形式传递与输出
作为实验模型,建议明确指出 “输出图片”,否则可能只有文本
输出图片的默认高度为 1024px
python 调用需要最新的 openai sdk 支持,请先运行 pip install -U openai
了解更多请访问 Gemini 官方文档
tags:
- 模型接口/Google Gemini/OpenAI兼容接口(推荐)
parameters:
- name: Authorization
in: header
description: ''
required: true
example: sk-
schema:
type: string
default: sk-
requestBody:
content:
application/json:
schema:
type: object
properties:
prompt:
type: string
description: 所需图像的文本描述。最大长度为 1000 个字符。
'n':
type: string
description: 要生成的图像数。必须介于 1 和 10 之间。
size:
type: string
description: 生成图像的大小。必须是256x256、512x512或 1024x1024之一。
x-apifox-orders:
- prompt
- 'n'
- size
required:
- prompt
example:
model: gemini-2.0-flash-preview-image-generation
stream: true
messages:
- role: user
content: A cat in a tree
responses:
'200':
description: ''
content:
application/json:
schema:
type: object
properties:
created:
type: integer
data:
type: array
items:
type: string
description: 生成的链接
x-apifox-orders:
- created
- data
required:
- created
- data
example:
created: 1589478378
data:
- url: https://...
- url: https://...
headers: {}
x-apifox-name: 成功
security: []
x-apifox-folder: 模型接口/Google Gemini/OpenAI兼容接口(推荐)
x-apifox-status: released
x-run-in-apifox: https://app.apifox.com/web/project/5503894/apis/api-319585167-run
components:
schemas: {}
securitySchemes: {}
servers:
- url: '{{base_url}}'
description: 测试环境
- url: https://newapi.eronmind.com
description: 正式环境
security: []