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:

Install and configure
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:

Basic text generation
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.

How fenbs helps

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 account

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

How to build a Google AI SDK work assistant with fenbs

  1. Create a free account and add a project for the work your assistant will help with.
  2. Install the Google AI SDK and create a model instance with a system instruction that describes the assistant's role and standing rules.
  3. Add a context-loading step at session startup: call the fenbs MCP tool to read the project context and inject it into the conversation.
  4. Define the tools your assistant needs and test them with the model before connecting to fenbs.
  5. 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.

Questions people ask.

What is the difference between Google AI Studio and Vertex AI for the SDK?

Google AI Studio is the developer environment for prototyping. It uses a simple API key and is free within rate limits. Vertex AI is Google's enterprise AI platform on Google Cloud. It uses Application Default Credentials and is suited for production workloads with higher quotas, data residency controls, and enterprise SLAs.

Which Gemini model should I use for a work assistant?

Check Google's current model documentation for the available options. As of mid-2026, Gemini 1.5 Pro handles long documents and complex reasoning well; Gemini 1.5 Flash is faster and more cost-effective for shorter tasks. Model availability and names change; verify against the current list before building.

Can the Google AI SDK call external tools?

Yes. Function calling lets you define tools as Python or JavaScript functions. When the model decides to use a tool, it returns a function call with the parameters; your code runs the function and sends the result back. The model can then use the result in its response.

How do I give my Google AI SDK assistant memory across sessions?

Save the conversation history and any important conclusions between sessions. For project context — rules, current task state, decisions — keep a separate record that you inject at session startup. A shared tool like fenbs keeps that record maintained without requiring a file you update manually.

Is the Google AI SDK free?

Google AI Studio has a free tier with rate limits. Usage above that tier is billed per token. Vertex AI uses Google Cloud pricing. Check Google's current pricing page for the rates that apply to the model and usage level you have in mind.

More in Connect your AI tools

All Connect your AI tools articles

Start with one thing.

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

There is nothing to set up first. Write one line and you’ve started.