对话补全:Gemini 3.6 Flash(OpenAI 兼容)
curl --request POST \
--url https://api.apiyi.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-3.6-flash",
"messages": [
{
"role": "user",
"content": "用一句话介绍你自己"
}
]
}
'import requests
url = "https://api.apiyi.com/v1/chat/completions"
payload = {
"model": "gemini-3.6-flash",
"messages": [
{
"role": "user",
"content": "用一句话介绍你自己"
}
]
}
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: 'gemini-3.6-flash', messages: [{role: 'user', content: '用一句话介绍你自己'}]})
};
fetch('https://api.apiyi.com/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://api.apiyi.com/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' => 'gemini-3.6-flash',
'messages' => [
[
'role' => 'user',
'content' => '用一句话介绍你自己'
]
]
]),
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://api.apiyi.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gemini-3.6-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"用一句话介绍你自己\"\n }\n ]\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://api.apiyi.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gemini-3.6-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"用一句话介绍你自己\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/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\": \"gemini-3.6-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"用一句话介绍你自己\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"model": "<string>",
"choices": [
{
"message": {
"role": "<string>",
"content": "<string>",
"tool_calls": [
{}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}Gemini 3.6 Flash
Gemini 3.6 Flash Chat API 參考
Gemini 3.6 Flash Chat Completions API 參考與線上除錯:OpenAI 相容格式,支援 reasoning_effort 分檔、流式、Function Call、視覺。
POST
/
v1
/
chat
/
completions
对话补全:Gemini 3.6 Flash(OpenAI 兼容)
curl --request POST \
--url https://api.apiyi.com/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gemini-3.6-flash",
"messages": [
{
"role": "user",
"content": "用一句话介绍你自己"
}
]
}
'import requests
url = "https://api.apiyi.com/v1/chat/completions"
payload = {
"model": "gemini-3.6-flash",
"messages": [
{
"role": "user",
"content": "用一句话介绍你自己"
}
]
}
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: 'gemini-3.6-flash', messages: [{role: 'user', content: '用一句话介绍你自己'}]})
};
fetch('https://api.apiyi.com/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://api.apiyi.com/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' => 'gemini-3.6-flash',
'messages' => [
[
'role' => 'user',
'content' => '用一句话介绍你自己'
]
]
]),
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://api.apiyi.com/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gemini-3.6-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"用一句话介绍你自己\"\n }\n ]\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://api.apiyi.com/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gemini-3.6-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"用一句话介绍你自己\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/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\": \"gemini-3.6-flash\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"用一句话介绍你自己\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"model": "<string>",
"choices": [
{
"message": {
"role": "<string>",
"content": "<string>",
"tool_calls": [
{}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123
}
}右側 Playground 可直接除錯:在 Authorization 填
Bearer sk-your-api-key,預設示例 reasoning_effort: "low",點擊發送即可看到響應。模型預設開啟深度思考(計入輸出計費),除錯建議保持 low;複雜任務改
high 並把 max_tokens 給到 4000+。搜尋 grounding、程式碼執行等原生工具本端點不支援,請改用 原生線上除錯。概覽與實測資料見 Gemini 3.6 Flash 概覽。引數說明速查
| 引數 | 型別 | 必填 | 說明 |
|---|---|---|---|
model | string | ✓ | 固定 gemini-3.6-flash |
messages | array | ✓ | OpenAI 標準訊息陣列;content 可為多模態陣列(image_url 支援 data URL) |
max_tokens | int | 輸出配額,開思考建議 2000+(思考計入輸出) | |
reasoning_effort | string | low / medium / high 思考分檔,實測生效 | |
stream | bool | SSE 流式 | |
response_format | object | json_schema 結構化輸出,實測可用 | |
tools | array | Function Call 工具列表,實測可用 |
響應要點
- 思考消耗看
usage.completion_tokens_details.reasoning_tokens(實測正常回顯) - 思考正文(reasoning_content)本端點不回顯;需要看思考過程請用原生端點
includeThoughts - 模型名拼寫錯誤會返回錯誤而非靜默降級,注意核對
gemini-3.6-flash
授權
在请求头中添加 Authorization: Bearer YOUR_API_KEY
主體
application/json
固定 gemini-3.6-flash
OpenAI 标准消息数组
Show child attributes
Show child attributes
输出配额;开思考时建议 2000+(思考计入输出)
SSE 流式输出
思考分档
可用選項:
low, medium, high 结构化输出,支持 json_schema
Function Call 工具列表
這個頁面有幫助嗎?
⌘I