docs: add Google GenAI SDK tutorial (JS & Python)#21885
Open
Chesars wants to merge 3 commits intoBerriAI:mainfrom
Open
docs: add Google GenAI SDK tutorial (JS & Python)#21885Chesars wants to merge 3 commits intoBerriAI:mainfrom
Chesars wants to merge 3 commits intoBerriAI:mainfrom
Conversation
Add tutorial for using Google's official GenAI SDK (@google/genai for JS, google-genai for Python) with LiteLLM proxy. Covers pass-through and native router endpoints, streaming, multi-turn chat, and multi-provider routing via model_group_alias. Also updates pass-through docs to use the new SDK replacing the deprecated @google/generative-ai.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR adds a new tutorial for using Google's official GenAI SDK (
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| docs/my-website/docs/tutorials/google_genai_sdk.md | New comprehensive tutorial for using Google GenAI SDK with LiteLLM. Well-structured with JS/Python/curl examples. One issue: the Environment Variable Configuration section is incomplete for the Python SDK (missing base URL env var, inconsistent API key env var name). |
| docs/my-website/docs/pass_through/google_ai_studio.md | Updated SDK examples from the deprecated @google/generative-ai package to the new @google/genai package. API patterns correctly updated (GoogleGenerativeAI → GoogleGenAI, model/requestOptions → httpOptions, etc.). Streaming and tags examples both updated consistently. |
| docs/my-website/sidebars.js | Added new tutorial entry under the "AI Tools" category, correctly positioned next to the Gemini CLI tutorial entry. Single-line addition, no issues. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
SDK["Google GenAI SDK\n(@google/genai / google-genai)"]
SDK -->|"baseUrl: /gemini"| PT["Pass-through Route\n/gemini/v1beta/models/..."]
SDK -->|"baseUrl: /"| NR["Native Router Route\n/v1beta/models/..."]
PT -->|"Direct proxy"| Gemini["Google Gemini API"]
NR -->|"model_group_alias"| Router["LiteLLM Router"]
Router --> Gemini
Router --> Anthropic["Anthropic Claude"]
Router --> OpenAI["OpenAI GPT-4o"]
Router --> Bedrock["AWS Bedrock"]
style PT fill:#e8f5e9,stroke:#4caf50
style NR fill:#e3f2fd,stroke:#2196f3
style Router fill:#fff3e0,stroke:#ff9800
Last reviewed commit: fa772cf
GOOGLE_GENAI_API_KEY does not exist in the google-genai SDK. The correct env var is GEMINI_API_KEY (or GOOGLE_API_KEY). Also note that the Python SDK has no base URL env var.
…ractions.md
The Python google-genai SDK does not read GOOGLE_GENAI_BASE_URL.
Use http_options={"base_url": "..."} in code instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
N/A
Pre-Submission checklist
tests/litellm/directory — N/A, docs-only changemake test-unit— N/A, docs-only changeType
📖 Documentation
Changes
New tutorial: Google GenAI SDK with LiteLLM (
docs/tutorials/google_genai_sdk.md)Adds a comprehensive tutorial for using Google's official GenAI SDK (
@google/genaifor JavaScript/TypeScript,google-genaifor Python) with LiteLLM Proxy. Includes:model_group_alias(call Claude, GPT-4o, Bedrock through the GenAI SDK)/gemini) vs native router endpointsUpdated pass-through docs (
docs/pass_through/google_ai_studio.md)@google/generative-aiSDK examples with the new@google/genaiSDKSidebar (
sidebars.js)Tested locally
/gemini/...) with Gemini 2.5 Flash/) with Gemini 2.5 Flashmodel_group_aliasrouting to Anthropic Claude Sonnet — confirmed Claude responds through the GenAI SDK