- (必读)网站使用教程
- (必读)前言
- 批量请求示例
- 常见问题及解决办法
- 聊天模型
- 音乐生成
- 绘画模型
- Midjourney
- Dalle和Gpt-image-1和Sora_image
- Flux
- Grok
- Stable-diffusion
- 即梦AI
- 可灵AI
- 音频模型
- 视频生成
- 查询令牌用量GET
- 查询令牌限额GET
聊天接口(函数调用)
POST
https://api.apicore.ai/v1/chat/completions
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token示例:
Authorization: Bearer ********************
Header 参数
Content-Type
string
可选
示例值:
application/json
Authorization
string
可选
示例值:
Bearer sk-xxxx
Body 参数application/json
model
string
模型
messages
array [object {2}]
消息列表
role
string
消息角色
content
string
消息内容
tools
array [object {2}]
工具列表
type
string
类型
function
function
object
函数
示例
{
"model": "string",
"messages": [
{
"role": "string",
"content": "string"
}
],
"tools": [
{
"type": "string",
"function": {
"name": "string",
"description": "string",
"parameters": {
"type": "string",
"properties": {},
"required": [
"string"
],
"additionalProperties": true
},
"strict": true
}
}
]
}
示例代码
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.apicore.ai/v1/chat/completions' \
--header 'Authorization: Bearer sk-xxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "string",
"messages": [
{
"role": "string",
"content": "string"
}
],
"tools": [
{
"type": "string",
"function": {
"name": "string",
"description": "string",
"parameters": {
"type": "string",
"properties": {},
"required": [
"string"
],
"additionalProperties": true
},
"strict": true
}
}
]
}'
返回响应
🟢200成功
application/json
Body
id
string
必需
object
string
必需
created
integer
必需
model
string
必需
choices
array [object {4}]
必需
index
integer
可选
message
object
可选
logprobs
null
可选
finish_reason
string
可选
usage
object
必需
prompt_tokens
integer
必需
completion_tokens
integer
必需
total_tokens
integer
必需
prompt_tokens_details
object
必需
completion_tokens_details
object
必需
system_fingerprint
string
必需
示例
{
"id": "string",
"object": "string",
"created": 0,
"model": "string",
"choices": [
{
"index": 0,
"message": {
"role": "string",
"content": null,
"tool_calls": [
{
"id": "string",
"type": "string",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"refusal": null
},
"logprobs": null,
"finish_reason": "string"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0,
"audio_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"system_fingerprint": "string"
}