Headless Gemini CLI and MCP auth: use a Sume API key
A headless Gemini CLI run cannot finish a browser consent. Connect to hosted Sume MCP with an API key header instead, and keep paid calls bounded.

In a headless environment such as CI, connect the Gemini CLI to Sume's hosted MCP server with an API key sent as Authorization: Bearer <SUME_API_KEY> or x-api-key, not with OAuth. OAuth needs a person to approve a consent page in a browser, and a headless job has nobody to do that.
What the Gemini CLI release notes say
The Gemini CLI releases page lists, in v0.63.0-preview.0 (September 29), "fix(auth): prevent infinite auth loop from file contention, headless keyring, and supervisor state drops". That fix concerns the CLI's own sign-in, not Sume. It does show that interactive auth is a fragile fit for headless runs, which is why an MCP server that answers with an OAuth challenge is a poor target for a client with no browser to complete it.
Why OAuth does not fit a headless run
Sume's hosted MCP sends an OAuth challenge and protected-resource metadata. The client then sends the user to https://mcp.sume.com/oauth/authorize, which continues to a first-party consent page on the MCP host. After sign-in the consent page shows a Read permission that is locked on and a Write toggle that is off by default. That flow is designed for an interactive human.
| Mode | How you connect | What the session can do |
|---|---|---|
| OAuth | Client follows the MCP OAuth flow and a person approves consent | mcp:read is required and read-only; Write is an opt-in toggle that grants mcp:write |
| API key | Send Authorization: Bearer <SUME_API_KEY> or x-api-key | Full hosted tool set; spend goes through wallet admission; idempotency_key is required on writes and paid calls |
Use the key without leaking it
Create the key in the Sume dashboard and keep it in your CI secret store. Hand it to the client from the CI secret mechanism rather than writing it into a prompt or a committed file. Sume's guidance is to rotate an API key if it shows up in logs or chat history.
An OAuth access token is not a Sume API key. Do not mint an API key as a way to fake an OAuth client, and do not paste an OAuth token into a prompt.
Bound the spend
An API-key session sees write and paid tools, so a headless agent can start paid generations. The docs give three controls to use before the first paid call:
dry_run=truepreflights the cost without submitting.generation_admission_previewshows what admission would decide.max_spend_usdcaps spend when you pass it. It is enforced only when provided.- Every write or paid call needs an
idempotency_key, so a retried step does not submit twice.
A read-only alternative
If the job only needs to look things up, an OAuth session with mcp:read sees read-only tools only. A mutating tool called without write scope returns insufficient_scope. For a headless job, though, the practical read-only choice is to run the job interactively once and keep the automation on a scoped API key with a spend cap.
Sources
Related posts
More in Developers
- Gemini CLI untrusted tool output provenance: Sume results as data
Gemini CLI 0.60 and 0.61 release notes name fixes for untrusted tool output and indirect prompt injection. Keep Sume write tools behind scope and caps.
- Omni Flash prompts in English, captions in your language
Google says Omni fully supports English; other languages are unevaluated. Prompt in English, then add captions in your language with Sume's captions API.
- Gemini Omni Flash resolution: "4K" or "4k" on Sume
Sume accepts 4k as an alias of 4K for Gemini Omni Flash 1.1 and translates it to the lowercase token fal expects. Billed rate and Google's 4K caveat.
- GitHub Actions and Sume: secret setup and a smoke test
Store SUME_API_KEY as a GitHub Actions secret, never echo it, and run sume account get --json as a read-only smoke test in a manually triggered workflow.
Written by Sume