{
 "kind": "api",
 "slug": "google-gemini-api",
 "path": "apis/google-gemini-api/",
 "name": "Gemini API",
 "logo": "https://agentgid.com/media/avatars/googleapis.png",
 "maker": "Google",
 "density": "full",
 "crumbs": [
  [
   "APIs",
   "apis/"
  ],
  [
   "Model hosting and inference",
   "apis/inference/"
  ]
 ],
 "lead": "Google AI models for text, files and media.",
 "chips": [
  {
   "label": "Model hosting and inference",
   "path": "apis/inference/"
  }
 ],
 "primary": {
  "label": "Copy prompt for your agent",
  "copy": "Add Gemini to my app with the google-genai package and the Interactions API: call it from the server with GEMINI_API_KEY from .env, use model gemini-3.8-flash, and never put the key in browser code."
 },
 "links": [
  {
   "label": "Website",
   "href": "https://ai.google.dev"
  },
  {
   "label": "Pricing",
   "href": "https://ai.google.dev/gemini-api/docs/pricing"
  },
  {
   "label": "GitHub",
   "href": "https://github.com/googleapis/js-genai"
  }
 ],
 "track": "Outages, price changes and new versions on your dashboard",
 "verdicts": [
  {
   "key": "price",
   "label": "Price",
   "value": "Free credits",
   "status": "cond",
   "sub": "One-time or needs a card",
   "quote": "5,000 free search requests per month (shared across all Gemini 3 and newer models), then $14 per 1,000 requests",
   "note": "Free tier: Free tier with rate limits on some models (not Gemini 4 Argon). As reported on the official pricing page, checked Oct 22, 2026.",
   "src": "https://ai.google.dev/gemini-api/docs/pricing"
  },
  {
   "key": "commercial",
   "label": "Commercial use",
   "value": "With conditions",
   "status": "cond",
   "sub": null,
   "quote": "Use of Google AI Studio and Gemini API is for developers building with Google AI models for professional or business purposes, not for consumer use.",
   "note": "Allowed for professional or business use by adults; not in apps aimed at under-18s, and apps for users in the EEA, Switzerland or the UK must use the paid tier.",
   "src": "https://aistudio.google.com/docs/terms"
  },
  {
   "key": "key",
   "label": "Key & sign-up",
   "value": "API key, server only",
   "status": "info",
   "sub": "Env var GEMINI_API_KEY",
   "quote": "Set the environment variable GEMINI_API_KEY or GOOGLE_API_KEY. The Gemini API client libraries automatically detect and use these variables. If both are set, GOOGLE_API_KEY takes precedence.",
   "note": "API key in the x-goog-api-key header (the official packages read it from the environment)",
   "src": "https://aistudio.google.com/docs/api-key"
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Docs for agents",
   "status": "info",
   "sub": "SDK",
   "quote": "The public Gemini Docs MCP server (https://gemini-api-docs-mcp.dev) gives your agent live access to the entire documentation site.",
   "note": " Our agent check: 2 of 6 (Nov 13, 2026).",
   "src": "https://aistudio.google.com/docs/coding-agents"
  }
 ],
 "vfoot": "Checked against the maker's official pages, pricing on Oct 22, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Gemini API does",
   "parts": [
    {
     "t": "prose",
     "text": "The Gemini API lets your app send a question, a document, a photo, a recording or a video to Google's Gemini models and get an answer back. It writes and summarizes text, reads files and media, can check facts with Google Search, and also makes images, video and music. There is a free tier with limits; paid use is billed by the amount of text processed."
    },
    {
     "t": "list",
     "items": [
      "Gemini API is one of 41 APIs in the Model hosting and inference category on AgentGid.",
      "It is one of 13 that can be started for free.",
      "6 of them ship an official MCP server; Gemini API does not.",
      "Its official SDK is the 2nd most downloaded in the category (72.1M a week)."
     ],
     "muted": true
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Answers with fresh web facts",
       "text": "Let a help bot or research tool answer with current information from Google Search, and show the links it used.",
       "idea": false
      },
      {
       "title": "Pull details out of PDFs",
       "text": "Upload contracts, invoices or reports and get back the facts you need, such as dates, names and totals.",
       "idea": false
      },
      {
       "title": "Summaries of audio recordings",
       "text": "Turn a meeting recording or a podcast episode into a written transcript, a summary, or answers to your questions.",
       "idea": false
      },
      {
       "title": "Find moments in videos",
       "text": "Ask what happens in a video and where, for example to tag clips in a video library or write short descriptions.",
       "idea": false
      },
      {
       "title": "Filled forms from free text",
       "text": "Turn a customer's message or a pasted recipe into neat fields your app can save, such as name, items and time.",
       "idea": false
      },
      {
       "title": "Product descriptions for a shop",
       "text": "Draft short descriptions for each item in an online shop from a few notes, then edit them before publishing.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Gemini API popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "70M",
       "l": "SDK downloads a week",
       "d": "+12.6% on the 4-week average",
       "up": true
      },
      {
       "n": "1,715",
       "l": "GitHub stars, googleapis/js-genai"
      }
     ]
    },
    {
     "t": "small",
     "text": "SDK downloads from npm and PyPI, weekly. Numbers as of Nov 17, 2026."
    }
   ]
  },
  {
   "id": "pricing",
   "nav": "Pricing and limits",
   "h2": "Pricing",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "Free tier",
       "v": "Free tier with rate limits on some models (not Gemini 4 Argon)"
      },
      {
       "l": "Cheapest plan",
       "v": "No monthly plan"
      },
      {
       "l": "Usage price",
       "v": "Paid tier billed per 1M tokens by model (prepaid or pay-as-you-go)"
      }
     ]
    },
    {
     "t": "h3",
     "text": "What one action costs"
    },
    {
     "t": "table",
     "head": [
      "Action",
      "Price"
     ],
     "num": true,
     "rows": [
      [
       "1M input tokens, Gemini 3.8 Flash (through December 31, 2026)",
       "$0.75"
      ],
      [
       "1M output tokens, Gemini 3.8 Flash (through December 31, 2026)",
       "$3.75"
      ],
      [
       "1M input tokens, Gemini 3.5 Flash-Lite (text, image, video, audio)",
       "$0.30"
      ],
      [
       "1,000 Google Search grounding requests after 5,000 free a month (Gemini 3+)",
       "$14"
      ]
     ]
    },
    {
     "t": "small",
     "text": "As reported on the official pricing page, checked Oct 22, 2026. Prices change: confirm before you buy.",
     "link": "ai.google.dev/gemini-api/docs/pricing",
     "href": "https://ai.google.dev/gemini-api/docs/pricing"
    }
   ]
  },
  {
   "id": "limits",
   "nav": null,
   "spy_as": "pricing",
   "h2": "Limits",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "All tiers",
       "v": "Limits count per project (requests per minute, input tokens per minute, requests per day); daily limits reset at midnight Pacific time.",
       "src": "https://aistudio.google.com/docs/rate-limits"
      },
      {
       "l": "All tiers",
       "v": "Exact limits per model and tier are shown only in Google AI Studio.",
       "src": "https://aistudio.google.com/docs/rate-limits"
      },
      {
       "l": "Tier 1 (billing linked)",
       "v": "$10 of spend per rolling 10 minutes",
       "src": "https://aistudio.google.com/docs/rate-limits"
      },
      {
       "l": "Batch",
       "v": "100 concurrent batch requests, 2GB input file, 20GB file storage",
       "src": "https://aistudio.google.com/docs/rate-limits"
      }
     ]
    },
    {
     "t": "small",
     "text": "From the official docs.",
     "link": "aistudio.google.com/docs/rate-limits",
     "href": "https://aistudio.google.com/docs/rate-limits"
    }
   ]
  },
  {
   "id": "access",
   "nav": "Access and terms",
   "h2": "Key and access",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "How it signs in",
       "v": "API key in the x-goog-api-key header (the official packages read it from the environment)"
      },
      {
       "l": "Environment variable",
       "v": "GEMINI_API_KEY",
       "code": true
      },
      {
       "l": "Safe in browser code",
       "v": "No, keep it on your server",
       "status": "no"
      },
      {
       "l": "Card at sign-up",
       "v": "No"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Steps only a person can do"
    },
    {
     "t": "list",
     "items": [
      "Sign in to Google AI Studio and copy or create a Gemini API key. Put it in .env as GEMINI_API_KEY (kept out of git); the official packages read it automatically.",
      "For production, for users in the EEA, Switzerland or the UK, or for Gemini 4 Argon, set up billing and prepay at least $5. No code change; the same key moves to paid limits.",
      "If AI Studio shows \"Verification needed\", verify the account with a phone or set up billing. Retry the request after the project status changes."
     ]
    }
   ]
  },
  {
   "id": "terms",
   "nav": null,
   "spy_as": "access",
   "h2": "Commercial use and your data",
   "parts": [
    {
     "t": "prose",
     "text": "It is a paid online service from Google with a free tier, not open source. It is meant for business use by adults, and Google does not claim ownership of what it generates. Apps for users in Europe or the UK must use the paid tier."
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In a paid app",
       "v": "With conditions",
       "status": "cond",
       "sub": "Allowed for professional or business use by adults; not in apps aimed at under-18s, and apps for users in the EEA, Switzerland or the UK must use the paid tier.",
       "quote": "Use of Google AI Studio and Gemini API is for developers building with Google AI models for professional or business purposes, not for consumer use.",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "In monetized videos",
       "v": "With conditions",
       "status": "cond",
       "sub": "Google does not claim ownership of generated content, but may generate similar content for others; you are responsible for how you use it.",
       "quote": "You're responsible for your use of generated content, and for the use of that content by anyone you share it with.",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "To train your own AI",
       "v": "No",
       "status": "no",
       "sub": "You may not use the service to build models that compete with Gemini, or extract its data or weights.",
       "quote": "You may not use the Services to develop models that compete with the Services (e.g., Gemini API or Google AI Studio).",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "client-work",
       "v": "With conditions",
       "status": "cond",
       "sub": "Fine as business use; for medical advice or clinical practice it is not allowed.",
       "quote": "You may not use the Services in clinical practice, to provide medical advice, or in any manner that is overseen by or requires clearance or approval from a medical device regulatory agency.",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "Trains on what you send",
       "v": "“Google uses the content you submit to the Services and any generated responses to provide, improve, and develop Google products and services and machine learning technologies”",
       "quote": null,
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "Keeps your data",
       "v": "Paid tier prompts and answers are logged for a limited time to detect misuse; Google Search grounding data is kept 30 days.",
       "quote": "For Paid Services, Google logs prompts and responses for a limited period of time, solely for detecting and preventing violations of the Prohibited Use Policy",
       "src": "https://aistudio.google.com/docs/terms"
      },
      {
       "l": "Where data is stored",
       "v": "Only in listed countries; data may be stored or cached in any country where Google has facilities.",
       "quote": "This data may be stored transiently or cached in any country in which Google or its agents maintain facilities.",
       "src": "https://aistudio.google.com/docs/terms"
      }
     ]
    }
   ]
  },
  {
   "id": "errors",
   "nav": null,
   "spy_as": "access",
   "h2": "Errors to handle",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "401 authentication",
       "v": "The API key is missing, invalid, or expired.",
       "sub": "Check the key in GEMINI_API_KEY; do not retry."
      },
      {
       "l": "402 payment_required",
       "v": "The prepaid credit balance is used up.",
       "sub": "Top up credits or turn on auto-reload; do not retry until credits are added."
      },
      {
       "l": "403 permission_denied",
       "v": "The key lacks permission, or the project is restricted, needs verification, or needs billing changes.",
       "sub": "Check the project status in AI Studio (verification, billing, leaked key) and fix it there."
      },
      {
       "l": "429 rate_limit_exceeded / quota_exceeded",
       "v": "Too many requests or tokens per minute, or the daily quota is used up.",
       "sub": "Retry with exponential backoff; for the daily quota wait for the reset or ask for an increase."
      },
      {
       "l": "503 service_unavailable",
       "v": "The service is temporarily overloaded or down.",
       "sub": "Retry with exponential backoff."
      }
     ]
    }
   ]
  },
  {
   "id": "agent",
   "nav": "For agents",
   "h2": "Use it from an agent",
   "parts": [
    {
     "t": "rows",
     "rows": [
      {
       "l": "Our agent check",
       "v": "2 of 6: llms.txt no, OpenAPI no, SDK yes, MCP no, status page no, AI assistants allowed yes",
       "sub": "Checked Nov 13, 2026."
      },
      {
       "l": "MCP server",
       "v": "Gemini Docs MCP server (documentation search only; it does not call models)",
       "sub": "claude mcp add --transport http geminiDocs https://gemini-api-docs-mcp.dev"
      },
      {
       "l": "npm",
       "v": "npm install @google/genai",
       "code": true
      },
      {
       "l": "PyPI",
       "v": "pip install google-genai",
       "code": true
      }
     ]
    },
    {
     "t": "h3",
     "text": "Instructions in its docs to check first"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "The docs say",
       "v": "“Building with an AI coding agent? Install the skill and then paste the prompt to get started with the Gemini API using Interactions:”",
       "sub": "Ask the person first. The suggested command is npx skills add google-gemini/gemini-skills (an unpinned package) and it changes the agent's setup."
      },
      {
       "l": "The docs say",
       "v": "“curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh | bash”",
       "sub": "Never run it on your own; it pipes a script from the internet into the shell. Ask the person, and prefer the pinned google-genai package in the project."
      },
      {
       "l": "The docs say",
       "v": "“npx skills add google-gemini/gemini-skills --skill gemini-api-dev --global”",
       "sub": "Ask the person first; it installs skills globally from an unpinned source."
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Gemini API",
       "me": true,
       "facts": [
        "Free plan",
        "Free tier"
       ]
      },
      {
       "name": "OpenAI API",
       "why": "Pick the OpenAI API when you want GPT models for text, vision, tool calling and agents, also priced per 1M tokens.",
       "path": "apis/openai-api/",
       "facts": [
        "from $0.1",
        "No free tier"
       ]
      },
      {
       "name": "Groq (LLM inference)",
       "why": "Pick Groq when you want fast answers from open models such as GPT-OSS and Llama.",
       "path": "apis/groq/",
       "facts": [
        "from $0.075",
        "No free tier"
       ]
      },
      {
       "name": "Mistral AI API",
       "why": "Pick Mistral when you want Mistral's open-weight and commercial models from one provider.",
       "path": "apis/mistral-api/",
       "facts": [
        "from $0.5 per million input tokens",
        "No free tier"
       ]
      }
     ],
     "more": "All model hosting and inference APIs",
     "more_path": "apis/inference/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Add Gemini to my app with the google-genai package and the Interactions API: call it from the server with GEMINI_API_KEY from .env, use model gemini-3.8-flash, and never put the key in browser code."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Get a Gemini API key in Google AI Studio (new users get a project and key automatically) and set it as an environment variable.",
       "code": "export GEMINI_API_KEY=\"YOUR_API_KEY\"",
       "src": "https://aistudio.google.com/docs/get-started"
      },
      {
       "text": "Install the official Google GenAI package for Python or JavaScript.",
       "code": "pip install -U google-genai\nnpm install @google/genai",
       "src": "https://aistudio.google.com/docs/libraries"
      },
      {
       "text": "Make the first request with the Interactions API and print the answer.",
       "code": "from google import genai\nclient = genai.Client()\ninteraction = client.interactions.create(\n model=\"gemini-3.8-flash\",\n input=\"Explain how AI works in a few words\"\n)\nprint(interaction.output_text)",
       "src": "https://aistudio.google.com/docs/get-started"
      }
     ]
    },
    {
     "t": "h3",
     "text": "First request"
    },
    {
     "t": "tabs",
     "label": "First request",
     "items": [
      {
       "tab": "Request",
       "code": "curl -X POST \"https://generativelanguage.googleapis.com/v1beta/interactions\" \\\n -H \"x-goog-api-key: $GEMINI_API_KEY\" \\\n -H 'Content-Type: application/json' \\\n -H \"Api-Revision: 2026-05-20\" \\\n -d '{\n \"model\": \"gemini-3.8-flash\",\n \"input\": \"Explain how AI works in a few words\"\n }'",
       "intro": null
      },
      {
       "tab": "Response",
       "code": "{\n \"id\": \"v1_ChdpQUFvYXI...\",\n \"status\": \"completed\",\n \"steps\": [\n {\n \"type\": \"model_output\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"AI learns patterns from data, then uses those patterns to make predictions or decisions on new data.\"\n }\n ]\n }\n ],\n \"object\": \"interaction\",\n \"model\": \"gemini-3.8-flash\"\n}"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "Writing code with the old google-generativeai package or gemini-1.5 model names.",
       "fix": "Use the google-genai (Python) or @google/genai (JavaScript) package and a current model name such as gemini-3.8-flash.",
       "why": "Coding assistants learned older names; the docs warn they suggest deprecated models and packages."
      },
      {
       "dont": "Putting GEMINI_API_KEY into front-end or mobile app code.",
       "fix": "Keep the key on your server and let the page call your own server route.",
       "why": "A key in client code can be read and used by anyone, on your bill."
      },
      {
       "dont": "Setting temperature, top_p or top_k for Gemini 3.6+ and Gemini 4 models.",
       "fix": "Leave these settings out; lower the thinking level instead if you need faster or cheaper answers.",
       "why": "These models ignore the values, send deprecation warnings, and will return 400 errors in a future release."
      },
      {
       "dont": "Retrying every failed request in a loop.",
       "fix": "Retry only 429, 408 and 5xx errors with exponential backoff and jitter; fix the key, credits or request on 400, 402 and 403.",
       "why": "Client errors mean a bad key, empty prepaid credit or bad syntax, and will fail again."
      },
      {
       "dont": "Installing @google/genai 3.x on Node.js 20.",
       "fix": "Use Node.js 22 or later, or pin an older major version of the package.",
       "why": "Version 3.0.0 requires Node.js 22."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Is there a free tier?",
       "a": "Yes. New accounts start on the free tier, which covers certain models up to their free limits. The top model, Gemini 4 Argon, is not included.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/billing",
        "quote": "New accounts begin on the Free Tier, which allows access to certain models in the Gemini API and AI Studio, up to the models' free tier rate limits."
       }
      },
      {
       "q": "Does Google train on what I send?",
       "a": "On the free tier, yes, it may use your content to improve its products. On the paid tier it does not.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/zdr",
        "quote": "when you use Paid Services, Google does not use your prompts (including associated system instructions, cached content, and files such as images, videos, or documents) or responses to improve our products."
       }
      },
      {
       "q": "Can I put the key in my web page?",
       "a": "No. The docs say keys in web or mobile apps can be extracted; call Gemini from your own server instead.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/api-key",
        "quote": "Keys compiled in client-side code can be extracted by users."
       }
      },
      {
       "q": "Are my rate limits per key?",
       "a": "No, per project, so several keys in one project share the same limits. Daily limits reset at midnight Pacific time.",
       "evidence": {
        "url": "https://aistudio.google.com/docs/rate-limits",
        "quote": "Rate limits are applied per project, not per API key."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Maker",
   "Google"
  ],
  [
   "Category",
   "Model hosting and inference"
  ],
  [
   "Price",
   "Free plan"
  ],
  [
   "Official SDK",
   "npm @google/genai, PyPI google-genai"
  ],
  [
   "Latest SDK",
   "3.0.0 on npm"
  ],
  [
   "Agent check",
   "2 of 6"
  ],
  [
   "Pricing checked",
   "Oct 22, 2026"
  ]
 ],
 "good": [
  "On the free tier Google may use what you send to improve its products, and people may review it. Do not send private or personal data there.",
  "The paid tier needs a billing account and a prepayment of at least $5 in credits.",
  "When prepaid credit reaches zero, every key on that billing account stops working until you add more."
 ],
 "checked_line": "Read by AgentGid from 18 official pages, card checked Nov 10, 2026; usage numbers update daily."
}