LiteLLM 上的 DAY 0 支援:Gemini 3 Flash
LiteLLM 現在支援 gemini-3-flash-preview 以及其所有新的 API 變更。
如果您只想要成本追蹤,您目前的 Litellm 版本不需要任何變更。但如果您想要支援隨之推出的新功能,例如 thinking levels,則需要使用 v1.80.8-stable.1 或以上版本。
部署這個版本
- Docker
- Pip
docker run \
-e STORE_MODEL_IN_DB=True \
-p 4000:4000 \
ghcr.io/berriai/litellm:main-v1.80.8-stable.1
pip install litellm==1.80.8.post1
新功能
1. 新的 Thinking Levels:thinkingLevel 搭配 MINIMAL 與 MEDIUM
Gemini 3 Flash 透過 thinkingLevel 而非 thinkingBudget,引入了更細緻的 thinking 控制。
- MINIMAL:超輕量 thinking,適合快速回應
- MEDIUM:平衡 thinking,適合複雜推理
- HIGH:最高推理深度
LiteLLM 會自動將 OpenAI 的 reasoning_effort 參數對應到 Gemini 的 thinkingLevel,因此您可以使用熟悉的 reasoning_effort 值(minimal、low、medium、high),而無需變更程式碼!
2. 思考簽章
如同 gemini-3-pro,這個模型也為工具呼叫包含 thought signatures。LiteLLM 會在內部處理 signature 的擷取與嵌入。深入了解 thought signatures。
邊界情況處理:如果請求中缺少 thought signatures,LiteLLM 會加入一個虛擬 signature,確保 API 呼叫不會中斷
支援的端點
LiteLLM 提供 Gemini 3 Flash 的完整端到端支援,適用於:
- ✅
/v1/chat/completions- OpenAI 相容的 chat completions 端點 - ✅
/v1/responses- OpenAI Responses API 端點(串流與非串流) - ✅
/v1/messages- Anthropic 相容的 messages 端點 - ✅
/v1/generateContent– Google Gemini API 相容端點 所有端點都支援: - 串流與非串流回應
- 具備 thought signatures 的函式呼叫
- 多輪對話
- 所有 Gemini 3 特有功能
- 將提供者特定的 thinking 相關參數轉換為 thinkingLevel
快速開始
- SDK
- PROXY
- LOW
- MEDIUM (NEW)
- HIGH
使用 MEDIUM thinking 的基本用法(新增)
from litellm import completion
# No need to make any changes to your code as we map openai reasoning param to thinkingLevel
response = completion(
model="gemini/gemini-3-flash-preview",
messages=[{"role": "user", "content": "Solve this complex math problem: 25 * 4 + 10"}],
reasoning_effort="medium", # NEW: MEDIUM thinking level
)
print(response.choices[0].message.content)
1. 設定 config.yaml
model_list:
- model_name: gemini-3-flash
litellm_params:
model: gemini/gemini-3-flash-preview
api_key: os.environ/GEMINI_API_KEY
2. 啟動 proxy
litellm --config /path/to/config.yaml
3. 使用 MEDIUM thinking 呼叫
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR-LITELLM-KEY>" \
-d '{
"model": "gemini-3-flash",
"messages": [{"role": "user", "content": "Complex reasoning task"}],
"reasoning_effort": "medium"
}'
``'
</TabItem>
</Tabs>
---
## All `reasoning_effort` Levels
<Tabs>
<TabItem value="minimal" label="MINIMAL">
**Ultra-fast, minimal reasoning**
```python
from litellm import completion
response = completion(
model="gemini/gemini-3-flash-preview",
messages=[{"role": "user", "content": "What's 2+2?"}],
reasoning_effort="minimal",
)
簡單的指令遵循
response = completion(
model="gemini/gemini-3-flash-preview",
messages=[{"role": "user", "content": "Write a haiku about coding"}],
reasoning_effort="low",
)
適用於複雜任務的平衡推理 ✨
response = completion(
model="gemini/gemini-3-flash-preview",
messages=[{"role": "user", "content": "Analyze this dataset and find patterns"}],
reasoning_effort="medium", # NEW!
)
最高推理深度
response = completion(
model="gemini/gemini-3-flash-preview",
messages=[{"role": "user", "content": "Prove this mathematical theorem"}],
reasoning_effort="high",
)
主要功能
✅ Thinking Levels:MINIMAL、LOW、MEDIUM、HIGH
✅ Thought Signatures:使用唯一識別碼追蹤推理
✅ 無縫整合:可與現有的 OpenAI 相容用戶端搭配使用
✅ 向後相容:Gemini 2.5 模型持續使用 thinkingBudget
安裝
pip install litellm --upgrade
import litellm
from litellm import completion
response = completion(
model="gemini/gemini-3-flash-preview",
messages=[{"role": "user", "content": "Your question here"}],
reasoning_effort="medium", # Use MEDIUM thinking
)
print(response)
如果透過 vertex_ai 使用此模型,請將 location 保持為 global,因為目前這是唯一支援的 location。
Gemini 3+ 的 reasoning_effort 對應
| reasoning_effort | thinking_level |
|---|---|
minimal | minimal |
low | low |
medium | medium |
high | high |
disable | minimal |
none | minimal |


