Google AI SDK: Build a Work Assistant With Shared Context
The Google AI SDK lets you call Gemini models from Python or JavaScript with a few lines of code. Here is how to set it up, add tools, supply project context, and connect to fenbs over MCP for a shared record across sessions.
Updated 4 min read
The Google AI SDK is the official Python and JavaScript library for calling Gemini models. It gives you text generation, tool use, and multimodal input in a few lines of code. Connecting it to fenbs over MCP means your work assistant can read the current project rules, context, and Where we left off at the start of every session — without you maintaining a context file manually.
A work assistant built on the Google AI SDK starts simple and grows with your needs. The minimal version is a chat loop. The useful version adds tools, a persistent context source, and a record of what was decided — so the next session continues where the last one ended.
What the Google AI SDK gives you
The SDK wraps the Gemini API. The main capabilities are:
- Text generation: send a prompt, get a response. Works with single-turn and multi-turn conversation (chat).
- Function calling: define tools as Python or JavaScript functions with a schema, and the model calls them when relevant.
- Multimodal input: pass images, audio, video, or files alongside text in a single request.
- Streaming: receive the response incrementally as the model generates it, useful for interactive assistants.
The SDK supports both the Google AI Studio API (for individual developers) and the Vertex AI API (for production workloads on Google Cloud). The code is nearly identical; the authentication method differs. Check Google's current documentation (opens in a new tab) for the latest SDK version and model names.
Setting up the SDK
Install the Python SDK and set your API key from Google AI Studio:
pip install google-generativeai # Set your API key as an environment variable export GOOGLE_API_KEY="your-api-key-here"
Never put the API key directly in your script. Load it from an environment variable or a secrets manager. The Google AI Studio key is for development; for production use Vertex AI with Application Default Credentials instead of a bare API key.
Making your first model call
A basic text generation call looks like this:
import google.generativeai as genai
import os
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
model = genai.GenerativeModel("gemini-1.5-pro")
response = model.generate_content("Summarize what needs doing on this project.")
print(response.text)For a multi-turn chat, use model.start_chat(). The chat object maintains the conversation history automatically, so each message has the context of previous turns.
Adding tools and function calling
Function calling lets the model decide when to call a tool and pass it the right parameters. You define the tool as a Python function with a docstring and type hints; the SDK translates those into the schema the model needs.
For a work assistant, useful tools include reading from a project file, looking up a ticket status, or searching a knowledge base. Keep each tool focused on one job and validate the parameters before running the function. See how to use AI at work for practical patterns. Compare with Vercel AI SDK if you are building a web interface rather than a script.
A practical starting point is two tools: one that reads from the project context source and one that can search reference material. Those two together let the assistant answer questions about current work without loading everything into the system prompt. Add write tools — saving a decision, updating a task status — only after the read tools have been tested in several real sessions. Write operations are harder to undo if the model calls them with the wrong parameters.
Supplying project context
A work assistant without project context gives generic answers. Inject the specific facts your assistant needs — the project goal, the current tasks, the rules that apply — into the system instruction or the first message of the session.
The system instruction is set when you create the model instance and persists across the conversation. Use it for stable context: what the assistant is for, what it should not do, and any standing rules. Use the first user message or a context-loading tool call for dynamic context: current tasks, where the work was left, and recent decisions.
Connecting to fenbs over MCP
MCP is the Model Context Protocol — a standard way for an AI app to read from and write to an outside tool. fenbs exposes an MCP endpoint that a connected assistant can call to read the current project rules, notes, and Where we left off.
A Google AI SDK work assistant can connect to fenbs by implementing MCP tool calls or by running inside a client that handles MCP automatically. See Integrations for the setup guides for supported clients. For a comparison of how the Google AI SDK compares to a purpose-built agent framework, see Google ADK vs OpenAI Agents SDK.
Give your Google AI SDK assistant shared project context
Connect your assistant to fenbs over MCP from Integrations. At the start of a session, it reads the current project rules, Where we left off, and the decisions that apply. At the end of a session, it saves progress back. The context is current for every session, even if you switch from a Python script to a different AI client.
Create a free accountFree for one person · No credit card · Works with Claude, ChatGPT, Cursor and more
How to build a Google AI SDK work assistant with fenbs
- Create a free account and add a project for the work your assistant will help with.
- Install the Google AI SDK and create a model instance with a system instruction that describes the assistant's role and standing rules.
- Add a context-loading step at session startup: call the fenbs MCP tool to read the project context and inject it into the conversation.
- Define the tools your assistant needs and test them with the model before connecting to fenbs.
- At the end of each session, call the fenbs save-progress tool so the next session starts from the current state.
For Google's broader AI tool ecosystem, see Google AI tools. For a personal assistant that uses AI without writing code, see AI personal assistant.