- 引言
- 在线调试说明
- 发出请求
- 中转站基本介绍
- Chat模型
- ChatGpt 接口
- ChatGPT音频(Audio)
- ChatGPT聊天(Chat)
- ChatGPT自动补全(Completions)
- ChatGPT嵌入(Embeddings)
- Anthropic Claude 接口
- 谷歌Gemini
- 文生图模型
- 文生视频模型
- GPTs 相关
- 文生音乐 Suno
- 系统API
- Python配置方式
- python openai官方库(使用AutoGPT,langchain等)
- python 连续对话
- python 使用 语音转文本
- python 使用文本转语音
- python 使用Embeddings 向量化
- python 调用DALL·E
- python简单调用 openai function-calling demo
- python 简单langchain 调用openai demo
- python llama_index 配置
- Python使用gpt-4o识别图片-本地图片
- python 库流式输出
- gpt realtime模型调用
- python request 请求 流式输出demo
- Python基础对话
- Python使用gpt-4o识别图片
- Python使用Claude识别图片
- nodejs 配置方式
- 各种插件/软件使用教程
- 帮助中心
创建聊天函数调用 (只能非流)
POST
https://yunwu.ai/v1/chat/completions
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token示例:
Authorization: Bearer ********************
Header 参数
Content-Type
string
必需
示例值:
application/json
Accept
string
必需
示例值:
application/json
Authorization
string
可选
示例值:
Bearer {{YOUR_API_KEY}}
Body 参数application/json
model
string
必需
messages
array [object {2}]
必需
role
string
可选
content
string
可选
temperature
integer
可选
top_p
但不是两者。top_p
integer
可选
temperature
但不是两者。n
integer
可选
为每个输入消息生成多少个聊天补全选择。
stream
boolean
可选
stop
string
可选
max_tokens
integer
可选
在聊天补全中生成的最大标记数。
presence_penalty
number
可选
frequency_penalty
number
可选
logit_bias
null
可选
user
string
可选
response_format
object
可选
seen
integer
可选
tools
array[string]
必需
tool_choice
object
必需
示例
{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful customer support assistant. Use the supplied tools to assist the user."
},
{
"role": "user",
"content": "Hi, can you tell me the delivery date for my order?"
},
{
"role": "assistant",
"content": "Hi there! I can help with that. Can you please provide your order ID?"
},
{
"role": "user",
"content": "i think it is order_12345"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_delivery_date",
"description": "Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The customer's order ID."
}
},
"required": [
"order_id"
],
"additionalProperties": false
}
}
}
]
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://yunwu.ai/v1/chat/completions' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful customer support assistant. Use the supplied tools to assist the user."
},
{
"role": "user",
"content": "Hi, can you tell me the delivery date for my order?"
},
{"role": "assistant", "content": "Hi there! I can help with that. Can you please provide your order ID?"},
{"role": "user", "content": "i think it is order_12345"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_delivery_date",
"description": "Get the delivery date for a customer'\''s order. Call this whenever you need to know the delivery date, for example when a customer asks '\''Where is my package'\''",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "The customer'\''s order ID."
}
},
"required": [
"order_id"
],
"additionalProperties": false
}
}
}
]
}'
返回响应
🟢200OK
application/json
Body
id
string
必需
object
string
必需
created
integer
必需
choices
array [object {3}]
必需
index
integer
可选
message
object
可选
finish_reason
string
可选
usage
object
必需
prompt_tokens
integer
必需
completion_tokens
integer
必需
total_tokens
integer
必需
示例
{
"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
}
}
修改于 2024-11-11 15:55:00