Backend · Skill
Build a Gemini API client
build-gemini-api-client
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.
Works with: Any AI Not yet model-tested; testing Jan 2027
Paste it into ChatGPT, Claude, Gemini or any AI chat, then tell it about your project. How it works
Install in Claude Code, Cursor or Codex (optional)
Only for AI coding tools that read skill folders. Run one line in a terminal, in your project folder. It downloads this skill's text files from TheSkillVault and nothing else; you can read them first with “View raw SKILL.md”.
Claude Code (all your projects)
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 (this project)
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'Codex and other Agent Skills tools (this project)
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'
Or connect the whole library over MCP
Add TheSkillVault to Cursor or add this to your app's MCP settings (read-only; help):
{
"mcpServers": {
"theskillvault": {
"url": "https://theskillvault.ai/mcp"
}
}
}Use 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.
Read 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.
The 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.
When to use
- A new Gemini API call, in Python or TypeScript.
- A chat that must continue with
previous_interaction_id. - A move off
generateContentor the legacy SDK. - Streaming, function calls, or a closed yes or no decision.
When not to use
- The user only wants a system prompt written. Use write-llm-system-prompt-prompt.
- The user wants embeddings for their own search index. Use design-embedding-model-and-chunking.
- Live bidirectional audio. That is a different API. Say so and open its doc.
Steps
- Name the job. Text, chat, stream, tools, image, speech, video, or a closed decision. Open the matching doc page before you write the call.
- Install
google-genaior@google/genai. Do not add the legacy packages. - Read the API key from the environment. Use the name the SDK already reads. Never commit it. Never put it in a
NEXT_PUBLICvariable. Never paste it into chat. - 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. - Call
interactions.createwith the model string from the current model page. Do not keep a model id from memory when the page lists a different one. - For a second turn, pass
previous_interaction_id. Interactions are stored by default. Setstoreto false when the user does not want retention. That choice also disablesprevious_interaction_idand background runs. - Send tools, the system instruction, and generation config again on every turn. They do not carry forward.
- For a stream, read
step.deltatext events untilinteraction.completed. Do not assume one JSON body holds the whole answer. - 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. - 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.
Minimal call
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: "gemini-4-hydrogen",
input: "Reply with one short sentence.",
});
console.log(interaction.output_text);
Replace 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.
Gotchas
- A client-side bundle must not contain the API key.
store: truekeeps the interaction. Paid retention and free retention differ. Say which tier you assumed.- A background research job is not done on the first response. Poll until status is completed or failed.
- Do not upgrade the SDK on the user's machine unless they asked. Give them the install command instead.
Portability
Works 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.
Example prompt
"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."
Done when
- The call uses
google-genaior@google/genai, not the legacy SDK. - The model id was checked against the current docs, or you said it was not.
- The API key is not in git and not in the browser bundle.
- A second turn passes
previous_interaction_id, or you setstorefalse on purpose. - One real call succeeded, or you said it is still untested.
---
Modified 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.
Bundled files
Licence
Adapted from 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. Modified by TheSkillVault on 2026-11-25. Rewritten as a short client guide. The model catalogue, agent samples, and doc index were not copied. The reader checks the current model page before keeping an id. Not the original file.
Licence: Apache License 2.0. Attribution when you reuse it: 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