Gemini 视觉理解接口 - 图片分析与问答
Gemini 3.8 Flash 已列在 Chat 兼容与 Gemini 原生目录。Chat 使用 messages;原生使用 contents。需要原生思考、文件或工具字段时,查看 Gemini 3.8 Flash 协议选择。
在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token
Authorization: Bearer ********************
请求参数
完整 JSON 请求体
{
"model": "gemini-3.8-flash",
"stream": false,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "这张图片是什么"
},
{
"type": "image_url",
"image_url": {
"url": "https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png"
}
}
]
}
],
"temperature": 0.9,
"max_tokens": 400
}
请求示例代码
curl --fail-with-body --request POST 'https://api.apizt.com/v1/chat/completions' \
--header "Authorization: Bearer ${tokenba_API_KEY}" \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gemini-3.8-flash",
"stream": false,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "这张图片是什么"
},
{
"type": "image_url",
"image_url": {
"url": "https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png"
}
}
]
}
],
"temperature": 0.9,
"max_tokens": 400
}'async function main() {
const headers = {
"Authorization": "Bearer " + process.env.tokenba_API_KEY,
"Content-Type": "application/json"
};
const body = JSON.stringify({
"model": "gemini-3.8-flash",
"stream": false,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "这张图片是什么"
},
{
"type": "image_url",
"image_url": {
"url": "https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png"
}
}
]
}
],
"temperature": 0.9,
"max_tokens": 400
});
const response = await fetch("https://api.apizt.com/v1/chat/completions", { method: "POST", headers, body });
if (!response.ok) throw new Error("HTTP " + response.status + ": " + await response.text());
console.log(await response.text());
}
main().catch(console.error);import os
import requests
headers = {"Authorization": "Bearer " + os.environ["tokenba_API_KEY"]}
payload = {'model': 'gemini-3.8-flash',
'stream': False,
'messages': [{'role': 'user',
'content': [{'type': 'text', 'text': '这张图片是什么'},
{'type': 'image_url',
'image_url': {'url': 'https://github.com/dianping/cat/raw/master/cat-home/src/main/webapp/images/logo/cat_logo03.png'}}]}],
'temperature': 0.9,
'max_tokens': 400}
response = requests.post('https://api.apizt.com/v1/chat/completions', headers=headers, json=payload, timeout=120)
response.raise_for_status()
print(response.text)返回响应
Chat Completions 文本位于 choices[].message.content。以下为结构示例,不代表实际调用结果。
{
"id": "chatcmpl_demo",
"object": "chat.completion",
"model": "gemini-3.8-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 8,
"total_tokens": 18
}
}
当前模型与版本
依据 apizt 价格页,同步于 。以下型号按目录声明的协议与本页用途筛选;不代表所有参数和功能通用。切换前请核对型号说明、令牌分组与参数差异。Gemini 原生接口需同时替换 URL 中的模型 ID。
| 模型 ID | 能力标签 | 支持分组 |
|---|---|---|
gemini-3.8-flash | 对话,识图,工具 | 分组(9)
|
gemini-3.1-pro-preview | 对话,思考,多模态 | 分组(9)
|
gemini-3.5-flash-lite | 对话,工具,识图 | 分组(9)
|
gemini-3-flash-preview | 对话,识图,工具 | 分组(9)
|
gemini-3.7-flash | 对话,识图,工具 | 分组(9)
|
gemini-3.1-flash-lite | 对话,工具,识图 | 分组(9)
|
gemini-3.5-flash | 对话,工具,识图 | 分组(9)
|
gemini-2.5-pro | 对话,识图,思考 | 分组(8)
|
共列入 16 个候选型号。查看完整模型、版本与接口目录。