Back to stack index

AI

Gemini

Google models connected through gateways and chat UIs.

Short answer

The Gemini API gives programs access to Google's Gemini models, and self-hosted apps such as LibreChat, LobeChat and Dify, plus gateways such as LiteLLM, support it natively. Google's newest model, Gemini 4 Argon, became generally available on October 13, 2026. On the Gemini API's paid tier it costs $2 per million input tokens and $10 per million output tokens until November 30, 2026, then $4 and $20 from December 1, with cached input at $0.10 rising to $0.20. Argon is not on the free tier, but smaller models such as Gemini 3.5 Flash-Lite are, with a context window of about 1 million tokens, which makes Gemini the cheapest way to try a long-context model in a self-hosted app. There are two ways in: an API key from Google AI Studio for quick setup, or Google Cloud's Vertex AI, now part of Gemini Enterprise Agent Platform, for IAM controls, regional data handling and enterprise billing.

Gemini 4 Argon
GA October 13, 2026
Google
Argon price to Nov 30
$2 input, $10 output per million tokens
Gemini API pricing
Argon price from Dec 1
$4 input, $20 output per million tokens
Gemini API pricing
Flash-Lite context
1,048,576 tokens in, 65,536 out
Google

Updated October 21, 2026How we evaluate tools

Official site

Directory projects (4)

  • LiteLLM

    OpenAI-compatible proxy that unifies dozens of model providers behind one key.

  • LibreChat

    Multi-model chat UI with plugins, agents, and self-hosted deployment.

  • LobeChat

    Modern chat shell for running and comparing multiple models locally or via API.

  • Dify

    Visual builder for RAG apps and agents with deployable API endpoints.

The Gemini API in open-source AI tools: connecting Google's models to self-hosted apps in 2026

Two doors to the same models

Google sells Gemini to developers in two ways, and the choice affects setup, billing and data terms.

Google AI Studio (Gemini API)Vertex AI (Gemini Enterprise Agent Platform)
SetupAPI key from aistudio.google.comGoogle Cloud project, service account, IAM
Free tierYes, rate-limitedTrial credits only
BillingLinked Cloud billing accountGoogle Cloud invoice
Data useFree tier may be used to improve products; paid tier notNot used for training
RegionsGlobalGlobal and regional endpoints
Best forIndividuals, prototypes, small teamsCompanies on Google Cloud

Both serve the same model families. Google has folded Vertex AI's generative services into Gemini Enterprise Agent Platform, and some older pieces, such as Vertex AI Extensions, are scheduled to shut down after November 26, 2026.

Which directory projects use it

ProjectHow it connects
LibreChatNative Google endpoint for AI Studio keys and Vertex service accounts
LobeChatBuilt-in Gemini provider
DifyGemini and Vertex model provider plugins
LiteLLMgemini/ and vertex_ai/ prefixes with cost tracking

Models and prices

ModelStatusInput per millionOutput per millionCached input
Gemini 4 Argon (to Nov 30, 2026)GA, paid only$2.00$10.00$0.10
Gemini 4 Argon (from Dec 1, 2026)GA, paid only$4.00$20.00$0.20
Gemini 3.5 Flash-LiteStable, free tier availableLow per-token rateLow per-token rateDiscounted

The introductory Argon price is worth noting in any budget: the same workload costs twice as much from December. Teams testing Argon in October should plan for the standard rate.

Gemini 3.5 Flash-Lite, updated in July 2026, accepts up to 1,048,576 input tokens and returns up to 65,536 output tokens. That long context window lets a self-hosted app send a whole contract set, codebase or book without building a retrieval pipeline first, though retrieval is still cheaper for repeated questions over large collections.

Long context in practice

Gemini models have led on context length for several years. Sending 500,000 tokens in one request is possible, but every request pays for every token, and latency grows with input size. Two habits keep costs sane:

  1. Use context caching. When many questions hit the same large document, cache it and pay the cached rate on later calls.
  2. Retrieve first, then read. For a library of thousands of documents, use a vector database such as Qdrant to find the ten most relevant, and send only those.

Setting it up

  1. For AI Studio: create a key at aistudio.google.com and link a billing account to move off the free tier.
  2. In LibreChat, set GOOGLE_KEY in .env, or provide a service-account JSON for Vertex.
  3. In LiteLLM, use model: gemini/gemini-4-argon with GEMINI_API_KEY, or vertex_ai/gemini-4-argon with project and location set.
  4. For apps that only speak OpenAI's format, Google offers an OpenAI-compatible endpoint at https://generativelanguage.googleapis.com/v1beta/openai/.

Multimodal input and output

Gemini models accept text, images, audio, video and PDFs in one request. A self-hosted app can let users upload a recording of a meeting or a scanned form and ask questions about it directly. Google's media models, such as Veo for video and image models, are billed separately; note that the Veo 3.1 Lite preview was scheduled to shut down on October 22, 2026, with users pointed to newer models. Check model status before building on any preview.

What a month costs

At Argon's standard price from December 2026:

UseMonthly tokensRough cost
One heavy user3M in, 0.5M outAbout $22
Team of 2040M in, 10M outAbout $360
Same team on Flash-Lite40M in, 10M outA small fraction of that

Many teams set Flash-Lite as the default and offer Argon for hard questions.

Data handling

The free tier is the main privacy trap. Google's terms allow free-tier prompts and responses to be used to improve its products, and human reviewers may read them. Paid-tier and Vertex AI traffic is excluded from training. If your self-hosted app is used for company data, make sure the key belongs to a billed project.

Gemini can ground answers in live Google Search results and return source links, a feature other providers lack in the same form. It is billed per grounded request on top of tokens, after a free daily allowance on some models. In a self-hosted chat app, this gives users web-backed answers without running a separate search tool such as SearXNG. Google's terms require showing the search suggestions it returns alongside grounded answers, so check that your app displays them.

Rate limits and quotas

AI Studio keys have per-model limits on requests per minute, tokens per minute and requests per day, set by your usage tier. Free-tier limits are low and change from time to time, so a self-hosted app shared with a team will hit them quickly. Paid tiers rise as cumulative spend grows. On Vertex AI, quotas are set per project and region and can be raised through the Cloud console, and Provisioned Throughput reserves capacity for steady production loads. When a request fails with a 429 error, a gateway such as LiteLLM can retry on another region or fall back to a different model.

Tool calling and structured output

Gemini supports function calling, JSON schema output and code execution in a sandbox, so it can drive agents in Dify, LibreChat and LangChain-based tools. Its function-calling format differs from OpenAI's, but LibreChat, LiteLLM and the OpenAI-compatible endpoint translate it. If an agent works on GPT and fails on Gemini, check how each tool's parameters are described: Gemini is stricter about some JSON schema features, and simplifying the schema often fixes the problem.

When to use something else

If your team prefers Claude for writing and code, see the Anthropic API. If EU residency is the priority, Mistral is simpler. If you need everything on your own hardware, run an open model through Ollama. Google's open Gemma models are another route to Google-quality small models offline.

Related: Google Cloud stack, OpenAI API stack, LiteLLM stack, ChatGPT alternatives, Stack index.

Frequently asked questions

Is the Gemini API free?

Partly. Google AI Studio offers a free tier with rate limits for several models, including Flash-class models. Gemini 4 Argon is paid only. On the free tier, Google may use prompts and responses to improve its products, so do not send confidential data through it.

How much does Gemini 4 Argon cost?

On the paid Gemini API tier, $2 per million input tokens and $10 per million output tokens through November 30, 2026, then $4 and $20 from December 1, 2026. Cached input costs $0.10 per million, rising to $0.20. Vertex AI regional prices can differ.

Should I use AI Studio or Vertex AI?

Use an AI Studio API key for personal projects and small teams; setup takes a minute. Use Vertex AI if your company already runs on Google Cloud, needs IAM roles, VPC controls, regional processing or a data processing agreement, or wants spend on the existing cloud bill.

Can I use Gemini in Open WebUI or LibreChat?

LibreChat has a native Google endpoint for both AI Studio keys and Vertex AI. LobeChat and Dify have Gemini providers. Open WebUI can connect through Google's OpenAI-compatible endpoint or through a LiteLLM proxy.

Does Google train on Gemini API data?

Google states that paid-tier and Vertex AI data is not used to improve its products. Free-tier data in AI Studio may be used for that purpose and reviewed by people. Check the current Gemini API terms before choosing a tier.

Which Gemini model should be the default in a self-hosted app?

A Flash-class model is the usual default for everyday chat because it is fast and cheap. Offer Gemini 4 Argon as a second option for hard reasoning, long documents and code, and watch the price change on December 1, 2026.

Sources

  1. Gemini API pricing
  2. Gemini API docs
  3. Gemini API terms
  4. Vertex AI generative AI pricing