Skip to main content

MaaS API

openaianthropicgoogle
parallel_tool_callsdisable_parallel_tool_use
max_completion_tokensmax_tokens
  • “长尾分布”
  • “突发性”
  • "Fat Tail" (肥尾)
  • 3+Sigma + 15-30min 窗口检查异动

Gemini API

Multiple tools are supported only when they are all search tools

  • 内置 tool 和 functionDeclaration 工具不能同时使用
  • openai 里的 tool 映射为一个 functionDeclaration
  • 其他的 tool 是内置 tool,语义上有点区别

OpenAI API

streaming

first chunk

  • 有些为了紧凑,会在第一个 chunk 包含内容
  • 正常情况第一个 chunk 不应该包含内容

last chunk

  • vLLM, OpenAI 最后一个 chunk 的 content 为 空
{
"index": 0,
"delta": {
"content": ""
},
"logprobs": null,
"finish_reason": "stop",
"stop_reason": null
}

ToolChoice

  • auto
    • 自动选择工具
  • required
    • 必须使用工具
  • none
    • 不使用工具

Thinking

{
"contents": [
{
"parts": [
{
"text": "Provide a list of 3 famous physicists and their key contributions"
}
]
}
],
"generationConfig": {
"thinkingConfig": {
"thinkingLevel": "low"
}
}
}

Interleaved thinking

思考过程可以进行 tool call

  • Claude 4+
    • interleaved-thinking-2025-05-14
    • Messages API 才支持
  • MiniMax-M2
  • Kimi-K2-Thinking

reasoning_details

{
"type": "reasoning.summary",
"summary": "The model analyzed the problem by first identifying key constraints, then evaluating possible solutions...",
"id": "reasoning-summary-1",
"format": "anthropic-claude-v1",
"index": 0
}
  • type
    • reasoning.summary
    • reasoning.encrypted
    • reasoning.text
  • 维护思考细节信息
    • OpenAI o
    • Claude 3.7+ thinking
    • Gemini Reasoning
    • xAI Reasoning

Preserved thinking


role

  • developer
  • system
  • user
  • assistant
  • tool
    • 新版本 openai
    • Anthropic 使用 user role
  • function
    • 旧版本 openai

usage

  • 付费
    • 算力
    • pay per token
    • pay per request
    • pay per item
      • 图、语音

abort

  • stream 499 会产生费用
  • 非strema 中断也会产生费用
    • 极端情况会产生完整的费用
  • Agent 实现在中断时候需要预估 usage
    • 否则 context window 会失准

Prompt Cache

模型 / 场景最小缓存 Token 数
Claude Opus 4.54096
Claude Opus 4.1, 41024
Claude Sonnet 4.5, 4, 3.71024
Claude Haiku 4.54096
Claude Haiku 3.5, 32048
Gemini 3 Pro Preview4096
Gemini 3 Flash Preview1024
Gemini 2.5 Pro4096
Gemini 2.5 Flash1024
Gemini Explicit Caching (Vertex AI)4096
Gemini Context Caching (Early Versions)32768
OpenAI GPT1024
  • Implicit Caching: 提供 75% - 90% 的输入 Token 折扣。
  • Explicit Caching: 按生存时间 (TTL) 收取存储费用。
  • 容量: 最大缓存大小等同于模型完整上下文窗口(可超过 100 万 Token)。
  • Gemini 3 优化: 在 Gemini 3 系列中,建议 Prompt 前缀或缓存数据至少达到 4096 Token 以确保缓存生效并有效降低 API 成本。
  • Google OpenAI API extra body
  • ⚠️ Tool call 缓存实际缓存的是 schema+描述 等
{
"google": {
"cached_content": "cachedContents/XXX",
"thinking_config": {
"thinking_level": "low",
"include_thoughts": true
}
}
}