创建对话补全
curl --request POST \
--url https://apiany.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Write a concise product tagline for APIAny.AI."
}
],
"temperature": 0.7
}
'import requests
url = "https://apiany.ai/v1/chat/completions"
payload = {
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Write a concise product tagline for APIAny.AI."
}
],
"temperature": 0.7
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-5.4',
messages: [{role: 'user', content: 'Write a concise product tagline for APIAny.AI.'}],
temperature: 0.7
})
};
fetch('https://apiany.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiany.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-5.4',
'messages' => [
[
'role' => 'user',
'content' => 'Write a concise product tagline for APIAny.AI.'
]
],
'temperature' => 0.7
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiany.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a concise product tagline for APIAny.AI.\"\n }\n ],\n \"temperature\": 0.7\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiany.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a concise product tagline for APIAny.AI.\"\n }\n ],\n \"temperature\": 0.7\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiany.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a concise product tagline for APIAny.AI.\"\n }\n ],\n \"temperature\": 0.7\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"input_tokens": 123,
"output_tokens": 123,
"cached_input_tokens": 123
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}Chat
创建对话补全
OpenAI 兼容的 Chat Completions 接口。当前以非 streaming 调用为主。
POST
/
v1
/
chat
/
completions
创建对话补全
curl --request POST \
--url https://apiany.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Write a concise product tagline for APIAny.AI."
}
],
"temperature": 0.7
}
'import requests
url = "https://apiany.ai/v1/chat/completions"
payload = {
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Write a concise product tagline for APIAny.AI."
}
],
"temperature": 0.7
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-5.4',
messages: [{role: 'user', content: 'Write a concise product tagline for APIAny.AI.'}],
temperature: 0.7
})
};
fetch('https://apiany.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiany.ai/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-5.4',
'messages' => [
[
'role' => 'user',
'content' => 'Write a concise product tagline for APIAny.AI.'
]
],
'temperature' => 0.7
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiany.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a concise product tagline for APIAny.AI.\"\n }\n ],\n \"temperature\": 0.7\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiany.ai/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a concise product tagline for APIAny.AI.\"\n }\n ],\n \"temperature\": 0.7\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiany.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-5.4\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Write a concise product tagline for APIAny.AI.\"\n }\n ],\n \"temperature\": 0.7\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"input_tokens": 123,
"output_tokens": 123,
"cached_input_tokens": 123
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
示例:
"gpt-5.4"
Show child attributes
Show child attributes
采样温度。
必填范围:
0 <= x <= 2核采样累计概率。
必填范围:
0 <= x <= 1max_completion_tokens 的兼容旧别名。APIAny 仅在所选模型路由需要新字段时转换。
必填范围:
x >= 1思考过程与最终答案合计的最大 Token 数。Kimi K3 省略时默认 131072,最高支持 1048576。
必填范围:
1 <= x <= 1048576Kimi K3 的思考强度。K3 始终思考,目前仅支持 max。
可用选项:
max 最多 4 个停止序列。
生成候选条数。
必填范围:
x >= 1必填范围:
-2 <= x <= 2必填范围:
-2 <= x <= 2尽量可复现的采样种子。
强制 JSON 对象或 JSON Schema 输出,如 { "type": "json_object" }。
模型可调用的工具/函数声明。
工具选择:'auto' | 'none' | 'required' | { type: 'function', function: { name } }。
必填范围:
0 <= x <= 20终端用户标识,用于风险审计。
为 true 时通过 SSE 流式返回增量(OpenAI chat.completion.chunk),以 'data: [DONE]' 结束。
⌘I