Blog
跳至主要內容

DAY 0 支援:LiteLLM 上的 Gemini 3.1 Pro

Sameer Kankute
SWE @ LiteLLM (LLM Translation)
Krrish Dholakia
CEO, LiteLLM
Ishaan Jaffer
CTO, LiteLLM

LiteLLM 現在支援 gemini-3.1-pro-preview 以及所有隨之而來的新 API 變更。

部署此版本

docker run litellm
docker run \
-e STORE_MODEL_IN_DB=True \
-p 4000:4000 \
ghcr.io/berriai/litellm:main-v1.81.9-stable.gemini.3.1-pro

新增內容

1. 新的思考層級:thinkingLevel,支援 MINIMAL 與 MEDIUM

Gemini 3.1 Pro 新增對 medium 思考層級的支援

LiteLLM 會自動將 OpenAI reasoning_effort 參數映射到 Gemini 的 thinkingLevel,因此您可以使用熟悉的 reasoning_effort 值(minimallowmediumhigh),而無需變更程式碼!


Gemini 3+ 的支援端點

LiteLLM 為 Gemini 3.1 Pro 提供 完整端到端支援,涵蓋:

  • /v1/chat/completions - OpenAI 相容的聊天 completions 端點
  • /v1/responses - OpenAI Responses API 端點(串流與非串流)
  • /v1/messages - Anthropic 相容的 messages 端點
  • /v1/generateContentGoogle Gemini API 相容端點

所有端點都支援:

  • 串流與非串流回應
  • 具備 thought signatures 的函式呼叫
  • 多輪對話
  • 所有 Gemini 3 專屬功能
  • 將提供者特定的 thinking 相關參數轉換為 thinkingLevel

快速開始

使用 MEDIUM 思考的基本用法(新)

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.1-pro-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)

reasoning_effort 映射表:適用於 Gemini 3+

reasoning_effortthinking_level
minimalminimal
lowlow
mediummedium
highhigh
disableminimal
noneminimal