curl --request POST \
--url 'https://api.elkapi.com/v1/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": false
}'
import requests
url = "https://api.elkapi.com/v1/completions"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": False
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/completions";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": false
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"id": "id",
"object": "text_completion",
"created": 1,
"model": "gpt-5.5",
"choices": [
{
"text": "你好,请介绍一下你自己",
"index": 1,
"finish_reason": "finish_reason"
}
],
"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
}
}
}
原生 OpenAI 格式
Completions
- 基于给定提示创建文本补全
POST
/
v1
/
completions
curl --request POST \
--url 'https://api.elkapi.com/v1/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": false
}'
import requests
url = "https://api.elkapi.com/v1/completions"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": False
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/completions";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": false
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"id": "id",
"object": "text_completion",
"created": 1,
"model": "gpt-5.5",
"choices": [
{
"text": "你好,请介绍一下你自己",
"index": 1,
"finish_reason": "finish_reason"
}
],
"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
}
}
}
curl --request POST \
--url 'https://api.elkapi.com/v1/completions' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": false
}'
import requests
url = "https://api.elkapi.com/v1/completions"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": False
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1/completions";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"model": "gpt-5.5",
"prompt": "一只小猫在阳光下的花园里奔跑,电影感,高细节",
"max_tokens": 1024,
"temperature": 1,
"stream": false
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"id": "id",
"object": "text_completion",
"created": 1,
"model": "gpt-5.5",
"choices": [
{
"text": "你好,请介绍一下你自己",
"index": 1,
"finish_reason": "finish_reason"
}
],
"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
}
}
}
Authorizations
string
必填
所有接口均需要使用 Bearer Token 进行认证。在请求头中添加:
Authorization: Bearer YOUR_API_KEY
Body
string
默认值:"gpt-5.5"
必填
示例:
gpt-5.5string or array<string>
必填
integer
number
number
integer
boolean
string or array<string>
string
boolean
Response
string
string
示例:
text_completioninteger
string
默认值:"gpt-5.5"
示例:
gpt-5.5⌘I