openapi: 3.0.1
info:
title: ''
description: ''
version: 1.0.0
paths:
/v1/images/generations:
post:
summary: 图片生成 / Imagen 4
deprecated: false
description: >-
Gemini 绘图和视频生成指引
Imagen 绘图
Imagen 是 Google 推出的先进图像生成 AI 模型系列,能够根据文本提示创建高质量、逼真的图像。本指南将帮助您了解如何使用
Imagen 系列 API 生成图像,包括参数设置、模型选择和代码示例。
可用模型列表:
imagen-4.0-generate-preview-05-20:最新的正式预览版
imagen-4.0-ultra-generate-exp-05-20:更高级的 4.0 实验款
imagen-3.0-generate-002:3.0 正式版
目前 Imagen 仅支持英文提示词(prompt),集成时建议增加自动翻译,让用户能够无障碍使用
绘制大量文本的表现不稳定,建议只绘制重点关键词
抢先体验期间,Imagen 系列模型同价,后续可能会按官方正式价格调整。
模型参数
Imagen 目前仅支持英文提示词,并提供以下参数:
numberOfImages: 要生成的图像数量,范围从 1 到 4(含)。默认值为 4。另外注意
imagen-4.0-ultra-generate-exp-05-20 单次只能生成 1 张。
aspectRatio: 更改生成图像的宽高比。支持的值有 “1:1”、“3:4”、“4:3”、“9:16” 和 “16:9”。默认值为
“1:1”。
personGeneration: 允许模型生成人物图像。支持以下值:
“DONT_ALLOW”: 阻止生成人物图像。
“ALLOW_ADULT”: 生成成人图像,但不生成儿童图像。这是默认值。
tags:
- 模型接口/Google Gemini/OpenAI兼容接口(推荐)
parameters:
- name: Accept
in: header
description: ''
required: true
example: application/json
schema:
type: string
default: application/json
- name: Authorization
in: header
description: ''
required: true
example: sk-
schema:
type: string
default: sk-
- name: Content-Type
in: header
description: ''
required: true
example: application/json
schema:
type: string
requestBody:
content:
application/json:
schema:
type: object
properties:
model:
type: string
description: 要使用的模型的 ID。有关哪些模型适用于聊天 API 的详细信息
messages:
type: array
items:
type: object
properties:
role:
type: string
content:
type: string
x-apifox-orders:
- role
- content
required:
- role
- content
temperature:
type: string
description: >-
使用什么采样温度,介于 0 和 2 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如
0.2)将使输出更加集中和确定。 我们通常建议改变这个或top_p但不是两者。
top_p:
type: string
description: >-
一种替代温度采样的方法,称为核采样,其中模型考虑具有 top_p 概率质量的标记的结果。所以 0.1 意味着只考虑构成前
10% 概率质量的标记。 我们通常建议改变这个或temperature但不是两者。
'n':
type: string
description: 为每个输入消息生成多少个聊天完成选项。
stream:
type: string
description: >-
如果设置,将发送部分消息增量,就像在 ChatGPT 中一样。当令牌可用时,令牌将作为纯数据服务器发送事件data:
[DONE]发送,流由消息终止。
stop:
type: string
description: API 将停止生成更多令牌的最多 4 个序列。
max_tokens:
type: string
description: 聊天完成时生成的最大令牌数。 输入标记和生成标记的总长度受模型上下文长度的限制。
presence_penalty:
type: string
description: '-2.0 和 2.0 之间的数字。正值会根据到目前为止是否出现在文本中来惩罚新标记,从而增加模型谈论新主题的可能性'
frequency_penalty:
type: string
description: '-2.0 和 2.0 之间的数字。正值会根据新标记在文本中的现有频率对其进行惩罚,从而降低模型逐字重复同一行的可能性。'
logit_bias:
type: string
description: >-
修改指定标记出现在完成中的可能性。 接受一个 json 对象,该对象将标记(由标记器中的标记 ID 指定)映射到从
-100 到 100 的关联偏差值。从数学上讲,偏差会在采样之前添加到模型生成的 logits
中。确切的效果因模型而异,但 -1 和 1 之间的值应该会减少或增加选择的可能性;像 -100 或 100
这样的值应该导致相关令牌的禁止或独占选择。
user:
type: string
description: 代表您的最终用户的唯一标识符,可以帮助 OpenAI 监控和检测滥用行为。
x-apifox-orders:
- model
- messages
- temperature
- top_p
- 'n'
- stream
- stop
- max_tokens
- presence_penalty
- frequency_penalty
- logit_bias
- user
required:
- model
- messages
example:
model: imagen-4.0-generate-preview-06-06
prompt: a portrait of a sheepadoodle wearing a cape
response_format: b64_json
'n': 1
responses:
'200':
description: ''
content:
application/json:
schema:
type: object
properties:
id:
type: string
description: ID 编号
object:
type: string
created:
type: string
choices:
type: array
items:
type: object
properties:
index:
type: string
message:
type: object
properties:
role:
type: string
content:
type: string
x-apifox-orders:
- role
- content
required:
- role
- content
finish_reason:
type: string
x-apifox-orders:
- index
- message
- finish_reason
required:
- index
- message
- finish_reason
usage:
type: object
properties:
prompt_tokens:
type: string
completion_tokens:
type: string
total_tokens:
type: string
x-apifox-orders:
- prompt_tokens
- completion_tokens
- total_tokens
required:
- prompt_tokens
- completion_tokens
- total_tokens
x-apifox-orders:
- id
- object
- created
- choices
- usage
required:
- id
- object
- created
- choices
- usage
example:
id: string
object: string
created: 0
choices:
- index: 0
message:
role: string
content: string
finish_reason: string
usage:
prompt_tokens: 0
completion_tokens: 0
total_tokens: 0
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-319592052-run
components:
schemas: {}
securitySchemes: {}
servers:
- url: '{{base_url}}'
description: 测试环境
- url: https://newapi.eronmind.com
description: 正式环境
security: []