Repository navigation
Add Google AI Studio usage via Cloud Monitoring #3072
Description
Summary
Could CodexBar add a separate Google AI Studio provider for project-level Gemini API usage through the official
Cloud Monitoring API and gcloud Application Default Credentials?
This is distinct from:
- Gemini, which uses Gemini CLI OAuth and private quota APIs;
- Vertex AI, which monitors
aiplatform.googleapis.com; - Add Google and xAI models.dev pricing lookup #2377, which adds model pricing lookup rather than project quota telemetry.
Evidence
I ran a read-only seven-day spike against an active project. It made no Gemini generation calls, imported no cookies,
and changed no APIs, IAM, or project settings.
- 14 populated native
generativelanguage.googleapis.com/*series; - 6 unambiguous quota usage/limit pairs;
- request, input/output token, and model-level data available;
- about 48 minutes of observed reporting lag.
Native Gemini metrics were sufficient; generic Service Runtime quota metrics were not.
Proposed v1
- Built-in provider using ADC, reusing/refactoring Vertex AI's Cloud Monitoring transport.
- Explicit project selection; no automatic Google Cloud changes.
- Primary window: highest unambiguous quota usage.
- Details: project/model request and token totals plus update time.
- No browser cookies, private AI Studio endpoints, per-key breakdown, billing/cost, or cross-provider fallback.
- Never render or log project/credential label values.
A local provider plugin cannot support this safely today because plugins cannot access gcloud/ADC.
Would a separate built-in Google AI Studio provider fit CodexBar's provider boundary?
If accepted, I can prepare a focused implementation that reuses the existing Vertex AI ADC and Cloud Monitoring code
where practical, with fixture-only tests and no live credentials.
Activity
clawsweeper commentedon Aug 19, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 5, 2026, 10:54 AM ET / 14:54 UTC.
Summary
Keep open in the owner’s provider queue. Current main and v0.56.6 lack this capability; the contributor’s user-ADC trace strengthens feasibility, but the owner has not approved implementation.
Reproducibility: not applicable. this requests new provider coverage rather than reporting broken behavior; the supplied direct-API trace supports feasibility and was not rerun.
Ways to help us reproduce this
Maintainer decision needed
Why: Feasibility evidence supports the proposed credential path, but the owner has only queued the proposal and authentication, privacy, and presentation scope require sign-off.
Next step
Owner approval of the project-selection, user-ADC, and telemetry-presentation contract is required before implementation; automated repair is inappropriate for this new capability.
Review details
Best possible solution:
If sponsored, use an opt-in native provider with explicit project selection, reusable ADC/Monitoring transport, strict quota pairing, redacted diagnostics, and clearly dated telemetry.
Do we have a high-confidence way to reproduce the issue?
Not applicable: this requests new provider coverage rather than reporting broken behavior; the supplied direct-API trace supports feasibility and was not rerun.
Is this the best way to solve the issue?
Yes, conditionally: native integration fits existing ADC ownership, while plugins lack the required access; Vertex-specific metric parsing and identity rendering should not be reused unchanged.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 1696c7a71c94.
Label changes
Label justifications:
P3: This is optional provider coverage awaiting product approval, with no reported regression or blocked existing workflow.Evidence reviewed
What I checked:
Sources/CodexBarCore/Providers/VertexAI/VertexAIOAuth/VertexAIUsageFetcher.swift:78, 1696c7a71c94)Sources/CodexBarCore/Providers/VertexAI/VertexAIOAuth/VertexAIOAuthCredentials.swift:185, 1696c7a71c94)Sources/CodexBarCore/Plugins/QuickJSProviderPluginEngine.swift:458, 1696c7a71c94)Sources/CodexBarCore/Providers/ProviderManifest.swift:7, 1696c7a71c94)Likely related people:
How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.brzvsk commentedon Aug 19, 2026
Thanks — agreed. To make the proposed contract explicit:
generativelanguage.googleapis.comrequest/token series; pair quota/usageand/limitonly when metric family, model, tier, location, and limit name match unambiguously. Ambiguous pairs fail soft.A screenshot would not add meaningful evidence before implementation because this is API feasibility rather than broken UI behavior. The read-only spike provides the expected-vs-observed evidence: requests, input/output tokens, model labels, and six unambiguous quota pairs were available, with roughly 48 minutes of observed lag.
I’ll wait for owner sign-off before starting production implementation.
steipete commentedon Aug 19, 2026
Triage: provider proposals are batched for an owner decision, so parking this with the queue (Vercel AI Gateway #2975, Notion #2888, Atlas #2714, etc.). Noting the design constraint for whenever it's picked up: Cloud Monitoring requires a GCP project + service-account auth, which is a heavier setup than most CodexBar providers — it would likely land as an explicitly-configured, API-key-style provider rather than an auto-detected one.
brzvsk commentedon Aug 19, 2026
Thanks for the thoughtful triage and for parking this with the provider queue.
One clarification for the eventual owner decision: the successful spike did not use a service account. It used
ordinary user ADC created by
gcloud auth application-default loginon an account that already had read access to CloudMonitoring.
Exact commands and redacted output
Authentication proof
No service-account key JSON, service-account impersonation, API key, browser cookie, or
GOOGLE_APPLICATION_CREDENTIALSoverride was used. The access token was short-lived and never written to the report orlogs.
Minimal direct API reproduction
This reproduces the relevant read-only calls on macOS for a project that already has Gemini API traffic and an enabled
Monitoring API. The user needs
monitoring.metricDescriptors.listandmonitoring.timeSeries.list; the commands do notenable APIs or change IAM/project configuration.
Observed output:
{ "descriptor_count": 146, "selected_generate_content_metrics": 36 }Example native quota query:
Redacted excerpts from the actual run included unambiguous per-model request pairs:
[ { "limit_name": "GenerateRequestsPerMinutePerProjectPerModel-PaidTier2", "model": "<redacted-model-a>", "usage": 3, "limit": 1000, "used_percent": 0.3 }, { "limit_name": "GenerateRequestsPerMinutePerProjectPerModel-PaidTier2", "model": "<redacted-model-b>", "usage": 18, "limit": 2000, "used_percent": 0.9 } ]Full spike result
For the 168-hour read-only run:
generate_contentmetric types were queried;1,172,772 / 3,000,000(39.0924%);16,091and75,244over the selected window;12and152;So I agree that this should be explicitly configured rather than auto-detected, but the minimum setup can be **project ID
change the user's gcloud project or Google Cloud configuration.
steipete commentedon Sep 24, 2026
The Cloud Monitoring endpoint is documented, and the reporter’s clarification confirms existing user ADC is sufficient; a service-account key is not inherently required. Bundled plugins currently lack ADC acquisition and OAuth refresh. Keeping this open for a shared, project-scoped auth capability before implementing delayed Gemini API telemetry. No Google account or project configuration was changed.
steipete commentedon Oct 8, 2026
Thanks @brzvsk. The native Gemini metrics are documented, but their aggregation/model matching differs from Vertex quota data. Plugins also lack project-scoped ADC acquisition/refresh. Closing the configuration-only approach; AI Studio needs that shared auth capability and a delayed-telemetry contract. Existing user ADC can work; a service-account key is not inherently required.