聊天接口
POST
https://api.chatkore.com/v1/chat/completions
请求参数
Header 参数
Authorization
string
必需
示例值:
Bearer sk-xxxxxxxx
Content-Type
string
必需
示例值:
application/json
Body 参数application/json
要使用的模型的 ID。
model
string
必需
messages
array [object {3}]
必需
content
必需
role
string
消息作者的角色。
tool_call_id
string
必需
max_tokens
integer
可选
top_p
integer
可选
logit_bias
null
可选
user
string
可选
n
integer
可选
stop
string
可选
stream
boolean
可选
presence_penalty
integer
可选
temperature
integer
可选
frequency_penalty
integer
可选
response_format
object
可选
type
string
必需
json_schema
object
可选
seed
integer
可选
tools
array [object {2}]
可选
type
string
必需
function
object
必需
tool_choice
可选
Any of
示例
{
"model": "string",
"messages": [
{
"content": "string",
"role": "string",
"tool_call_id": "string"
}
],
"max_tokens": 0,
"top_p": 0,
"logit_bias": null,
"user": "string",
"n": 0,
"stop": "string",
"stream": true,
"presence_penalty": 0,
"temperature": 0,
"frequency_penalty": 0,
"response_format": {
"type": "string",
"json_schema": {
"description": "string",
"name": "string",
"strict": true,
"schema": {}
}
},
"seed": 0,
"tools": [
{
"type": "string",
"function": {
"description": "string",
"name": "string",
"parameters": {}
}
}
],
"tool_choice": "string"
}
示例代码
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://api.chatkore.com/v1/chat/completions' \
--header 'Authorization: Bearer sk-xxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw ''
返回响应
🟢200成功
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
必需
system_fingerprint
string
必需
示例
{
"id": "string",
"object": "string",
"created": 0,
"choices": [
{
"index": 0,
"message": {
"role": "string",
"content": "string",
"tool_calls": [
{
"id": "string",
"type": "string",
"function": {
"name": "string",
"arguments": "string"
}
}
]
},
"finish_reason": "string"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
},
"system_fingerprint": "string"
}
修改于 2025-01-20 04:21:18