其他模型 API 详细教程

本文介绍 Gemini、Claude、GPT、Grok 系列模型的接口地址、参数说明与调用示例。

其他模型 API 详细教程

  • 模型路由:https://token.matpool.com/v1
  • 路由规则与 OpenAI 标准一致
  • 鉴权方式:Authorization: Bearer YOUR_API_TOKEN

通用接口形式

所有模型均支持以下两种接口形式:

接口路径格式适用模型
Chat CompletionsPOST /v1/chat/completionsOpenAI 兼容格式,Authorization: Bearer <token>全部 16 个模型
MessagesPOST /v1/messagesAnthropic Messages 兼容格式,x-api-key: <token> + anthropic-version: 2023-06-01全部 16 个模型

Messages 接口说明:Messages 接口使用 Anthropic 原生 API 格式。与 Chat Completions 不同,Messages 接口的鉴权头为 x-api-key,且需要携带 anthropic-version 头。该接口支持 system 顶层参数(非 messages 数组中的 system role)、max_tokens(必填)、stop_reason 响应字段等 Anthropic 特有特性。

Messages 接口请求示例

bash
复制代码
curl https://token.matpool.com/v1/messages \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_API_TOKEN" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "Claude-Sonnet-4.6", "max_tokens": 1024, "system": "You are a helpful assistant.", "messages": [ {"role": "user", "content": "Hello!"} ] }'

Messages 接口响应格式

json
复制代码
{ "id": "chatcmpl-xxx", "type": "message", "role": "assistant", "model": "claude-4.6-sonnet", "content": [ {"type": "text", "text": "Hello! How can I help you today?"} ], "stop_reason": "end_turn", "usage": { "input_tokens": 19, "output_tokens": 75 } }

Messages 接口流式输出

bash
复制代码
curl https://token.matpool.com/v1/messages \ -H "Content-Type: application/json" \ -H "x-api-key: YOUR_API_TOKEN" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "Claude-Sonnet-4.6", "max_tokens": 1024, "stream": true, "messages": [ {"role": "user", "content": "用英文写一首关于春天的短诗"} ] }'

流式响应对应 Anthropic SSE 事件格式(message_startcontent_block_startcontent_block_deltamessage_deltamessage_stop)。

跨模型支持:Messages 接口除了 Claude 系列模型外,也适用于 GPT、Gemini、Grok 系列的所有模型。system 参数在所有模型上均可正常工作。


一、Google Gemini 模型

1.1 支持的模型

模型名称说明特点
Gemini-3.5-FlashGoogle Gemini 3.5 Flash轻量快速,低延迟,成本更优,适合高频对话
Gemini-3.1-FlashGoogle Gemini 3.1 Flash轻量推理模型,价格便宜,支持联网搜索、代码执行
Gemini-3.1-ProGoogle Gemini 3.1 Pro旗舰推理模型,支持深度思考(Thinking Levels),支持媒体解析(最高 ULTRA_HIGH),支持流式函数调用

1.2 接口地址

Gemini 模型支持两种接口形式:

Chat Completions 接口

text
复制代码
POST https://token.matpool.com/v1/chat/completions

Messages 接口(Anthropic 原生格式,跨模型通用)

text
复制代码
POST https://token.matpool.com/v1/messages

Messages 接口为跨模型通用接口,适用于所有模型。通用说明和示例请参见上文通用接口形式章节。

1.3 请求参数(Chat Completions)

通用参数

参数类型必填默认值说明
modelstring模型名称,如 Gemini-3.5-FlashGemini-3.1-FlashGemini-3.1-Pro
messagesarray对话消息列表;role 支持 systemuserassistant
temperaturenumber1.0生成随机性,范围 0.0 ~ 2.0
top_pnumber核采样阈值,范围 0.0 ~ 1.0
max_tokensinteger模型默认最大输出 Token 数
streambooleanfalse是否开启流式输出(SSE)
stopstring / array停止序列,最多 5 个
seedinteger随机种子,用于提高结果可复现性
toolsarray工具定义(Function Calling),同时支持 googleSearchcodeExecution 特殊工具
tool_choicestring / objectauto工具选择策略:autononerequired 或指定函数对象
response_formatobject输出格式控制,{ "type": "json_object" }{ "type": "json_schema", "json_schema": {...} }

Gemini 特有参数(通过 extra_body 传递)

Gemini 特有参数通过 extra_body.google 传入,不会影响 OpenAI 兼容性。

json
复制代码
{ "model": "Gemini-3.1-Pro", "messages": [...], "extra_body": { "google": { "thinking_config": { "thinking_level": "HIGH", "include_thoughts": true } } } }

thinking_config 参数

参数类型说明
thinking_levelstring思考强度级别。"HIGH"(默认,适用于复杂推理)、"MEDIUM"(平衡模式)、"LOW"(快速响应,适合高吞吐任务)。仅 Gemini-3.1-Pro 支持。
thinking_budgetinteger思考预算 Token 数。设为 0 可禁用思考。
include_thoughtsboolean是否在响应中包含思考过程。

1.4 多模态输入

Gemini 模型原生支持多种媒体类型输入,通过 OpenAI 兼容的 content 数组传入:

类型示例
文本{ "type": "text", "text": "..." }
图片{ "type": "image_url", "image_url": { "url": "https://..." } }
图片(Base64){ "type": "image_url", "image_url": { "url": "data:image/jpeg;base64,..." } }

支持的图片 MIME 类型:image/pngimage/jpegimage/webpimage/heicimage/heif

1.5 调用示例

以下所有示例均使用 curl,您可将 YOUR_API_TOKEN 替换为自己的 API Key 进行测试。

基础文本对话(Gemini-3.1-Pro)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.1-Pro", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "介绍一下 Gemini 3.1 Pro 的核心能力" } ], "temperature": 0.7, "max_tokens": 2048 }'

基础文本对话(Gemini-3.5-Flash)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.5-Flash", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "用一句话介绍量子计算" } ], "temperature": 0.7, "max_tokens": 1024 }'

基础文本对话(Gemini-3.1-Flash)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.1-Flash", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "用一句话介绍量子计算" } ], "temperature": 0.7, "max_tokens": 1024 }'

启用深度思考(Gemini-3.1-Pro)

通过 extra_body.google.thinking_config 控制思考级别:

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.1-Pro", "messages": [ { "role": "user", "content": "设计一个高并发消息队列的架构方案,要求支持百万级 QPS" } ], "extra_body": { "google": { "thinking_config": { "thinking_level": "HIGH", "include_thoughts": true } } } }'

流式输出

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.5-Flash", "messages": [ { "role": "user", "content": "用英文写一首关于春天的短诗" } ], "stream": true }'

多模态输入(图片理解)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.1-Pro", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "请详细描述这张图片的内容" }, { "type": "image_url", "image_url": { "url": "https://cdn.matpool.com/images/159cfc58_opt_token1.png" } } ] } ], "max_tokens": 1024 }'

Function Calling

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.1-Pro", "messages": [ { "role": "user", "content": "上海今天天气怎么样?" } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "获取指定城市的天气信息", "parameters": { "type": "object", "properties": { "city": { "type": "string", "description": "城市名称" } }, "required": ["city"] } } } ], "tool_choice": "auto" }'

Gemini 支持通过特殊工具名 googleSearch 启用联网搜索:

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.5-Flash", "messages": [ { "role": "user", "content": "2026年最新AI技术趋势是什么?" } ], "tools": [ { "type": "function", "function": { "name": "googleSearch", "description": "搜索网络获取最新信息", "parameters": { "type": "object", "properties": {} } } } ] }'

结构化输出(JSON Schema)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Gemini-3.1-Pro", "messages": [ { "role": "user", "content": "列出5本科幻小说,包含书名、作者和出版年份" } ], "response_format": { "type": "json_schema", "json_schema": { "name": "books", "strict": true, "schema": { "type": "object", "properties": { "books": { "type": "array", "items": { "type": "object", "properties": { "title": { "type": "string" }, "author": { "type": "string" }, "year": { "type": "integer" } }, "required": ["title", "author", "year"] } } }, "required": ["books"] } } } }'

1.6 响应格式

标准 OpenAI Chat Completions 响应格式:

json
复制代码
{ "id": "chatcmpl-xxx", "object": "chat.completion", "created": 1718000000, "model": "Gemini-3.1-Pro", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Gemini 3.1 Pro 是 Google 最新的推理模型..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 50, "completion_tokens": 200, "total_tokens": 250 } }

1.7 模型对比

特性Gemini-3.5-FlashGemini-3.1-FlashGemini-3.1-Pro
定位轻量快速模型轻量经济模型旗舰推理模型
Thinking Levels有限支持不支持LOW / MEDIUM / HIGH
媒体解析标准标准ULTRA_HIGH
Function Calling支持支持支持(含流式)
联网搜索支持支持支持
代码执行支持支持支持
结构化输出支持支持支持
延迟最低较高(深度思考时)
适用场景高频对话、快速响应、成本敏感场景高吞吐经济场景、简单推理复杂推理、代码生成、多步规划、高级分析

1.8 注意事项

  1. 模型名称大小写敏感,请严格按 Gemini-3.5-FlashGemini-3.1-FlashGemini-3.1-Pro 填写
  2. Gemini-3.1-Pro 的思考级别(thinking_level)不能与旧的 thinking_budget 同时使用,否则会返回 400 错误;Gemini-3.1-Flash 不支持思考配置
  3. 流式输出时思考内容会先于文本内容返回,客户端需正确处理
  4. 联网搜索(googleSearch)和代码执行(codeExecution)通过特殊命名的 Function Calling 工具启用
  5. Safety Settings 由平台自动配置,用户无需手动设置
  6. Gemini 对图片和文件的 MIME 类型有严格校验,不支持的格式会返回错误

二、Claude 模型

2.1 支持的模型

模型名称说明特点
Claude-Fable-5Anthropic Claude Fable 5最新旗舰模型,强力推理、编码与多模态,支持联网搜索
Claude-Opus-4.8Anthropic Claude Opus 4.8最新 Opus 模型,性能强劲,支持缓存
Claude-Opus-4.7Anthropic Claude Opus 4.7Opus 4.7 旗舰推理模型,深度思考时需清除 temperature 等参数
Claude-Opus-4.6Anthropic Claude Opus 4.6Opus 4.6 旗舰推理模型,支持 adaptive thinking
Claude-Sonnet-4.6Anthropic Claude Sonnet 4.6高性价比模型,速度与质量平衡

2.2 接口地址

Claude 模型支持两种接口形式:

Chat Completions 接口

text
复制代码
POST https://token.matpool.com/v1/chat/completions

Messages 接口(Anthropic 原生格式,推荐)

text
复制代码
POST https://token.matpool.com/v1/messages

Claude 模型推荐使用 Messages 接口,该接口为 Anthropic 原生 API 格式。鉴权使用 x-api-key 头(非 Authorization: Bearer),需携带 anthropic-version: 2023-06-01 头。system 提示词使用顶层 system 参数而非 messages 中的 system role。通用 Messages 接口说明和示例请参见上文通用接口形式章节。

2.3 请求参数(Chat Completions)

通用参数

参数类型必填默认值说明
modelstring模型名称,如 Claude-Sonnet-4.6
messagesarray对话消息列表;role 支持 systemuserassistanttool
max_tokensinteger模型默认最大输出 Token 数
temperaturenumber1.0生成随机性,范围 0.0 ~ 1.0
top_pnumber核采样阈值,范围 0.0 ~ 1.0
top_kintegerTop-K 采样
streambooleanfalse是否开启流式输出(SSE)
stopstring / array停止序列,最多 4 个
toolsarray工具定义(Function Calling)
tool_choicestring / objectauto工具选择策略:autoanynone{"type":"tool","name":"..."}
parallel_tool_callsbooleantrue是否允许并行工具调用
response_formatobject输出格式控制,{ "type": "json_object" }

扩展思考参数(Extended Thinking)

通过 reasoning_effort 参数控制思考深度:

取值说明
"low"低思考预算(1280 tokens)
"medium"中等思考预算(2048 tokens)
"high"高思考预算(4096 tokens)

联网搜索

通过 web_search_options 参数启用联网搜索:

json
复制代码
{ "web_search_options": { "search_context_size": "medium" } }

search_context_size 取值:

取值说明
"low"最多 1 次搜索调用
"medium"最多 5 次搜索调用
"high"最多 10 次搜索调用

多模态输入

Claude 模型支持图片和 PDF 输入,通过 OpenAI 兼容的 content 数组传入:

类型示例
文本{ "type": "text", "text": "..." }
图片{ "type": "image_url", "image_url": { "url": "https://..." } }
图片(Base64){ "type": "image_url", "image_url": { "url": "data:image/jpeg;base64,..." } }

支持的图片 MIME 类型:image/pngimage/jpegimage/webpimage/gif

2.4 调用示例

以下所有示例均使用 curl,您可将 YOUR_API_TOKEN 替换为自己的 API Key 进行测试。

基础文本对话

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Claude-Sonnet-4.6", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "介绍一下 Claude Sonnet 4.6 的核心能力" } ], "temperature": 0.7, "max_tokens": 1024 }'

启用扩展思考(reasoning_effort)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Claude-Opus-4.6", "messages": [ { "role": "user", "content": "设计一个高并发消息队列的架构方案" } ], "max_tokens": 2048, "reasoning_effort": "high" }'

流式输出

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Claude-Sonnet-4.6", "messages": [ { "role": "user", "content": "用英文写一首关于春天的短诗" } ], "stream": true, "max_tokens": 1024 }'

联网搜索

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Claude-Sonnet-4.6", "messages": [ { "role": "user", "content": "2026年最新AI技术趋势是什么?" } ], "web_search_options": { "search_context_size": "medium" }, "max_tokens": 2048 }'

Function Calling

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Claude-Sonnet-4.6", "messages": [ { "role": "user", "content": "北京今天天气怎么样?" } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "获取指定城市的天气信息", "parameters": { "type": "object", "properties": { "city": { "type": "string", "description": "城市名称" } }, "required": ["city"] } } } ], "tool_choice": "auto", "max_tokens": 1024 }'

多模态输入(图片理解)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Claude-Sonnet-4.6", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "请详细描述这张图片的内容" }, { "type": "image_url", "image_url": { "url": "https://cdn.matpool.com/images/159cfc58_opt_token1.png" } } ] } ], "max_tokens": 1024 }'

2.5 响应格式

标准 OpenAI Chat Completions 响应格式:

json
复制代码
{ "id": "chatcmpl-xxx", "object": "chat.completion", "created": 1718000000, "model": "claude-4.6-sonnet", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Claude Sonnet 4.6 是 Anthropic 最新的..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 50, "completion_tokens": 200, "total_tokens": 250 } }

启用扩展思考时,响应会包含 reasoning_content 字段:

json
复制代码
{ "choices": [ { "index": 0, "message": { "role": "assistant", "content": "最终输出文本...", "reasoning_content": "思考过程..." }, "finish_reason": "end_turn" } ] }

2.6 模型对比

特性Claude-Fable-5Claude-Opus-4.8Claude-Opus-4.7Claude-Opus-4.6Claude-Sonnet-4.6
定位最新旗舰最新 OpusOpus 旗舰Opus 旗舰高性价比
扩展思考支持支持支持支持
adaptive thinking支持支持
联网搜索支持支持支持支持支持
图片理解支持支持支持支持支持
Function Calling支持支持支持支持支持
流式输出支持支持支持支持支持
结构化输出支持支持支持支持支持
缓存支持支持支持
延迟中等中等较高较高

2.7 注意事项

  1. 模型名称大小写敏感,请严格按表格中的名称填写
  2. 启用扩展思考时,Claude-Opus-4.7 会自动清除 temperaturetop_ptop_k 参数(Opus 4.7 在思考模式下会拒绝这些参数)
  3. 扩展思考的 budget_tokens 必须 >= 1024,且小于 max_tokens
  4. 联网搜索(web_search_options)为顶层参数,非 tools 数组内的工具
  5. Prompt Caching 自动对 system prompt 生效,无需手动设置
  6. 图片输入自动转换为 Base64 格式发送给上游

三、GPT 模型

3.1 支持的模型

模型名称说明特点
GPT-5.5OpenAI GPT-5.5最新 GPT 模型,全面升级推理、编码与多模态能力
GPT-5.5-HighOpenAI GPT-5.5 HighGPT-5.5 高性能版,更强的推理深度
GPT-5.4OpenAI GPT-5.4旗舰推理模型,支持深度推理(reasoning_effort)
GPT-5.4-ProOpenAI GPT-5.4 Pro专业版,极致推理性能
GPT-5.4-MiniOpenAI GPT-5.4 Mini轻量经济模型,适合高频对话
GPT-5.4-NanoOpenAI GPT-5.4 Nano最轻量模型,极致性价比

3.2 接口地址

GPT 模型支持两种接口形式:

Chat Completions 接口(全部 GPT 模型)

text
复制代码
POST https://token.matpool.com/v1/chat/completions

Response API 接口(仅 GPT-5.5)

text
复制代码
POST https://token.matpool.com/v1/responses

Response API 说明:Response API 是 OpenAI 推出的新一代接口,使用 Authorization: Bearer <token> 鉴权,支持 input 字段替代 messages,响应格式为 output 数组。目前仅 GPT-5.5 支持该接口。GPT-5.4-Mini、GPT-5.4-Nano、GPT-5.4-Pro、GPT-5.5-High 等模型暂不支持。

Response API 请求示例

bash
复制代码
curl https://token.matpool.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "input": "用一句话介绍量子计算" }'

Response API 响应格式

json
复制代码
{ "id": "resp_xxx", "object": "response", "status": "completed", "model": "gpt-5.5", "output": [ { "type": "message", "role": "assistant", "content": [ { "type": "output_text", "text": "量子计算是利用量子力学原理..." } ] } ], "usage": { "input_tokens": 5093, "output_tokens": 47, "total_tokens": 5140 } }

Response API 流式输出

bash
复制代码
curl https://token.matpool.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "input": "用英文写一首关于春天的短诗", "stream": true }'

流式响应对应 OpenAI Response API SSE 事件格式(response.createdresponse.in_progressresponse.output_text.deltaresponse.completed)。

3.3 请求参数(Chat Completions)

通用参数

参数类型必填默认值说明
modelstring模型名称,如 GPT-5.5
messagesarray对话消息列表;role 支持 systemuserassistantdeveloper
max_tokensinteger模型默认最大输出 Token 数(Chat Completions 格式)
max_completion_tokensinteger最大输出 Token 数(GPT-5.5 推荐使用)
temperaturenumber1.0生成随机性,范围 0.0 ~ 2.0
top_pnumber核采样阈值,范围 0.0 ~ 1.0
streambooleanfalse是否开启流式输出(SSE)
stopstring / array停止序列
toolsarray工具定义(Function Calling),支持 web_search_preview 等特殊工具
tool_choicestring / objectauto工具选择策略:autononerequired 或指定函数对象
parallel_tool_callsbooleantrue是否允许并行工具调用
response_formatobject输出格式控制,{ "type": "json_object" }
seedinteger随机种子,用于提高结果可复现性

推理参数

通过 reasoning_effort 控制模型推理深度:

取值说明
"none"不启用推理
"low"低推理预算
"medium"中等推理预算
"high"高推理预算
"xhigh"最高推理预算

联网搜索

通过 tools 数组中的 web_search_preview 工具启用联网搜索:

json
复制代码
{ "tools": [ { "type": "web_search_preview" } ], "tool_choice": "auto" }

3.4 调用示例

以下所有示例均使用 curl,您可将 YOUR_API_TOKEN 替换为自己的 API Key 进行测试。

基础文本对话(GPT-5.5)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "介绍一下 GPT-5.5 的核心能力" } ], "temperature": 0.7, "max_tokens": 1024 }'

基础文本对话(GPT-5.4-Mini)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.4-Mini", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "用一句话介绍量子计算" } ], "temperature": 0.7, "max_tokens": 1024 }'

启用深度推理(reasoning_effort)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "messages": [ { "role": "user", "content": "设计一个高并发消息队列的架构方案" } ], "reasoning_effort": "high", "max_tokens": 2048 }'

流式输出

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "messages": [ { "role": "user", "content": "用英文写一首关于春天的短诗" } ], "stream": true, "max_tokens": 1024 }'

联网搜索

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "messages": [ { "role": "user", "content": "2026年最新AI技术趋势是什么?" } ], "tools": [ { "type": "web_search_preview" } ], "tool_choice": "auto", "max_tokens": 2048 }'

Function Calling

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "messages": [ { "role": "user", "content": "上海今天天气怎么样?" } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "获取指定城市的天气信息", "parameters": { "type": "object", "properties": { "city": { "type": "string", "description": "城市名称" } }, "required": ["city"] } } } ], "tool_choice": "auto" }'

结构化输出(JSON Object)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "GPT-5.5", "messages": [ { "role": "user", "content": "列出5本科幻小说,包含书名、作者和出版年份,以JSON格式返回" } ], "response_format": { "type": "json_object" } }'

3.5 响应格式

标准 OpenAI Chat Completions 响应格式:

json
复制代码
{ "id": "chatcmpl-xxx", "object": "chat.completion", "created": 1718000000, "model": "gpt-5.5", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "GPT-5.5 是 OpenAI 最新的..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 50, "completion_tokens": 200, "total_tokens": 250, "prompt_tokens_details": { "cached_tokens": 0 } } }

3.6 模型对比

特性GPT-5.5GPT-5.5-HighGPT-5.4GPT-5.4-ProGPT-5.4-MiniGPT-5.4-Nano
定位最新全能高性能版旗舰推理专业版轻量经济极致轻量
深度推理支持支持支持支持
联网搜索支持支持支持支持支持支持
Function Calling支持支持支持支持支持支持
结构化输出json_objectjson_objectjson_objectjson_objectjson_objectjson_object
流式输出支持支持支持支持支持支持
缓存支持支持支持
延迟中等中等较低较高最低

3.7 注意事项

  1. 模型名称大小写敏感,请严格按表格中的名称填写
  2. reasoning_effort 可取值 nonelowmediumhighxhigh,部分模型可能不支持所有级别
  3. 联网搜索通过 toolstype: "web_search_preview" 启用,非 function calling 格式
  4. max_completion_tokens 为 GPT-5.5 推荐使用的最大输出参数,max_tokens 同样兼容
  5. 缓存(Prompt Caching)自动生效,用户无需手动配置
  6. GPT-5.5 系列支持 response_format: { "type": "json_object" } 结构化输出,暂不适用于 json_schema

四、Grok 模型

4.1 支持的模型

模型名称说明特点
Grok-4.1-FastxAI Grok 4.1 Fast轻量快速模型,低延迟,适合高频对话
Grok-4.1-Fast-ReasoningxAI Grok 4.1 Fast Reasoning支持推理能力的版本,适合需要深度思考的场景

4.2 接口地址

Grok 模型支持两种接口形式:

Chat Completions 接口

text
复制代码
POST https://token.matpool.com/v1/chat/completions

Messages 接口(Anthropic 原生格式,跨模型通用)

text
复制代码
POST https://token.matpool.com/v1/messages

Messages 接口为跨模型通用接口,适用于所有模型。通用说明和示例请参见上文通用接口形式章节。

4.3 请求参数(Chat Completions)

通用参数

参数类型必填默认值说明
modelstring模型名称,如 Grok-4.1-FastGrok-4.1-Fast-Reasoning
messagesarray对话消息列表;role 支持 systemuserassistant
max_tokensinteger模型默认最大输出 Token 数
temperaturenumber1.0生成随机性,范围 0.0 ~ 2.0
top_pnumber核采样阈值,范围 0.0 ~ 1.0
streambooleanfalse是否开启流式输出(SSE)
stopstring / array停止序列
toolsarray工具定义(Function Calling)
tool_choicestring / objectauto工具选择策略:autononerequired 或指定函数对象
response_formatobject输出格式控制,{ "type": "json_object" }
seedinteger随机种子,用于提高结果可复现性

推理参数

Grok-4.1-Fast-Reasoning 支持通过 reasoning_effort 控制推理深度:

取值说明
"low"低推理预算
"medium"中等推理预算
"high"高推理预算

4.4 调用示例

以下所有示例均使用 curl,您可将 YOUR_API_TOKEN 替换为自己的 API Key 进行测试。

基础文本对话(Grok-4.1-Fast)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Grok-4.1-Fast", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "介绍一下 Grok 4.1 Fast 的核心能力" } ], "temperature": 0.7, "max_tokens": 1024 }'

基础文本对话(Grok-4.1-Fast-Reasoning)

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Grok-4.1-Fast-Reasoning", "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "设计一个高并发消息队列的架构方案" } ], "reasoning_effort": "high", "max_tokens": 2048 }'

流式输出

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Grok-4.1-Fast", "messages": [ { "role": "user", "content": "用英文写一首关于春天的短诗" } ], "stream": true, "max_tokens": 1024 }'

Function Calling

bash
复制代码
curl https://token.matpool.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -d '{ "model": "Grok-4.1-Fast", "messages": [ { "role": "user", "content": "上海今天天气怎么样?" } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "获取指定城市的天气信息", "parameters": { "type": "object", "properties": { "city": { "type": "string", "description": "城市名称" } }, "required": ["city"] } } } ], "tool_choice": "auto" }'

4.5 响应格式

标准 OpenAI Chat Completions 响应格式:

json
复制代码
{ "id": "chatcmpl-xxx", "object": "chat.completion", "created": 1718000000, "model": "Grok-4.1-Fast", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Grok 4.1 Fast 是 xAI 推出的..." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 50, "completion_tokens": 200, "total_tokens": 250 } }

4.6 模型对比

特性Grok-4.1-FastGrok-4.1-Fast-Reasoning
定位轻量快速模型推理增强版
深度推理支持(reasoning_effort)
Function Calling支持支持
流式输出支持支持
结构化输出支持支持
延迟中等

4.7 注意事项

  1. 模型名称大小写敏感,请严格按表格中的名称填写
  2. Grok-4.1-Fast-Reasoning 启用推理时,响应中会返回 reasoning_content 字段
  3. 两类模型均兼容标准 OpenAI 请求格式

五、费用说明

按标准 Token 计费模式:

  • 费用 = (输入 Token ÷ 1,000,000) × 输入单价 + (输出 Token ÷ 1,000,000) × 输出单价
  • 启用思考模式时,思考过程 Token 按输出 Token 计费
  • 多媒体输入按对应 Token 换算计费
  • 具体单价请参考 模型广场

六、推荐的 SDK 配置

Chat Completions 接口(OpenAI SDK)

Matpool 接口与 OpenAI 规范兼容,推荐使用 OpenAI 官方 SDK,只需覆盖 base_url

Python

python
复制代码
from openai import OpenAI client = OpenAI( api_key="YOUR_API_TOKEN", base_url="https://token.matpool.com/v1" ) response = client.chat.completions.create( model="Gemini-3.5-Flash", messages=[ {"role": "user", "content": "Hello!"} ] )

Node.js

javascript
复制代码
import OpenAI from "openai"; const openai = new OpenAI({ apiKey: "YOUR_API_TOKEN", baseURL: "https://token.matpool.com/v1" }); const completion = await openai.chat.completions.create({ model: "Gemini-3.5-Flash", messages: [{ role: "user", content: "Hello!" }] });

Messages 接口(Anthropic SDK)

Messages 接口兼容 Anthropic 官方 SDK,只需覆盖 base_url

Python

python
复制代码
from anthropic import Anthropic client = Anthropic( api_key="YOUR_API_TOKEN", base_url="https://token.matpool.com/v1" ) message = client.messages.create( model="Claude-Sonnet-4.6", max_tokens=1024, system="You are a helpful assistant.", messages=[ {"role": "user", "content": "Hello!"} ] ) print(message.content[0].text)

Node.js

javascript
复制代码
import Anthropic from "@anthropic-ai/sdk"; const anthropic = new Anthropic({ apiKey: "YOUR_API_TOKEN", baseURL: "https://token.matpool.com/v1" }); const message = await anthropic.messages.create({ model: "Claude-Sonnet-4.6", max_tokens: 1024, system: "You are a helpful assistant.", messages: [{ role: "user", content: "Hello!" }] }); console.log(message.content[0].text);

Response API 接口(OpenAI SDK)

GPT-5.5 支持 OpenAI 最新的 Response API,可使用 OpenAI SDK 的 responses.create 方法:

Python

python
复制代码
from openai import OpenAI client = OpenAI( api_key="YOUR_API_TOKEN", base_url="https://token.matpool.com/v1" ) response = client.responses.create( model="GPT-5.5", input="用一句话介绍量子计算" ) print(response.output[0].content[0].text)
Copyright © 2019-2026 matpool.com. All rights reserved.

Command Palette

Search for a command to run...