Appearance
OpenAI聊天格式
OpenAI聊天格式
POST/v1/chat/completionsGemini 图片生成
请求头 (Headers)
| 参数名 | 类型 | 必选 | 描述 | 示例 |
|---|---|---|---|---|
Authorization | string | 否 | 鉴权令牌 | Bearer ******************** |
请求体 (Request Body)
Content-Type: application/json
| 字段 | 类型 | 必选 | 描述 |
|---|---|---|---|
| model | string | 是 | |
| stream | boolean | 是 | |
| messages | array of object | 是 | |
| messages[].role | string | 否 | |
| messages[].content | string | 否 | |
| extra_body | object | 是 | |
| extra_body.google | object | 是 | |
| extra_body.google.image_config | object | 是 | |
| extra_body.google.image_config.aspect_ratio | string | 是 | |
| extra_body.google.image_config.image_size | string | 是 | |
| contents | array of object | 是 | |
| contents[].role | string | 否 | |
| contents[].parts | array of object | 否 | |
| contents[].parts[].text | string | 否 |
请求体示例
json
{
"model": "string",
"stream": true,
"messages": [
{
"role": "string",
"content": "string"
}
],
"extra_body": {
"google": {
"image_config": {
"aspect_ratio": "string",
"image_size": "string"
}
}
},
"contents": [
{
"role": "string",
"parts": [
{
"text": "string"
}
]
}
]
}返回响应 (Responses)
200 - 成功
| 字段 | 类型 | 描述 |
|---|---|---|
| id | string | |
| model | string | |
| object | string | |
| created | integer | |
| choices | array of object | |
| choices[].index | integer | |
| choices[].message | object | |
| choices[].message.role | string | |
| choices[].message.content | string | |
| choices[].finish_reason | string | |
| usage | object | |
| usage.prompt_tokens | integer | |
| usage.completion_tokens | integer | |
| usage.total_tokens | integer |
响应示例
json
{
"id": "string",
"model": "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
}
}