PromptisePromptise
PlatformSoonEnterprise
DocsGitHub
Talk to usGet started
Promptise - AI Framework LogoPromptise

The full-stack framework for agentic systems. Build with the framework. Run it on the platform. Launch it with our engineers.

pip install promptise

[01] Product

  • Framework
  • Platform (coming soon)
  • Enterprise
  • How it works
  • Contact

[02] Framework

  • The Agent
  • The Interface
  • The Harness

[03] Resources

  • Documentation
  • GitHub
  • Why Promptise
  • Use cases
  • Roadmap
  • Guides
  • Learning Paths
  • Questions

[04] Company

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Subprocessors

© 2026 Promptise by Manser Ventures. All rights reserved.

hello@promptise.com
← Learning paths> Agentic Engineering with Promptise Foundry
Lesson 11 / 100
11%

Gemini AI Agent with MCP: Use Google Models in Promptise

Build a Gemini AI agent with MCP tools: get an AI Studio key, pick a current model id, set reasoning effort, use Vertex AI on Google Cloud, fix errors.

Beginner11 minModel Selection and RoutingModel Context Protocol (MCP)
All 100 lessons↓
  1. ✓What Is an AI Agent? Definition, How It Works, Examples
  2. ✓How to Build an AI Agent in Python (2026 Guide)
  3. ✓Build a Personal AI Agent: Memory, Reminders, Chat
  4. ✓What Is an Agent Harness? Parts and How to Build One
  5. ✓System Prompt Best Practices for AI Agents in Python
  6. ✓Best LLM for AI Agents (2026): Picks, Prices, How to Test
  7. ✓AI Agent YAML: Define and Run an Agent From a Config File
  8. ✓Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  9. ✓Best Local LLM for AI Agents: Ollama Models by GPU (2026)
  10. ✓Claude AI Agent with MCP: Use Anthropic Models in Promptise
  11. 11Gemini AI Agent with MCP: Use Google Models in Promptise
  12. 12Azure OpenAI Agent with MCP: Use Deployments in Promptise
  13. 13OpenRouter AI Agent with MCP: Many Models in Promptise
  14. 14Ollama AI Agent with MCP: Run Local Models in Promptise
  15. 15LLM Semantic Cache and Model Fallback in Python
  16. 16What Is MCP (Model Context Protocol)? A Developer's Guide
  17. 17What Is Tool Calling? LLM Function Calling Explained
  18. 18MCP Tools vs Resources vs Prompts (With Python Examples)
  19. 19How to Connect MCP Servers to Your AI Agent in Python
  20. 20Build a Production MCP Server in Python (Step by Step)
  21. 21MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  22. 22MCP 2026-07-28 Migration: Make Your MCP Server Stateless
  23. 23OpenAPI to MCP: Turn Any REST API into an MCP Server
  24. 24MCP Authentication in Python: API Keys, JWT and OAuth
  25. 25Build an Authenticated MCP Server for Your AI Agent (Python)
  26. 26MCP Security Best Practices: A Checklist for MCP Servers
  27. 27Testing MCP Servers in Python: pytest Without a Live Server
  28. 28Too Many MCP Tools? How to Fix LLM Tool Selection in Python
  29. 29Idempotent Tool Calls: Make AI Agent Retries Safe
  30. 30AI Agent Tool Failures: Stop Unsafe Workarounds
  31. 31MCP Server Caching, Timeouts and Circuit Breakers in Python
  32. 32MCP Middleware for Servers: Auth, Logging, Rate Limits
  33. 33MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  34. 34LangChain vs MCP: Differences and How They Work Together
  35. 35FastMCP Alternatives for Production MCP Servers (2026)
  36. 36AI Agent Audit Logging: Tamper-Evident Logs in Python
  37. 37AI Agent Human in the Loop: Approve Tool Calls in Python
  38. 38AI Agent Prompt Injection: How to Defend Against It
  39. 39Hidden Text Prompt Injection: Sanitize Pages for AI Agents
  40. 40Build a Multi-Agent System in Python (and When Not To)
  41. 41Context Engineering for AI Agents: Context Window Management
  42. 42Context Compaction for AI Agents: Trim vs Summarize
  43. 43How to Deploy an AI Agent with Docker (2026 Guide)
  44. 44LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  45. 45MCP Long-Running Tasks: Background Jobs in Python
  46. 46MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  47. 47Best AI Agent Frameworks (2026): Python Options Compared
  48. 48Self-Improving AI Agent: Learn From Tool Failures in Python
  49. 49AI Agent Identity: Authenticate Agents to MCP Servers
  50. 50Code-Action Agents in Python: One Program vs 37 Tool Calls
  51. 51Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  52. 52What Is Agentic RAG? How It Differs from Classic RAG
  53. 53AI Agent Memory in Python: Short-Term and Long-Term
  54. 54Per-User Agent Memory Isolation: Stop Leaks Between Users
  55. 55Agentic RAG in Python: Give Your AI Agent a Search Tool
  56. 56AI Agent Reasoning Patterns in Python: From ReAct to Debate
  57. 57Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  58. 58Self-Modifying AI Agent in Python: Open Mode & Limits
  59. 59CrewAI Alternatives: 7 Options and How to Migrate (2026)
  60. 60Migrate from AutoGen: Agent Framework, AG2 and More
  61. 61What Is an LLM Guardrail? Types, Examples and Limits
  62. 62Best LLM Guardrails Tools (2026): 9 Platforms Compared
  63. 63AI Agent Guardrails in Python: Block Injection, Redact PII
  64. 64NeMo Guardrails vs Guardrails AI: Which to Choose (2026)
  65. 65AI-Based PII Detection and Redaction Tools for LLM Apps
  66. 66Stop Secrets Leaking Into LLM Logs and Traces
  67. 67AI Agent Code Execution Sandbox: Run LLM Code Safely
  68. 68AI Agent Network Egress: Limit Where Agents Can Connect
  69. 69AutoGen Docker Task Isolation: Secure the Code Executor
  70. 70SPIFFE for AI Agents: Workload Identity Without API Keys
  71. 71On-Behalf-Of Auth for AI Agents: Act as Each User
  72. 72AI Agent Production Checklist: What to Check Before Launch
  73. 73Approval Fatigue: Auto-Approve Safe AI Agent Actions
  74. 74What Is Human in the Loop AI? Approvals for AI Agents
  75. 75AI Agent Notifications: Webhook and Slack Alerts in Python
  76. 76AI Agent Observability: Trace Tool Calls, Tokens and Cost
  77. 77Best AI Agent Observability Tools (2026), Compared
  78. 78AI Agent Stuck in a Loop? How to Detect and Stop It
  79. 79How to Run, Debug and Deploy an AI Agent in Python
  80. 80AI Agent Cost Tracking: Tokens and Cost per Run and User
  81. 81How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  82. 82AI Agent Cost Control: Budgets That Stop Runaway Spend
  83. 83How to Test LLM Prompts and AI Agents in Python
  84. 84AI Agent Evals in CI: Run Them on Every Pull Request
  85. 85What Is an Agentic Runtime? AI Agent Runtimes Explained
  86. 86Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  87. 87Event-Driven AI Agents: Webhook, Cron and File Triggers
  88. 88AI Agent Cron Jobs: Run an Agent on a Schedule
  89. 89AI Agent Webhook Trigger: Run an Agent on HTTP Events
  90. 90AI Agent File Watcher: Process New Files Automatically
  91. 91Custom AI Agent Triggers: Wake an Agent From Any Source
  92. 92AI Agent Event Filters: Skip Runs Before the LLM
  93. 93AI Agent Retries and a Dead Letter Queue for Failed Runs
  94. 94Run Multiple AI Agents: One Runtime, Many Processes
  95. 95AI Agent Manifest: Declare a Long-Running Agent in YAML
  96. 96AI Agent CLI: Start, Stop and Inspect Running Agents
  97. 97AI Agent Monitoring Dashboard in the Terminal
  98. 98Multi-Agent Event Bus: Chain Agents With Events
  99. 99Distributed AI Agents: Run Agents Across Many Machines
  100. 100Pause and Resume an AI Agent: Lifecycle States Explained

Lessons in this path

  1. ✓What Is an AI Agent? Definition, How It Works, Examples
  2. ✓How to Build an AI Agent in Python (2026 Guide)
  3. ✓Build a Personal AI Agent: Memory, Reminders, Chat
  4. ✓What Is an Agent Harness? Parts and How to Build One
  5. ✓System Prompt Best Practices for AI Agents in Python
  6. ✓Best LLM for AI Agents (2026): Picks, Prices, How to Test
  7. ✓AI Agent YAML: Define and Run an Agent From a Config File
  8. ✓Streaming LLM Responses with FastAPI: Tokens and Tool Calls
  9. ✓Best Local LLM for AI Agents: Ollama Models by GPU (2026)
  10. ✓Claude AI Agent with MCP: Use Anthropic Models in Promptise
  11. 11Gemini AI Agent with MCP: Use Google Models in Promptise
  12. 12Azure OpenAI Agent with MCP: Use Deployments in Promptise
  13. 13OpenRouter AI Agent with MCP: Many Models in Promptise
  14. 14Ollama AI Agent with MCP: Run Local Models in Promptise
  15. 15LLM Semantic Cache and Model Fallback in Python
  16. 16What Is MCP (Model Context Protocol)? A Developer's Guide
  17. 17What Is Tool Calling? LLM Function Calling Explained
  18. 18MCP Tools vs Resources vs Prompts (With Python Examples)
  19. 19How to Connect MCP Servers to Your AI Agent in Python
  20. 20Build a Production MCP Server in Python (Step by Step)
  21. 21MCP Transports: stdio vs Streamable HTTP vs SSE (Python)
  22. 22MCP 2026-07-28 Migration: Make Your MCP Server Stateless
  23. 23OpenAPI to MCP: Turn Any REST API into an MCP Server
  24. 24MCP Authentication in Python: API Keys, JWT and OAuth
  25. 25Build an Authenticated MCP Server for Your AI Agent (Python)
  26. 26MCP Security Best Practices: A Checklist for MCP Servers
  27. 27Testing MCP Servers in Python: pytest Without a Live Server
  28. 28Too Many MCP Tools? How to Fix LLM Tool Selection in Python
  29. 29Idempotent Tool Calls: Make AI Agent Retries Safe
  30. 30AI Agent Tool Failures: Stop Unsafe Workarounds
  31. 31MCP Server Caching, Timeouts and Circuit Breakers in Python
  32. 32MCP Middleware for Servers: Auth, Logging, Rate Limits
  33. 33MCP vs CLI for AI Agents: Tokens, Security, When to Use Each
  34. 34LangChain vs MCP: Differences and How They Work Together
  35. 35FastMCP Alternatives for Production MCP Servers (2026)
  36. 36AI Agent Audit Logging: Tamper-Evident Logs in Python
  37. 37AI Agent Human in the Loop: Approve Tool Calls in Python
  38. 38AI Agent Prompt Injection: How to Defend Against It
  39. 39Hidden Text Prompt Injection: Sanitize Pages for AI Agents
  40. 40Build a Multi-Agent System in Python (and When Not To)
  41. 41Context Engineering for AI Agents: Context Window Management
  42. 42Context Compaction for AI Agents: Trim vs Summarize
  43. 43How to Deploy an AI Agent with Docker (2026 Guide)
  44. 44LLM Tool Rate Limiting: Per-Client Limits for MCP Servers
  45. 45MCP Long-Running Tasks: Background Jobs in Python
  46. 46MCP Server Monitoring: Prometheus, OpenTelemetry and Logs
  47. 47Best AI Agent Frameworks (2026): Python Options Compared
  48. 48Self-Improving AI Agent: Learn From Tool Failures in Python
  49. 49AI Agent Identity: Authenticate Agents to MCP Servers
  50. 50Code-Action Agents in Python: One Program vs 37 Tool Calls
  51. 51Multi-Tenant AI Agents: Keep Each Customer's Data Apart
  52. 52What Is Agentic RAG? How It Differs from Classic RAG
  53. 53AI Agent Memory in Python: Short-Term and Long-Term
  54. 54Per-User Agent Memory Isolation: Stop Leaks Between Users
  55. 55Agentic RAG in Python: Give Your AI Agent a Search Tool
  56. 56AI Agent Reasoning Patterns in Python: From ReAct to Debate
  57. 57Plan-and-Execute Agents in Python: Beyond the ReAct Loop
  58. 58Self-Modifying AI Agent in Python: Open Mode & Limits
  59. 59CrewAI Alternatives: 7 Options and How to Migrate (2026)
  60. 60Migrate from AutoGen: Agent Framework, AG2 and More
  61. 61What Is an LLM Guardrail? Types, Examples and Limits
  62. 62Best LLM Guardrails Tools (2026): 9 Platforms Compared
  63. 63AI Agent Guardrails in Python: Block Injection, Redact PII
  64. 64NeMo Guardrails vs Guardrails AI: Which to Choose (2026)
  65. 65AI-Based PII Detection and Redaction Tools for LLM Apps
  66. 66Stop Secrets Leaking Into LLM Logs and Traces
  67. 67AI Agent Code Execution Sandbox: Run LLM Code Safely
  68. 68AI Agent Network Egress: Limit Where Agents Can Connect
  69. 69AutoGen Docker Task Isolation: Secure the Code Executor
  70. 70SPIFFE for AI Agents: Workload Identity Without API Keys
  71. 71On-Behalf-Of Auth for AI Agents: Act as Each User
  72. 72AI Agent Production Checklist: What to Check Before Launch
  73. 73Approval Fatigue: Auto-Approve Safe AI Agent Actions
  74. 74What Is Human in the Loop AI? Approvals for AI Agents
  75. 75AI Agent Notifications: Webhook and Slack Alerts in Python
  76. 76AI Agent Observability: Trace Tool Calls, Tokens and Cost
  77. 77Best AI Agent Observability Tools (2026), Compared
  78. 78AI Agent Stuck in a Loop? How to Detect and Stop It
  79. 79How to Run, Debug and Deploy an AI Agent in Python
  80. 80AI Agent Cost Tracking: Tokens and Cost per Run and User
  81. 81How to Evaluate AI Agents: Evals, LLM Judges and pass^k
  82. 82AI Agent Cost Control: Budgets That Stop Runaway Spend
  83. 83How to Test LLM Prompts and AI Agents in Python
  84. 84AI Agent Evals in CI: Run Them on Every Pull Request
  85. 85What Is an Agentic Runtime? AI Agent Runtimes Explained
  86. 86Autonomous AI Agent Runtime: Budgets, Crash Recovery, API
  87. 87Event-Driven AI Agents: Webhook, Cron and File Triggers
  88. 88AI Agent Cron Jobs: Run an Agent on a Schedule
  89. 89AI Agent Webhook Trigger: Run an Agent on HTTP Events
  90. 90AI Agent File Watcher: Process New Files Automatically
  91. 91Custom AI Agent Triggers: Wake an Agent From Any Source
  92. 92AI Agent Event Filters: Skip Runs Before the LLM
  93. 93AI Agent Retries and a Dead Letter Queue for Failed Runs
  94. 94Run Multiple AI Agents: One Runtime, Many Processes
  95. 95AI Agent Manifest: Declare a Long-Running Agent in YAML
  96. 96AI Agent CLI: Start, Stop and Inspect Running Agents
  97. 97AI Agent Monitoring Dashboard in the Terminal
  98. 98Multi-Agent Event Bus: Chain Agents With Events
  99. 99Distributed AI Agents: Run Agents Across Many Machines
  100. 100Pause and Resume an AI Agent: Lifecycle States Explained
← Path overview

This guide shows how to build a Gemini AI agent with MCP tools: an agent that runs on Google's Gemini models and calls tools from a Model Context Protocol server. It is for developers who want Gemini's long context and price range behind an agent, either with a Google AI Studio key or through Vertex AI on Google Cloud. You will set up the key, pick a current model id, control reasoning, and run one small agent file against a local MCP server.

[01]

How do you build a Gemini AI agent with MCP?

Create an API key in Google AI Studio, put it in GOOGLE_API_KEY (or GEMINI_API_KEY), and pass "gemini:gemini-3.8-flash" or Model("gemini-3.8-flash", provider="gemini") to build_agent(). Promptise reaches Gemini through Google's OpenAI-compatible endpoint with langchain-openai, which is part of the core install, so there is nothing else to install. Add your MCP servers in servers=. The agent sends their tools to Gemini as function declarations, runs the calls Gemini makes and loops until it answers.

  • Two ways in. provider="gemini" uses an AI Studio API key. provider="vertex" uses Vertex AI with a Google Cloud project and Application Default Credentials.

  • Use current model ids. Google retires models regularly. Check the models page before you pin one.

  • Control reasoning with reasoning_effort. Gemini 3 models always reason, and the effort level sets how much.

  • The free tier trains on your content. Google's pricing page says free-tier content is used to improve its products and paid-tier content isn't.

  • Check before you call. promptise models check gemini:<model> shows the route and what is missing.


[02]

Set up Gemini

You need Python 3.10 or later, Promptise Foundry 1.4.2 or later, and an API key from Google AI Studio.

>_Terminal
pip install "promptise>=1.4.2"

Put the key in a .env file next to your script. Promptise loads the nearest .env file automatically, and a variable already exported in your shell wins. It reads GOOGLE_API_KEY first and accepts GEMINI_API_KEY as an alias:

Output
# Google Gemini (AI Studio API key) — model string example: gemini:gemini-3.8-flash
export GOOGLE_API_KEY=AIza...
#   ↳ aistudio.google.com → Get API key

Then check the configuration. With the key set (here as GEMINI_API_KEY), the check reports the endpoint and stops before calling anything:

Output
$ promptise models check gemini:gemini-3.8-flash
gemini:gemini-3.8-flash → google_genai:gemini-3.8-flash  (Google Gemini (AI Studio API key))
  model part: gemini-3.8-flash — the model name
  route: OpenAI-compatible endpoint https://generativelanguage.googleapis.com/v1beta/openai/ (core, nothing to install)
  GOOGLE_API_KEY: set — aistudio.google.com → Get API key
  For Gemini through Google Cloud (no API key, ADC) use provider='vertex'.
Configuration OK — every required setting is in place; nothing was called. Add --ping to make a real one-token call to the model.

"Configuration OK" means the key is set, not that it works. --ping makes one real call. This is the real output with a key that isn't valid:

Output
$ promptise models check gemini:gemini-3.8-flash --ping
Configuration OK.
Pinging… failed
OpenAIInvalidRequestError: Error code: 400 - [{'error': {'code': 400, 'message': 'Please pass a valid API key', 'status': 'INVALID_ARGUMENT'}}]

Which model id to use

Copy ids from Google's models page. At the time of writing, Google recommends these for new projects:

Model id

Good for

gemini-3.8-flash

The default for agents: tool calling, reasoning and a long context at a moderate price

gemini-3.5-flash-lite

Simple, high-volume steps where cost and speed matter most

Older ids such as gemini-2.5-pro still appear in many tutorials, including Promptise's own provider table, but Google now lists the 2.5 models with limited access. Preview models (ids ending in -preview) can change or disappear with little notice, so avoid them for production agents. To compare Gemini with other providers on your own tool calls, see the best LLM for AI agents.


[03]

Build a minimal Gemini AI agent

The agent answers questions about a shop's products. The model is configured once at the top of the file:

Pythongemini_agent.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import asyncio
import sys

from promptise import Model, build_agent
from promptise.config import StdioServerSpec

# The key comes from GOOGLE_API_KEY or GEMINI_API_KEY (environment or .env).
GEMINI = Model("gemini-3.8-flash", provider="gemini")


async def make_agent(model=GEMINI):
    return await build_agent(
        model=model,
        servers={"shop": StdioServerSpec(command=sys.executable, args=["shop_server.py"])},
        instructions="You answer questions about the shop's products. "
                     "Use the tools for stock and prices. Never guess them.",
        max_agent_iterations=10,
    )


async def main():
    agent = await make_agent()
    try:
        result = await agent.ainvoke(
            {"messages": [{"role": "user", "content": "Is KB-101 in stock, and what does it cost?"}]}
        )
        calls = [c["name"] for m in result["messages"] for c in getattr(m, "tool_calls", None) or []]
        print("tool calls:", ", ".join(calls) or "none")
        print(result["messages"][-1].text)
    finally:
        await agent.shutdown()


if __name__ == "__main__":
    asyncio.run(main())

What each part does:

  • Model("gemini-3.8-flash", provider="gemini") names the model and the provider. gemini, google and google_genai all select the same provider. The key comes from the environment. Pass api_key= instead when it comes from a secret store.

  • max_agent_iterations=10 stops a run that keeps calling tools without finishing.

  • result["messages"][-1].text reads the answer text.

Run it with python gemini_agent.py. With a valid key, the script prints the tools Gemini called and then its answer. With a key that isn't valid, the run fails with the same Please pass a valid API key error as the ping above, raised as a GraphExecutionError from the agent's reasoning step.


[04]

Use MCP tools with Gemini

The tools come from a small MCP server that the agent starts over stdio:

Pythonshop_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""A small MCP tool server: product stock and prices for a shop."""
from promptise.mcp.server import MCPServer

server = MCPServer("shop")

STOCK = {"KB-101": 14, "MS-220": 0, "HD-350": 3}
PRICES = {"KB-101": 89.00, "MS-220": 39.50, "HD-350": 129.00}


@server.tool()
async def check_stock(sku: str) -> dict:
    """How many units of a product (by SKU) are in stock."""
    if sku not in STOCK:
        return {"sku": sku, "error": "unknown SKU"}
    return {"sku": sku, "in_stock": STOCK[sku]}


@server.tool()
async def get_price(sku: str) -> dict:
    """The current price of a product (by SKU), in USD."""
    if sku not in PRICES:
        return {"sku": sku, "error": "unknown SKU"}
    return {"sku": sku, "price_usd": PRICES[sku]}


if __name__ == "__main__":
    server.run()  # stdio by default
Your code calls the Promptise agent, which calls Gemini at generativelanguage.googleapis.com/v1beta/openai/ over HTTPS and runs the returned tool_calls on shop_server.py over stdio as the MCP client. The tool result goes into the next Gemini call, and Gemini never connects to the MCP server.
FigureThe Promptise agent calls Gemini and runs its tool calls on the MCP server

Promptise is the MCP client. When the agent is built, it connects to each server in servers=, lists the tools and converts their input schemas into function definitions in the OpenAI format, which Google's compatible endpoint accepts. When Gemini returns a tool call, Promptise runs it against the MCP server and calls Gemini again with the result. Promptise binds tools with automatic tool choice, so Gemini decides when a tool is needed.

Gemini never connects to your MCP server, so the server can stay on your machine or a private network. For a remote server, use HTTPServerSpec(url=..., bearer_token=...) from promptise.config. The MCP connection guide covers transports and authentication.


[05]

Gemini-specific notes

Reasoning effort

Gemini 3 models reason before they answer, and you can't turn that off. You can set how much with reasoning_effort, which the compatibility endpoint accepts as minimal, low, medium or high:

Python
GEMINI = Model("gemini-3.8-flash", provider="gemini", extra={"reasoning_effort": "low"})

Lower effort means fewer reasoning tokens, lower cost and faster replies. That suits lookups like the example. Raise it for agents that plan across several tools. Google's thinking guide explains how effort maps onto Gemini's own thinking settings.

The OpenAI-compatible route and the native route

The default route uses Google's OpenAI compatibility layer, which supports tool calling, streaming and structured output. Google labels it beta and says feature support is still expanding. Gemini features that the OpenAI format can't express need Google's own client. Promptise reaches it with native=True once you install langchain-google-genai:

Python
GEMINI = Model("gemini-3.8-flash", provider="gemini", native=True)

Start with the default route. Move to native=True only when you need a feature it doesn't expose, and test the agent again after the switch.

Gemini on Vertex AI

On Google Cloud, use the vertex provider. It needs your project id and, optionally, a region. Authentication uses an OAuth access token instead of an API key:

Python
GEMINI = Model("gemini-3.8-flash", provider="vertex", project="my-project-123", region="us-central1")

Install google-auth and run gcloud auth application-default login (or use the service account of the machine). Promptise then gets a token for you and refreshes it before it expires, so a long-running agent keeps working. A token set by hand in GOOGLE_OAUTH_ACCESS_TOKEN or api_key= expires after about an hour, which is fine for one-off runs only. A bare Gemini name is prefixed with google/ for Vertex's endpoint. Check that the model you want is available in your region on Vertex before you deploy.

Pricing, limits and data use

Prices per million tokens are on Google's pricing page, and request and token limits per tier are on the rate limits page. An agent makes several model calls per question, so it reaches per-minute limits faster than a chat app. The pricing page also says content sent on the free tier is used to improve Google's products and content on the paid tier isn't. Don't send customer data through a free-tier key. Put a budget on the agent before it handles real traffic.


[06]

Common problems and fixes

Symptom

Cause

Fix

GOOGLE_API_KEY is not set

No key in the environment, the .env file or the code

Set GOOGLE_API_KEY or GEMINI_API_KEY, or pass api_key=

HTTP 400 Please pass a valid API key

The key is wrong, deleted or restricted to other APIs

Create a new key in AI Studio and check its API restrictions

HTTP 404 for the model

The id is misspelled, retired or not available to your key

Copy a current id from the models page

HTTP 429

The per-minute request or token limit for your tier

Back off and retry, lower concurrency, or move to a paid tier

The agent answers without calling tools

The instructions don't say when tools are needed, or the tool descriptions are vague

Say which questions need which tools, and improve the descriptions on the MCP server

no OAuth access token with provider="vertex"

No token and no Application Default Credentials

Install google-auth and run gcloud auth application-default login

Vertex calls start failing after about an hour

A hand-set access token expired

Use Application Default Credentials so Promptise refreshes the token


[07]

Frequently asked questions

Do I need the Google Gen AI SDK to build a Gemini agent with Promptise?

No. Promptise reaches Gemini through Google's OpenAI-compatible endpoint with langchain-openai, which is installed with Promptise. You only need Google's own LangChain integration, langchain-google-genai, if you opt into the native route with native=True for a feature the compatible endpoint doesn't expose.

Can Gemini call MCP tools?

Yes. Promptise is the MCP client: it reads the tools from your MCP servers and sends them to Gemini as function definitions. Gemini returns a function call, Promptise runs it against the MCP server and sends back the result. Gemini never connects to the MCP server itself, so private and local servers work.

Should I use the Gemini API or Vertex AI for an agent?

Use the Gemini API with an AI Studio key to get started and for projects outside Google Cloud. Use Vertex AI when your organization runs on Google Cloud and needs its identity and access controls, billing or regional data handling. In Promptise, the switch is the provider: gemini or vertex. The rest of the agent stays the same.

Which Gemini model is best for an AI agent?

Start with gemini-3.8-flash, which Google recommends for new projects and which supports tool calling and reasoning. Use gemini-3.5-flash-lite for simple steps where cost matters most. Test both on your own questions and tools, because the right choice depends on how hard the agent's tasks are.

Is my data used for training when I use the Gemini API?

According to Google's pricing page, content sent on the free tier is used to improve Google's products, and content on the paid tier isn't. Check the current terms for your account before you send customer or confidential data, and use a paid-tier key or Vertex AI for production.


[08]

Next steps

  • Build the full agent step by step: how to build an AI agent.

  • Compare Gemini with other models: best LLM for AI agents.

  • Use the long context well: context engineering for AI agents.

  • Write the tool side: build a production MCP server.

  • Trace every model and tool call: AI agent observability.

  • Every provider setting: Models and providers reference.

← PreviousClaude AI Agent with MCP: Use Anthropic Models in PromptiseNext lesson →Azure OpenAI Agent with MCP: Use Deployments in Promptise