{"name":"build-gemini-api-client","description":"Calls the Gemini API with the current Google GenAI SDK for text, chat, streaming, and tool use. Use when the user wants a Gemini client, interactions.create, a move off generateContent, or the google-genai package. Check the current model page before you name a model.","category":"backend","tags":["gemini","llm","api"],"models":["any"],"proven":false,"passing_families":0,"model_testing":"Not yet model-tested; testing Jan 2027","url":"https://theskillvault.ai/skills/build-gemini-api-client","api_url":"https://theskillvault.ai/api/skills/build-gemini-api-client","raw_url":"https://theskillvault.ai/api/skills/build-gemini-api-client/raw","body":"# Build a Gemini API client\n\nUse the current SDK. Python package `google-genai`. TypeScript package `@google/genai`. The old packages `google-generativeai` and `@google/generative-ai` are the legacy SDKs. Do not start a new call on them.\n\nRead the current docs before you name a model or a parameter. Start at the Interactions overview and the model page linked from Google's Gemini docs. If those pages disagree with this skill, follow the pages and name the one you used.\n\nThe pinned guide's sample model is `gemini-4-hydrogen`. It tells you not to start new work on `gemini-2.5`, `gemini-2.0`, or `gemini-1.5`. Treat that as the guide's claim on the day it was pinned. Open the current model page and use the id it lists.\n\n## When to use\n- A new Gemini API call, in Python or TypeScript.\n- A chat that must continue with `previous_interaction_id`.\n- A move off `generateContent` or the legacy SDK.\n- Streaming, function calls, or a closed yes or no decision.\n\n## When not to use\n- The user only wants a system prompt written. Use write-llm-system-prompt-prompt.\n- The user wants embeddings for their own search index. Use design-embedding-model-and-chunking.\n- Live bidirectional audio. That is a different API. Say so and open its doc.\n\n## Steps\n1. Name the job. Text, chat, stream, tools, image, speech, video, or a closed decision. Open the matching doc page before you write the call.\n2. Install `google-genai` or `@google/genai`. Do not add the legacy packages.\n3. Read the API key from the environment. Use the name the SDK already reads. Never commit it. Never put it in a `NEXT_PUBLIC` variable. Never paste it into chat.\n4. Create the client. The stable Interactions API can use the default client. Managed agents and the Decisions API need `v1beta`. Set that version only for those calls.\n5. Call `interactions.create` with the model string from the current model page. Do not keep a model id from memory when the page lists a different one.\n6. For a second turn, pass `previous_interaction_id`. Interactions are stored by default. Set `store` to false when the user does not want retention. That choice also disables `previous_interaction_id` and background runs.\n7. Send tools, the system instruction, and generation config again on every turn. They do not carry forward.\n8. For a stream, read `step.delta` text events until `interaction.completed`. Do not assume one JSON body holds the whole answer.\n9. For a closed yes or no, a single choice, or a rubric score, use the Decisions API on `v1beta`. Do not ask the chat model to print a label and then hope.\n10. Run one real call with a throwaway prompt. If you cannot run it, say the call is untested. Do not claim a model id is current unless you opened the page.\n\n## Minimal call\n```ts\nimport { GoogleGenAI } from \"@google/genai\";\n\nconst client = new GoogleGenAI({});\nconst interaction = await client.interactions.create({\n  model: \"gemini-4-hydrogen\",\n  input: \"Reply with one short sentence.\",\n});\nconsole.log(interaction.output_text);\n```\n\nReplace `gemini-4-hydrogen` if the current model page names a different default. The comment to keep: the key stays in the environment, not in this file.\n\n## Gotchas\n- A client-side bundle must not contain the API key.\n- `store: true` keeps the interaction. Paid retention and free retention differ. Say which tier you assumed.\n- A background research job is not done on the first response. Poll until status is completed or failed.\n- Do not upgrade the SDK on the user's machine unless they asked. Give them the install command instead.\n\n## Portability\nWorks with Python or TypeScript. Any other language can call the same HTTP API. If you use another model provider, keep that client. Do not wrap it in the Google SDK.\n\n## Example prompt\n\"Add a Gemini chat in TypeScript with interactions.create. Keep the API key in the environment, and check the current model page before you pick the model id.\"\n\n## Done when\n- The call uses `google-genai` or `@google/genai`, not the legacy SDK.\n- The model id was checked against the current docs, or you said it was not.\n- The API key is not in git and not in the browser bundle.\n- A second turn passes `previous_interaction_id`, or you set `store` false on purpose.\n- One real call succeeded, or you said it is still untested.\n\n---\nModified from \"gemini-api-dev\" in google-gemini/gemini-skills (Apache-2.0). Attribute to Google (google-gemini/gemini-skills). The upstream LICENSE keeps the unfilled template line. See LICENSE.txt.","files":["LICENSE.txt","NOTICE.txt"],"license":"Apache-2.0","license_name":"Apache License 2.0","license_url":"https://www.apache.org/licenses/LICENSE-2.0","attribution":"Based on work by Google (google-gemini/gemini-skills) (Copyright [yyyy] [name of copyright owner]. The google-gemini/gemini-skills LICENSE keeps that Apache template line unfilled. Attribute this skill to Google (google-gemini/gemini-skills)., Apache License 2.0), https://github.com/google-gemini/gemini-skills/blob/c4d0c62c1240e08a90546186bf320600ab6a039a/skills/gemini-api-dev/SKILL.md; adapted by TheSkillVault, https://theskillvault.ai","install":{"claude_code":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/raw' -o ~/'.claude/skills/build-gemini-api-client/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/files/LICENSE.txt' -o ~/'.claude/skills/build-gemini-api-client/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/files/NOTICE.txt' -o ~/'.claude/skills/build-gemini-api-client/NOTICE.txt'","cursor":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/raw' -o '.cursor/skills/build-gemini-api-client/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/files/LICENSE.txt' -o '.cursor/skills/build-gemini-api-client/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/files/NOTICE.txt' -o '.cursor/skills/build-gemini-api-client/NOTICE.txt'","agents":"curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/raw' -o '.agents/skills/build-gemini-api-client/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/files/LICENSE.txt' -o '.agents/skills/build-gemini-api-client/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-gemini-api-client/files/NOTICE.txt' -o '.agents/skills/build-gemini-api-client/NOTICE.txt'","mcp_url":"https://theskillvault.ai/mcp","cursor_mcp_deeplink":"cursor://anysphere.cursor-deeplink/mcp/install?name=theskillvault&config=eyJ1cmwiOiJodHRwczovL3RoZXNraWxsdmF1bHQuYWkvbWNwIn0%3D","mcp_config":{"mcpServers":{"theskillvault":{"url":"https://theskillvault.ai/mcp"}}}},"bundles":[],"tested_on":[{"family":"chatgpt","name":"ChatGPT","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"claude","name":"Claude","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"gemini","name":"Gemini","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"grok","name":"Grok","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"llama","name":"Llama","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"deepseek","name":"DeepSeek","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"mistral","name":"Mistral","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"qwen","name":"Qwen","outcome":null,"date":null,"source":null,"counts":false,"stale":false},{"family":"kimi","name":"Kimi K","outcome":null,"date":null,"source":null,"counts":false,"stale":false}],"proven_rule":{"threshold":5,"window_days":365,"computed_at":"2026-11-29T03:42:30.374Z"}}