API reference
🇺🇸 English
  • 🇨🇳 Chinese
  • 🇺🇸 English
  1. Chat
API reference
🇺🇸 English
  • 🇨🇳 Chinese
  • 🇺🇸 English
  • Chat Models
    • Chat
      • Create chat completion
        POST
      • vision
        POST
    • OpenAI-Realtime
    • Completions
      • Instruct
    • Audio
      • Transcriptions
      • Translations
      • Speech
    • Image generation
      • DALL·E 3
    • Embeddings
      • Create
    • Models
      • model list
    • Help
      • 常见问题及解决办法
  • Anthropic
    • Anthropic Claude
      POST
  • Suno
    • Generate music
      POST
    • Generate lyrics
      POST
    • Upload music
      POST
    • Music concat
      POST
    • Fetch task
      GET
    • Fetch batch tasks
      POST
  • Udio
    • Generate music
      POST
    • Fetch task
      GET
  • Midjourney API
    • Quick
    • Task Submit
      • Imagine
      • Action
      • Modal
      • Blend
      • Describe
      • Shorten
      • Upload discord
    • Get Task
      • Fetch task by ids
      • Fetch task by id
      • Get seed
  • Flux
    • Official
      • Generate
      • Finetune
      • Fetch task
    • OpenAI Dalle3
      POST
  • Recraft
    • Official
      • Generate Image
      • Vectorize Image
      • Remove Background
      • Clarity Upscale
      • Generative Upscale
      • Create style
    • OpenAI Dalle3
  • Ideogram
    • Generate
    • Remix
    • Edit
    • Upscale
    • Describe
  • Luma
    • Official
      • Generate
      • Fetch task
    • Own format
      • Submit
        • Generate
        • Get video of no mark
        • 扩展视频
      • Get task
        • Get task
        • Get batch task
  • Runway
    • Official
      • image to video
      • get task
    • reverse
      • text to video
      • image to video
      • video2video
      • Act-one
      • Get task
  • Kling-API
    • Callback
    • Generate image
    • Text 2 Video
    • Image 2 Video
    • Video extend
    • Get task
    • lip-sync
    • kolors-virtual-try-on
  • Replicate
    • Generate
    • Get
  • MiniMax
    • Generate video
    • Get task
    • Get file
  1. Chat

vision

POST
/v1/chat/completions
Last modified:2025-02-05 11:12:25

Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Header Params
Content-Type
string 
required
Example:
application/json
Accept
string 
required
Example:
application/json
Authorization
string 
optional
Example:
Bearer {{YOUR_API_KEY}}
Body Params application/json
model
string 
required
要使用的模型的 ID。有关哪些模型适用于聊天 API 的详细信息,请参阅模型端点兼容性表。
messages
array [object {2}] 
required
以聊天格式生成聊天完成的消息。
role
string 
optional
content
string 
optional
temperature
integer 
optional
使用什么采样温度,介于 0 和 2 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如 0.2)将使输出更加集中和确定。 我们通常建议改变这个或top_p但不是两者。
top_p
integer 
optional
一种替代温度采样的方法,称为核采样,其中模型考虑具有 top_p 概率质量的标记的结果。所以 0.1 意味着只考虑构成前 10% 概率质量的标记。 我们通常建议改变这个或temperature但不是两者。
n
integer 
optional
为每个输入消息生成多少个聊天完成选项。
stream
boolean 
optional
如果设置,将发送部分消息增量,就像在 ChatGPT 中一样。当令牌可用时,令牌将作为纯数据服务器发送事件data: [DONE]发送,流由消息终止。有关示例代码,请参阅 OpenAI Cookbook 。
stop
string 
optional
API 将停止生成更多令牌的最多 4 个序列。
max_tokens
integer 
optional
聊天完成时生成的最大令牌数。 输入标记和生成标记的总长度受模型上下文长度的限制。
presence_penalty
number 
optional
-2.0 和 2.0 之间的数字。正值会根据到目前为止是否出现在文本中来惩罚新标记,从而增加模型谈论新主题的可能性。 查看有关频率和存在惩罚的更多信息。
frequency_penalty
number 
optional
-2.0 和 2.0 之间的数字。正值会根据新标记在文本中的现有频率对其进行惩罚,从而降低模型逐字重复同一行的可能性。 查看有关频率和存在惩罚的更多信息。
logit_bias
null 
optional
修改指定标记出现在完成中的可能性。 接受一个 json 对象,该对象将标记(由标记器中的标记 ID 指定)映射到从 -100 到 100 的关联偏差值。从数学上讲,偏差会在采样之前添加到模型生成的 logits 中。确切的效果因模型而异,但 -1 和 1 之间的值应该会减少或增加选择的可能性;像 -100 或 100 这样的值应该导致相关令牌的禁止或独占选择。
user
string 
optional
代表您的最终用户的唯一标识符,可以帮助 OpenAI 监控和检测滥用行为。了解更多。
Example
{
  "model": "gpt-4-vision-preview",
  "stream": false,
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "这张图片有什么"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png"
          }
        }
      ]
    }
  ],
  "max_tokens": 400
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location -g --request POST '/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ' \
--header 'Authorization;' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "gpt-4-vision-preview",
  "stream": false,
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "这张图片有什么"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png"
          }
        }
      ]
    }
  ],
  "max_tokens": 400
}'

Responses

🟢200OK
application/json
Body
id
string 
required
object
string 
required
created
integer 
required
choices
array [object {3}] 
required
index
integer 
optional
message
object 
optional
finish_reason
string 
optional
usage
object 
required
prompt_tokens
integer 
required
completion_tokens
integer 
required
total_tokens
integer 
required
Example
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "\n\nHello there, how may I assist you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}
Previous
Create chat completion
Next
Instruct
Built with