Skip to content

OpenAI聊天格式

OpenAI聊天格式

POST /v1/chat/completions

Gemini 图片生成

请求头 (Headers)

参数名类型必选描述示例
Authorizationstring鉴权令牌Bearer ********************

请求体 (Request Body)

Content-Type: application/json

字段类型必选描述
modelstring
streamboolean
messagesarray of object
messages[].rolestring
messages[].contentstring
extra_bodyobject
extra_body.googleobject
extra_body.google.image_configobject
extra_body.google.image_config.aspect_ratiostring
extra_body.google.image_config.image_sizestring
contentsarray of object
contents[].rolestring
contents[].partsarray of object
contents[].parts[].textstring

请求体示例

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 - 成功

字段类型描述
idstring
modelstring
objectstring
createdinteger
choicesarray of object
choices[].indexinteger
choices[].messageobject
choices[].message.rolestring
choices[].message.contentstring
choices[].finish_reasonstring
usageobject
usage.prompt_tokensinteger
usage.completion_tokensinteger
usage.total_tokensinteger

响应示例

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
  }
}

Released under the MIT License.