概要
前回 Azure のカスタムエンドポイントを設定する方法を紹介しました
今回は Gemini flash の設定方法を紹介します
環境
- docker 27.3.1
- Ubuntu 24.04
- litellm-proxy v1.67.0-stable
litellm_config.yaml
model_list:
- model_name: gemini/gemini-flash
litellm_params:
model: gemini/gemini-flash
api_base: os.environ/GEMINI_API_BASE # runs os.getenv("GEMINI_API_BASE")
api_key: os.environ/GEMINI_API_KEY # runs os.getenv("GEMINI_API_KEY")
api_version: ""
docker 起動
docker run --rm \
-v $(pwd)/litellm_config.yaml:/app/config.yaml \
-e GEMINI_API_KEY=b4xxx \
-e GEMINI_API_BASE=https://your-api-endpoint/ai/chat-ai/gemini/flash \
-p 4000:4000 \
ghcr.io/berriai/litellm:main-latest \
--config /app/config.yaml --detailed_debug
カスタムメソッド部の :streamGenerateContent は不要です
動作確認
リクエスト LiteLLM Proxy が互換にしてくれるので Azure のときと同じです
curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini/gemini-flash",
"messages": [
{
"role": "user",
"content": "what llm are you"
}
]
}'
レスポンスは以下です
{
"id": "chatcmpl-2062ec16-2314-4772-a264-6f987407689d",
"created": 1745811058,
"model": "gemini-flash",
"object": "chat.completion",
"system_fingerprint": null,
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "I am a large language model, trained by Google.\n",
"role": "assistant",
"tool_calls": null,
"function_call": null
}
}
],
"usage": {
"completion_tokens": 12,
"prompt_tokens": 5,
"total_tokens": 17,
"completion_tokens_details": null,
"prompt_tokens_details": {
"audio_tokens": null,
"cached_tokens": null
}
},
"vertex_ai_grounding_metadata": [],
"vertex_ai_safety_results": [],
"vertex_ai_citation_metadata": []
}
最後に
LiteLLM Proxy で Gemini flash を動作させる方法を紹介しました
これで Open WebUI のモデルを簡単に変更することができます
0 件のコメント:
コメントを投稿