Gemini CLI with a LiteLLM gateway

Gemini CLI can send its model traffic through a self-hosted LiteLLM proxy, so keys, budgets and model access sit with your team. This page covers the supported method, the version it needs and the rollout sequence.

On this page

How a Gemini CLI with LiteLLM gateway keeps developer model access under central control

Developers who run Gemini CLI on their own machines usually need a Gemini API key or a Google sign-in, which puts provider credentials and spend outside the organization's control. The fix is to point Gemini CLI at a self-hosted LiteLLM proxy, so developers authenticate to the gateway with their own LiteLLM-issued key and the gateway holds the provider credentials. LiteLLM's documented tutorial covers routing gemini-cli through the proxy, and that path is supported from v1.73.3-nightly and above, so the release line you deploy must be checked against that floor before any developer configures a laptop. With keys, budgets and model allow-lists enforced at the gateway, a developer can reach the approved models without ever holding a shared provider key.

This page covers the method, the prerequisites, the setup sequence, how developer identities map to LiteLLM keys and teams, the security controls around the gateway, how to test the setup, and the failure points that tend to appear after rollout. Confirm first which LiteLLM build your platform team will run, because the tutorial's version floor applies to the proxy and not to the developer's Gemini CLI install. Also confirm which of your approved models Gemini CLI can address through the gateway, since model names the CLI sends must match routes configured on the proxy.

The setup is a sequence rather than a single configuration change. The gateway, its PostgreSQL database and its key policy have to exist before the CLI is pointed at it, and the identity mapping decides whether budgets belong to a person, a team or a service account. Each of those decisions affects the others, so plan them together. The sections that follow take each step in turn and name the checks you should run before developers are onboarded.

What you need before connecting Gemini CLI to LiteLLM

Gemini CLI can only reach the gateway if several pieces exist first: a LiteLLM build new enough to route gemini-cli, a database that holds virtual keys, a shared cache once you run more than one proxy, a protected master key, and a network path from developer machines. Confirm each item before you write any client configuration.

LiteLLM build with gemini-cli routing

The tutorial supports routing gemini-cli through the proxy from v1.73.3-nightly and above, so older builds will not work for this integration. Check the LiteLLM releases page and pin the exact image you deploy, not just a version family. The releases page lists v1.105.1, published October 14, 2026, so confirm whether that or a later release is the one your security team has approved. Record the chosen tag in your change record so the gateway and the Gemini CLI setup can be rolled back together.

Gemini CLI tutorial

PostgreSQL for virtual keys

Virtual keys, per-key and per-team budgets, and spend tracking all require a PostgreSQL database. Without it, you cannot issue the individual keys that make per-developer governance possible, so Gemini CLI would fall back to shared credentials. Plan for backups and point-in-time recovery from the start, because losing this database means losing key history and spend records. Ask your database team who operates it and where it sits relative to the gateway.

Virtual keys docs

Redis 7.0 or newer for shared state

Redis becomes required once more than one proxy instance runs, because rate limits, router state and cache must be shared across instances. If a developer's requests land on different replicas, a single-instance setup would give inconsistent TPM and RPM enforcement. Confirm that Redis is deployed with the version floor, has authentication enabled, and is reachable only from the gateway network. A single proof-of-concept instance can skip Redis, but the decision should be recorded.

Minimum Redis version
7.0

Master key in a secret manager

The LITELLM_MASTER_KEY value must start with sk- and gives full administrative control over the gateway, so it should never be written into a developer's shell profile or a Gemini CLI settings file. Store it in your secret manager and inject it into the proxy at runtime. Developers should receive only their own virtual keys, which can be rotated or revoked without touching the master key. Confirm who can read the master key and how it is rotated.

Network path from developer machines

Every developer laptop and CI runner that runs Gemini CLI must reach the proxy over HTTPS on a hostname your team controls. Check egress rules from corporate networks, VPN split-tunnel settings, and any proxy or TLS inspection devices that could break the connection. Decide whether the gateway is reachable only from the corporate network or also from remote locations, and confirm that the chosen certificate chain is trusted on every developer device.

Gemini CLI version and provider accounts

Confirm the Gemini CLI version named in the LiteLLM tutorial and install that version on a test machine before rollout, since client behavior can change between releases. Then list the provider accounts the gateway will call, such as Gemini, OpenAI, Anthropic, Bedrock or Azure, and confirm each has an approved API key, a billing owner and a spend limit set at the provider. The gateway can only route to providers whose credentials it holds, so missing accounts will show up as failed model calls.

How a Gemini CLI request travels through the LiteLLM gateway

The request starts in Gemini CLI on the developer's laptop, which sends it with a virtual key to the LiteLLM proxy inside the organization's boundary. The proxy checks the key, its budget, rate limits and model allow-list against PostgreSQL and Redis before the router picks a provider deployment and forwards the call upstream. Check that the trust boundary sits where your security team expects, and that spend and request logs land in the stores you plan to review.

A Gemini CLI call crosses the trust boundary once, then passes through the proxy's checks and router.

Configuring the LiteLLM proxy and Gemini CLI in sequence

This sequence takes a platform team from an empty environment to a LiteLLM proxy that issues scoped keys, enforces budgets and limits, and serves Gemini CLI traffic with a logged, testable path. Each step ends with a check that confirms the previous layer works before the next one is added.

  1. Deploy the proxy with PostgreSQL and a managed master key

    The platform team deploys the LiteLLM proxy in infrastructure you control, connected to a PostgreSQL database, because virtual keys, budgets and spend records depend on it. Store LITELLM_MASTER_KEY, which must start with sk-, in your secret manager and inject it at runtime rather than writing it into a configuration file. Confirm the deployment by calling the proxy health endpoint and by sending an authenticated request with the master key to the model list endpoint. The step is done when both calls succeed and the proxy logs show a clean database connection.

  2. Define Gemini and approved models in configuration

    Add the Gemini models your organization has approved to the proxy configuration, along with any other approved providers or self-hosted models you want developers to reach through the same gateway. Give each model a stable public name so developers and keys refer to it consistently, and keep provider credentials in the secret manager as well. Confirm the configuration by listing models with the master key and checking that each approved name appears with the expected provider mapping. Test one Gemini model with a short completion request before moving on.

  3. Create teams and virtual keys with limits

    Create a team for the group that will use Gemini CLI, then issue a virtual key for each developer or shared workload under that team. Set the budget, TPM and RPM limits at the key and team level, and restrict each key to an explicit model allow-list that contains only the Gemini models that group needs. Record who owns each key and when it should be reviewed. Confirm the setup by viewing the key details in the admin interface or the key info endpoint and checking that the budget, limits and model list match the written request.

  4. Point Gemini CLI at the proxy

    On a test workstation, configure Gemini CLI to send its requests to your LiteLLM proxy URL using the environment variables and settings described in the LiteLLM Gemini CLI tutorial. Confirm the exact variable names, the proxy path Gemini CLI expects, and the minimum LiteLLM version for your build in that tutorial before you roll anything out, because these details change between releases. Use the virtual key, not the master key, as the credential the CLI reads. The step is done when Gemini CLI starts without falling back to a direct provider connection.

  5. Send a test request and confirm the spend record

    Run a simple prompt from Gemini CLI using the test virtual key, then check the proxy request log for that call. Confirm that the request is attributed to the expected key and team and that a spend record appears against the key's budget after the request completes. If the spend record does not appear, check database connectivity and spend update timing before assuming the request failed. The step is done when the request, the attribution and the spend entry all match.

  6. Verify the model allow-list refuses out-of-scope models

    Using the same virtual key, request a model that is approved for another team but not for this key. The proxy should refuse the request with an authorization error rather than forward it to the provider. Repeat the check for a model that is on the allow-list to confirm the key still works for permitted models. Record both results, since they become the baseline for later regression tests after upgrades or configuration changes. The step is done when the refused request appears in the logs and the permitted request succeeds.

  7. Confirm fallback behavior before wider rollout

    If you configure fallbacks or priority ordering in the router, test them by temporarily making a primary model unavailable in a non-production setup, or by using a deliberately invalid route in a test configuration. Confirm that the router retries and then moves to the fallback model, and that the request log shows which model served the response. Review the routing documentation for the retry and cooldown settings in your release before relying on them. The step is done when the fallback is observed in logs and the team agrees on which model should answer under failure.

How people, teams and keys map to LiteLLM objects

This table maps each organizational concept in a Gemini CLI rollout to its LiteLLM object, along with where the source of truth lives, where the key is stored, who can rotate it and what the audit trail records. Read it as a checklist before you assign budgets or depend on identity provider groups. The main takeaway is that the mapping only holds for SSO-based access if your user count stays within the free SSO tier or you hold an Enterprise license.

Organizational conceptLiteLLM objectSource of truth and storageRotation and audit trail
DeveloperUser, with models and budget inherited from team membershipYour identity provider or HR directory. Confirm whether users are created by admin invitation or by automatic upsert on first sign-in.Admins or the user can request rotation of keys. The audit trail depends on edition: confirm whether your edition records admin changes to users.
Team (for example, a platform or product squad)Team with its own budget and allowed model listTeam roster in LiteLLM, optionally synced from identity provider groups. Group sync may require an Enterprise license, so confirm before relying on it.Team budget edits are recorded in spend and admin logs. Confirm which change events your edition exports to your SIEM.
Developer laptop running Gemini CLIVirtual key with a per-key budget, TPM and RPM limits and a model listKey value generated in LiteLLM and stored in the developer's environment, read by Gemini CLI through the environment variable named in your configuration. Confirm the exact variable name in the LiteLLM Gemini CLI tutorial.Key rotation is an admin or key-owner action in LiteLLM. Spend and requests are logged against the key, so a leaked key can be traced to a device or person only if the key is issued per developer.
Gemini CLI base URL and key settingProxy endpoint plus the virtual key read from the environment, not a provider keyManaged developer configuration or shell profile. Provider credentials stay in the gateway, never on the laptop.Changes to the base URL or key handling are configuration changes, tracked in your configuration management system rather than in LiteLLM.
Identity provider group for SSO sign-inTeam or role mapping at loginIdentity provider. SSO is free for up to 5 users from v1.76.0, and an Enterprise license is needed beyond that, so confirm user count before the mapping relies on groups.Sign-in events come from the identity provider. Confirm which login and group change events reach LiteLLM logs in your edition.
Service account for automation or shared runnersKey not tied to a person, with its own budget and model listSecret manager, referenced from the gateway configuration. Do not store the master key in developer tooling.Rotate on a schedule owned by the platform team. Confirm how service keys are labelled so that spend in reports stays attributable.

How fallbacks and budgets behave when a provider fails

When a model behind the gateway fails, LiteLLM's router decides where the Gemini CLI request goes next, and the key that made the request keeps its limits. The router offers simple-shuffle, usage-based, latency-based, least-busy and cost-based strategies, with simple-shuffle as the recommended default. Around that choice sit retries, cooldowns that take a deployment out of rotation after repeated failures, and priority ordering that tells the router which fallback to try first. For a Gemini CLI setup, confirm which deployments share the requested model name, which ones are listed as fallbacks, and in what order the router should try them. Then write that order down so the platform owner can explain it during an incident.

A fallback moves the request to another model, but it does not reset the calling key. The virtual key's budget, TPM and RPM limits, and its list of allowed models still apply to the fallback target, and spend is recorded against the same key and team. If the fallback target is not on the key's allow-list, LiteLLM refuses the request rather than sending it to an unapproved model. That refusal is a feature for governance, but it means a developer can see errors during an outage that look like access problems. Decide before rollout which fallback targets each Gemini CLI key or team is allowed to reach, and align the router configuration with those allow-lists so the failover path and the access policy match.

Test fallbacks before anyone relies on them. In a non-production LiteLLM deployment, point a test model entry at a deliberately disabled or invalid provider credential, send Gemini CLI traffic through it, and confirm that the request reaches the approved fallback, that the cooldown and retry behavior match your settings, and that spend lands on the expected key. Then send a request with a key whose allow-list excludes the fallback and confirm the refusal and the error message the developer receives. Repeat the test after each change to router settings, model lists or key policies, and confirm the exact routing and cooldown behavior against the LiteLLM routing documentation for the release you run.

Security settings for a Gemini CLI gateway

Gemini CLI on developer laptops should hold one thing that can be revoked: a LiteLLM virtual key. The master key, provider credentials, admin access and logging decisions stay on the gateway, where the platform team controls them. The cards below cover the controls that matter most for this integration and which of them need an Enterprise license.

Keep the master key in a secret manager

LITELLM_MASTER_KEY must start with sk- and has full administrative power over the proxy, including creating keys and reading spend. Store it in a secret manager and inject it into the proxy at runtime, never in a developer's shell profile, a repository or a Gemini CLI settings file. Check that no one outside the platform team can read it and that rotation is planned, since rotating it affects every administrative script that uses it.

LiteLLM production guide

Keep provider credentials on the gateway

Developers' local settings should hold only a revocable virtual key and the gateway base URL. Provider API keys for Gemini, Vertex or other approved models belong in the proxy configuration, where they are used on the server side. If a laptop is lost, revoking one virtual key cuts off that person without rotating provider credentials for the whole organization.

Issue one virtual key per person or team

Give each developer, or each team that needs a shared service account, its own virtual key with a budget and rate limits. Virtual keys support per-key, per-user and per-team budgets, TPM and RPM limits, and restriction to specific models, so a key can reach only the Gemini models the team approved. Avoid one key shared across developers: spend, logs and revocation then cannot be traced to a person.

Virtual keys docs

Narrow each key's model list

Set the allowed model list on every key so that a coding session cannot fall through to an expensive or unapproved model. Confirm with the model owners which routes each group may use, then test one key against a model outside its list to confirm the proxy refuses it. Review the lists when a provider adds or retires models, because the gateway enforces only what is written into the key.

Restrict access to the proxy admin UI

The admin UI can create keys, change budgets and view spend across the organization. Limit network access to it to your administrators' networks or a VPN, and confirm which login method guards it. Single sign-on in the admin UI is free for up to 5 users from v1.76.0, and beyond that needs an Enterprise license, so plan the login model before onboarding a larger group.

Admin UI SSO docs

Plan which controls need Enterprise

Audit logs, IP allowlisting, organization and team RBAC, and secret manager integrations with AWS, Azure, Google, HashiCorp Vault or CyberArk are Enterprise features. Without them, you can still protect the master key with your own secret manager, but you cannot have LiteLLM read secrets from it directly or restrict the proxy by source IP. Ask the vendor to confirm the current feature list for your edition before you design the rollout around it.

Enterprise docs

Why Gemini CLI requests fail through LiteLLM and how to fix them

This table lists the failures most often seen when Gemini CLI calls a LiteLLM gateway, with the likely cause, the fix and the first check to run for each. Read it top to bottom when a request fails, starting with the version and key checks, since they rule out the most common causes quickly.

FailureLikely causeFixFirst check to run
Gemini CLI routes fail or ignore the proxyLiteLLM build older than v1.73.3-nightly, which lacks Gemini CLI routingUpgrade to v1.73.3-nightly or a later release that includes it, then restart the proxyRun the proxy version command and compare it with the tutorial's minimum
Request rejected for model not allowedVirtual key does not list the model Gemini CLI requestedAdd the model to the key's allowed models or request a different model in the CLI settingsInspect the key's model list in the admin UI or key info endpoint
Requests return budget or limit errorsKey, user or team budget, or its TPM or RPM limit, has been reachedRaise the budget or limit, or apply a temporary budget increase for the affected keyCheck spend and current TPM and RPM usage against the key's limits
Virtual keys stop working or cannot be createdNo PostgreSQL database connected, which virtual keys requireSet the database URL, run database migrations and restart the proxyConfirm the proxy starts with a database connection and no migration errors in logs
Rate limits behave inconsistently across instancesSeveral proxy instances run without Redis, so limits and router state are not sharedDeploy Redis 7.0 or newer and point every instance at itConfirm each instance connects to the same Redis endpoint and reports it at startup
Admin calls or proxy startup fail on the master keyLITELLM_MASTER_KEY does not start with sk-Generate a new master key with the sk- prefix and store it in your secret managerCheck the first characters of the key value in the secret, without logging the full value
Fallback requests fail or go to an unexpected modelFallback target is outside the key's or team's allow-listAdd the fallback model to the allow-list or remove it from the fallback chainCompare the fallback targets in the router config with the allowed models for the key

What buyers ask before a Gemini CLI gateway rollout

What does a Gemini CLI gateway rollout cost, and what is one-time versus recurring?

The cost has three parts: infrastructure, software licensing and people. Infrastructure is the LiteLLM proxy, PostgreSQL (the primary supported database for LiteLLM) and Redis 7.0 or newer once more than one proxy instance runs. These recur monthly from your cloud or data center budget. Licensing is one-time to set up only if you need features outside the open-source edition. LiteLLM is MIT licensed outside the enterprise directory, and the enterprise directory uses its own license. People time is mostly one-time: design, configuration, the Gemini CLI setup and testing. Recurring time covers upgrades, key rotation and log review. Ask any partner for a quote that lists each item separately, names who pays for each, and states what is one-time and what recurs.

Which Enterprise features need a paid license for Gemini CLI users?

Single sign-on in the admin UI is free for up to 5 users from v1.76.0. Beyond that, you need an Enterprise license for SSO and SCIM. Other Enterprise features include JWT authentication with identity provider tokens, audit logs, organization and team RBAC, IP allowlisting, secret manager integrations, and team-level guardrails and logging. If every developer will sign in through your identity provider, the license question comes early. Confirm the current license terms and pricing directly with LiteLLM before you commit, because the number of SSO users decides whether a license is needed at all.

What makes the effort grow for a Gemini CLI gateway rollout?

Effort rises with the number of teams, the number of model providers, and the SSO and secret management you already run. Each team adds budgets, model access rules and key ownership. Each provider adds credentials, routes and cost settings. Single sign-on requires identity provider configuration and group mapping. If you already run a secret manager such as HashiCorp Vault or a cloud secret service, the gateway can use it, but the connection still needs design and testing. Ask for the quote to list teams, providers, identity integration and secret handling as separate line items so you can see which choices move the price.

How long does a Gemini CLI gateway rollout take?

Duration depends on the scope agreed in writing before work starts. A single team using one provider with a shared database is a smaller engagement than several teams, multiple providers, SSO and audit logging across regions. Timelines should come from the written scope, not from a general rule. Ask the implementer to show the phases, the decisions needed from your side, the testing before developers receive keys, and the point at which Gemini CLI is working for a pilot group. Also confirm the LiteLLM version the integration needs. The Gemini CLI routing path is available from v1.73.3-nightly and above, so the version check belongs in the first phase.

What does our team need to provide for the rollout?

Plan for four groups of input. Identity owners must confirm how developers sign in, which groups map to teams, and how access ends when someone leaves. Network staff must allow traffic from developer machines or a VPN to the gateway, and from the gateway to the model providers, and approve any internal DNS and certificate changes. Provider account owners must create or approve the accounts, keys and quotas for the models you allow. Platform staff must provide the Kubernetes or virtual machine environment, the PostgreSQL and Redis services, and a secret store for the master key. Confirm each owner and date in writing before the build starts.

Can our own engineers do this without outside help?

Yes, if you have engineers who can run Kubernetes or a comparable container platform, operate PostgreSQL and Redis, configure an identity provider, and review logs and security settings. The LiteLLM documentation covers the production setup, virtual keys, routing and SSO in detail. The harder parts are usually the team and budget design, the identity mapping, the security review of the gateway and the evidence your compliance team will ask for. Many organizations do the build in-house and bring in a partner for the review or for ongoing support. Compare your team's time, skills and on-call capacity against a written partner scope before you decide.

How DeployOpen scopes and delivers a Gemini CLI gateway integration

DeployOpen treats the Gemini CLI integration as part of a wider self-hosted LiteLLM gateway inside your infrastructure, not as a standalone developer setting. We agree the scope in writing, build and test the routing, keys and budgets in your environment, and hand over the configuration and runbooks your team needs to operate it.

How we scope

  • Confirm which LiteLLM release line and minimum version your Gemini CLI setup needs before any build work starts.
  • Map which approved models developers may reach through the gateway, and which fallbacks each model group should use.
  • Agree in writing how virtual keys, per-person and per-team budgets, and rate limits will be issued and enforced.

How we build

  • Deploy the LiteLLM proxy with PostgreSQL and, where more than one instance runs, Redis in your cloud accounts or data centers.
  • Configure Gemini CLI to route through the gateway, then test model access, key restrictions, budget caps and fallback behavior.
  • Verify that prompts and spend appear in logs as designed, and document any gaps for your security and compliance teams to review.

How we hand over

  • Deliver configuration as code, developer setup instructions and the key issuance procedure your administrators will follow.
  • Document the upgrade path, the database migration steps and the supported release line so your team can plan future changes.
  • Walk your platform and security staff through the runbook for common failures and what to collect before escalating.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work begins.
  • Ongoing support, upgrades and continuous testing are available as a retainer, and a quote follows from the written scope.
  • Ask us to confirm which Gemini CLI and LiteLLM versions your environment has been tested against before you roll out to developers.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.