curl --request POST \
--url 'https://api.elkapi.com/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": false,
"max_tokens": 1024,
"response_format": "json"
}'
import requests
url = "https://api.elkapi.com/v1/chat/completions"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": False,
"max_tokens": 1024,
"response_format": "json"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/chat/completions";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": false,
"max_tokens": 1024,
"response_format": "json"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"id": "id",
"object": "chat.completion",
"created": 1,
"model": "gpt-5.5",
"choices": [
{
"index": 1,
"message": {
"role": "user",
"content": "你好,请介绍一下你自己",
"name": "name",
"tool_calls": [
{
"id": {},
"type": {},
"function": {}
}
],
"tool_call_id": "tool_call_id",
"reasoning_content": "reasoning_content"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1,
"prompt_tokens_details": {
"cached_tokens": 1,
"text_tokens": 1,
"audio_tokens": 1,
"image_tokens": 1
},
"completion_tokens_details": {
"text_tokens": 1,
"audio_tokens": 1,
"reasoning_tokens": 1
}
},
"system_fingerprint": "system_fingerprint"
}
{
"error": {
"message": "message",
"type": "type",
"param": "param",
"code": "code"
}
}
{
"error": {
"message": "message",
"type": "type",
"param": "param",
"code": "code"
}
}
原生 OpenAI 格式
Chat Completions
- 根据对话历史创建模型响应。支持流式和非流式响应。
- 兼容 OpenAI Chat Completions API。
POST
/
v1
/
chat
/
completions
curl --request POST \
--url 'https://api.elkapi.com/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": false,
"max_tokens": 1024,
"response_format": "json"
}'
import requests
url = "https://api.elkapi.com/v1/chat/completions"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": False,
"max_tokens": 1024,
"response_format": "json"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/chat/completions";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": false,
"max_tokens": 1024,
"response_format": "json"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"id": "id",
"object": "chat.completion",
"created": 1,
"model": "gpt-5.5",
"choices": [
{
"index": 1,
"message": {
"role": "user",
"content": "你好,请介绍一下你自己",
"name": "name",
"tool_calls": [
{
"id": {},
"type": {},
"function": {}
}
],
"tool_call_id": "tool_call_id",
"reasoning_content": "reasoning_content"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1,
"prompt_tokens_details": {
"cached_tokens": 1,
"text_tokens": 1,
"audio_tokens": 1,
"image_tokens": 1
},
"completion_tokens_details": {
"text_tokens": 1,
"audio_tokens": 1,
"reasoning_tokens": 1
}
},
"system_fingerprint": "system_fingerprint"
}
{
"error": {
"message": "message",
"type": "type",
"param": "param",
"code": "code"
}
}
{
"error": {
"message": "message",
"type": "type",
"param": "param",
"code": "code"
}
}
curl --request POST \
--url 'https://api.elkapi.com/v1/chat/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": false,
"max_tokens": 1024,
"response_format": "json"
}'
import requests
url = "https://api.elkapi.com/v1/chat/completions"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": False,
"max_tokens": 1024,
"response_format": "json"
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/chat/completions";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "你好,请介绍一下你自己"
}
],
"temperature": 1,
"stream": false,
"max_tokens": 1024,
"response_format": "json"
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"id": "id",
"object": "chat.completion",
"created": 1,
"model": "gpt-5.5",
"choices": [
{
"index": 1,
"message": {
"role": "user",
"content": "你好,请介绍一下你自己",
"name": "name",
"tool_calls": [
{
"id": {},
"type": {},
"function": {}
}
],
"tool_call_id": "tool_call_id",
"reasoning_content": "reasoning_content"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1,
"prompt_tokens_details": {
"cached_tokens": 1,
"text_tokens": 1,
"audio_tokens": 1,
"image_tokens": 1
},
"completion_tokens_details": {
"text_tokens": 1,
"audio_tokens": 1,
"reasoning_tokens": 1
}
},
"system_fingerprint": "system_fingerprint"
}
{
"error": {
"message": "message",
"type": "type",
"param": "param",
"code": "code"
}
}
{
"error": {
"message": "message",
"type": "type",
"param": "param",
"code": "code"
}
}
Authorizations
string
必填
所有接口均需要使用 Bearer Token 进行认证。在请求头中添加:
Authorization: Bearer YOUR_API_KEY
Body
string
默认值:"gpt-5.5"
必填
模型 ID示例:
gpt-5.5array<object>
必填
number
默认值:"1"
采样温度
number
默认值:"1"
核采样参数
integer
默认值:"1"
生成数量
boolean
默认值:"false"
是否流式响应
string or array<string>
停止序列
integer
最大生成 Token 数
integer
最大补全 Token 数
number
默认值:"0"
number
默认值:"0"
object
string
integer
string
推理强度 (用于支持推理的模型)可选值:
low、medium、higharray<string>
Response
string
string
示例:
chat.completioninteger
string
默认值:"gpt-5.5"
示例:
gpt-5.5array<object>
object
string