Skip to content

Support Google Gemini flex service tier (50% discount on non-time-sensitive requests) #78258

@aurelien64

Description

@aurelien64

Background

Google's Gemini API supports a "flex" service tier that offers a 50% discount on non-time-sensitive requests. It's a great fit for cron / batch / heartbeat jobs that don't need fast response.

OpenClaw already has serviceTier plumbing for OpenAI, Anthropic, and Minimax (via createOpenAIServiceTierWrapper, createAnthropicServiceTierWrapper, etc.), but no equivalent for the Google provider.

Current behavior (2026.5.4-beta.1, commit 9cc3ae1)

Setting a model as google/gemini-3.1-flash-lite-preview?serviceTier=flex in a cron payload (or anywhere a model ref is parsed):

  1. normalizeStaticProviderModelId (model-ref-shared-CCa0R1eg.js:12-22) does not strip the query string — the entire gemini-3.1-flash-lite-preview?serviceTier=flex is treated as the model id.
  2. The allowlist check fails unless the literal …?serviceTier=flex string is also added to agents.defaults.models.
  3. Even when allowlisted, Google returns either 404 Unknown Model or an empty response, since the literal model name doesn't exist.

So ?serviceTier=flex is currently a no-op syntactically — it isn't parsed anywhere, and there's no Google wrapper that would honor it.

Request

Add Google flex tier support, mirroring the existing OpenAI/Anthropic implementations:

  • A createGoogleServiceTierWrapper (analogous to createOpenAIServiceTierWrapper).
  • Wire it into the Google provider stream composition (provider-stream-…js).
  • A configuration path — either:
    • per-model option in agents.defaults.models[<id>].serviceTier = "flex", or
    • per-call override on cron payloads / agent turns, or
    • the existing ?serviceTier=flex model-id query syntax, parsed centrally and stripped before the allowlist + provider call.

Workaround for users hitting this

Use bare model ids (no ?serviceTier=flex) — costs full standard tier but jobs run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions