Add `service_tier` support to `GroqModel`
Closes #12072
This carries #12666 forward as a maintainer-authored PR. The change needs an API-compatibility waiver under .github/, and the .github Directory Guard accepts .github/ changes only from maintainers, never from pydanty[bot].
GroqModel listed service_tier in unsupported_settings, so every unified tier was dropped from the request and the tier Groq served was discarded. This implements the maintainer decision on #12072: map the unified tiers onto Groq's, add groq_service_tier for Groq's native values, and surface the served tier in provider_details.
[!WARNING]
Compatibility impact: a unified service_tier set in settings shared across models, for example on a FallbackModel or an Agent that also runs Groq, now reaches Groq instead of being dropped. Unified 'flex' then sends Groq's flex tier, which fails fast with a 498 when Groq is at capacity (#12062 tracks its error category).
Why this can ship in a minor release: ServiceTier documents that the unified field maps onto each provider's tiers and is ignored only where a provider lacks the tier. Groq has these tiers, so dropping them was a bug. This ships under the version policy's bug-fix exception: only code that relied on Groq ignoring service_tier, which nothing documented, sees a change.
Migration: to keep Groq on its standard tier while other models use flex, set groq_service_tier='on_demand' in the Groq model's settings, or set service_tier per model rather than in shared settings.
New public surface: GroqModelSettings.groq_service_tier: Literal['auto', 'on_demand', 'flex', 'performance'].
User-visible behavior:
Agent('groq:llama-3.3-70b-versatile', model_settings={'service_tier': 'flex'})
-# request body: no service_tier
+# request body: "service_tier": "flex"
unified service_tier | sent to Groq |
|---|---|
'auto' | 'auto' |
'default' | 'on_demand' |
'flex' | 'flex' |
'priority' | (omitted) |
groq_service_tier wins over the unified field and is the only way to reach the enterprise 'performance' tier. The tier rides in extra_body, like reasoning_effort, because the minimum supported groq SDK (0.25.0) types service_tier without 'performance'. Streamed requests carry the tier too. The served tier lands in ModelResponse.provider_details['service_tier'] on non-streamed responses; streamed chunks carry no tier, so streamed responses are read as before.
Verification:
test_service_tiercaptures the outgoing request body withhttpx.MockTransport: each mapped value,priorityomitted,performance, precedence, and the merge with a userextra_bodyandreasoning_effort;test_service_tier_streamed_requestdoes the same for a streamed request. Both live intests/models/test_groq_service_tier.py. No Groq API key was available to record a cassette, so a liveflexrecording is parked on credentials; the maintainer decision allows a captured request body in that case.- Six existing cassette snapshots gain
'service_tier': 'on_demand'inprovider_details, because the recorded Groq responses already carry it. - The unchanged probes in
tests/models/test_model_settings_support.pypass withservice_tierout ofunsupported_settings. - The API compatibility gate's
GroqModel.unsupported_settingschange is waived in.github/api-compatibility-waivers/86956c2a7b69b71c63793e85e0042aabe6fc8f7abd5dbec695ed2267a5c979e5.json.
What changes for existing users: a service_tier that Groq used to drop is now sent; see the warning above.
Out of scope: bumping the groq SDK floor (its Omit migration is its own change), and an error category for flex's 498 (#12062).
PR decisions
2026-11-15 · adopted PR #12666 at 2026-11-15 · iter -
- Decision: Branch-context bootstrapped from existing PR + issue(s). Decisions prior to this entry are backfilled from resolved threads.
- Why: PR predates the branch-context setup
- Source: https://github.com/pydantic/pydantic-ai/pull/12666
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · tier travels in extra_body · iter -
- Decision: Send the resolved Groq tier through
extra_body, generalising thereasoning_effortmerge in_completions_create; dropcast(Any, ...) - Why: groq SDK floor 0.25.0 types
service_tierwithout'performance'; no casts orAny; a derived key overwrites a colliding userextra_bodykey, asreasoning_effortalready does - Source: https://github.com/pydantic/pydantic-ai/issues/12072
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · response tier read via isinstance(getattr) · iter -
- Decision: Read the response tier with
isinstance(getattr(response, 'service_tier', None), str) - Why:
ChatCompletiondeclares noservice_tierfield before groq 0.35.0, so it arrives as an extra;model_extrawould read None once the field is declared; truthy getattr letAnyintoprovider_details - Source: https://github.com/pydantic/pydantic-ai/issues/12072
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · inline mapping, module-level map · iter -
- Decision: Replace the single-use
_resolve_service_tierhelper with a module-level_UNIFIED_TO_GROQ_SERVICE_TIERdict resolved inline in_completions_create - Why: Answers pydanty's open choice; single-use helper rule in agent_docs/index.md; complexity stays under the limit (14); precedent
_TOP_LEVEL_TO_GLA_SERVICE_TIERin google.py - Source: https://github.com/pydantic/pydantic-ai/pull/12666#issuecomment-6673676426
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · MockTransport body capture, no cassette · iter -
- Decision: Request tests capture the outgoing body with
httpx.MockTransportintests/models/test_groq.py::test_service_tier; no live Groq recording - Why: No Groq key on this box; the maintainer decision allows a captured request body when no key is available; the tier now travels in
extra_body, which the MockGroq kwargs capture can't see as a top-level arg - Source: https://github.com/pydantic/pydantic-ai/issues/12072
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · compatibility impact: waiver + label · iter -
- Decision: Waive
GroqModel.unsupported_settings(fingerprint 86956c2a…, against v2.68.0), addcompatibility impactlabel,[!WARNING]block and release note - Why: Unified
flexin shared settings, e.g. on aFallbackModel, now reaches Groq, which can return 498 at capacity (#12062); precedent #10920 - Source: https://github.com/pydantic/pydantic-ai/pull/10920
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · pre-push review 1 of 3 at 01dc643eb83a1dfff3fe22b48183e0f0dfd32a82 · iter -
- Decision: dispatched (reserved); outcome appended below
- Why: tree af831718de6fdaef0dad3d56bf1ddad0b3b192fb; scope d564378d6..01dc643eb full branch; first review
- Source: https://github.com/pydantic/pydantic-ai/pull/12666
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · pre-push review 1 of 3 at 01dc643eb83a1dfff3fe22b48183e0f0dfd32a82 — outcome · iter -
- Decision: remediated: added test_service_tier_streamed_request (streamed request carries the tier); linked Groq's flex-processing doc for the 498; trimmed groq_service_tier docstring to precedence + performance like bedrock_service_tier. Refuted: 498 is documented at https://console.groq.com/docs/flex-processing. Skipped: groq.md mapping list stays (anthropic/bedrock page precedent)
- Why: reviewed tree af831718de6fdaef0dad3d56bf1ddad0b3b192fb; scope d564378d6..01dc643eb
- Source: https://github.com/pydantic/pydantic-ai/pull/12666
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · exempt delta 01dc643eb..ca6e40ef4 from reviewed 01dc643eb · iter -
- Decision: No review 2: test-only addition (missing-coverage row), docstring-only trim (docstring row), and a docs/models/groq.md citation link
- Why: Docs delta touches only the documentation rung: it adds a link to Groq's own flex-processing page and rewords the 498 clause to that page's sentence; it cannot move API, behavior or tests. Chains from reviewed 01dc643eb
- Source: https://github.com/pydantic/pydantic-ai/pull/12666
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · exempt delta ca6e40ef4..8c082ddc0 from reviewed 01dc643eb · iter -
- Decision: No review 2: docs/models/groq.md link markup only, applying douwebot's Optional finding
- Why: Touches only the documentation rung: it turns inline code into a reference link to the existing pydantic_ai.messages.ModelResponse.provider_details symbol, same form as docs/native-tools.md; cannot move API, behavior or tests. Chains from reviewed 01dc643eb via the logged exempt delta to ca6e40ef4
- Source: https://github.com/pydantic/pydantic-ai/pull/12666#discussion_r4576519102
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · standing rule: mask keys in live recordings (manager dispatch 2026-11-15T01:35Z) · iter -
- Decision: For every live recording with real provider keys, pipe test output through a key-masking filter inside the env-run shell, and before each push grep cassettes and commits for raw key values
- Why: Keeps provider key values out of test output and transcripts; this PR has no live recordings so far
- Source: https://github.com/pydantic/pydantic-ai/pull/12666
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · waiver moves to a maintainer PR · iter -
- Decision: A separate maintainer-authored PR carries the API-compatibility waiver file byte for byte; once it merges, merge main here so this diff no longer touches .github/; until then, leave the waiver untouched
- Why: Per .github/workflows/AGENTS.md a maintainer carries a .github/ change forward in their own PR; the .github Directory Guard refuses it on a pydanty-authored PR
- Source: https://github.com/pydantic/pydantic-ai/pull/12666
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · carry #12666 forward as dsfaccini PR #13521 · iter -
- Decision: Pushed head 8c082ddc0 to groq-service-tier-carry-forward and opened https://github.com/pydantic/pydantic-ai/pull/13521 as dsfaccini with #12666's title, labels and Closes #12072; switched this worktree to that branch
- Why: A waiver-only maintainer PR cannot pass: check_api_compatibility.py fails on an unused current-release waiver, so the whole change moves to a maintainer-authored PR, the route .github/workflows/AGENTS.md names; supersedes 'waiver moves to a maintainer PR'
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · waiver pull_request points at #13521 · iter -
- Decision: Commit b482c6b05 sets the waiver's pull_request to https://github.com/pydantic/pydantic-ai/pull/13521; no new pre-push review
- Why: The delta from reviewed content is one waiver data field; check_api_compatibility.py --against v2.68.0 passes
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · closed #12666 · iter -
- Decision: Closed https://github.com/pydantic/pydantic-ai/pull/12666 with a comment linking #13521 and the .github guard rule
- Why: Superseded by the carry-forward PR
- Source: https://github.com/pydantic/pydantic-ai/pull/12666#issuecomment-6887511093
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · #13521 at the merge bar on b482c6b05 · iter -
- Decision: CI green, PR Review Checks success, clean douwebot approval, .github Directory Guard success, 0 unresolved threads
- Why: Waiver now ships from a maintainer-authored PR
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · David picked (pydanty:review-lite) on 2026-11-15 · iter -
- Decision: Step-7 second opinion for #13521 is pydanty:review-lite, applied after main is merged and CI is green on the new head; the manager enqueues
- Why: Public setting, so the step-7 choice belongs to David; the manager runs the 12-hour freshness check before every enqueue
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · exempt delta b482c6b05..256e8f49f: merge upstream/main · iter -
- Decision: Merged upstream/main (6 commits, no conflicts) for the 12-hour freshness window; no new pre-push review
- Why: Target-branch merge row: git diff upstream/main...b482c6b05 equals git diff upstream/main...HEAD; check_api_compatibility.py --against v2.68.0 passes. Chains from reviewed 01dc643eb via the logged exempt deltas
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · applied pydanty:review-lite at 2026-11-15T22:47:32Z on 256e8f49f · iter -
- Decision: Applied after CI went green on 256e8f49f; PR Review Checks reads 'No result: tests-and-dependencies', reported to the manager, no rerun or waiver
- Why: Manager sequences PR Review Checks reruns and arms its own pydanty:is-working watch
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · defer: CLAI2 withholds unified service_tier from non-OpenAI models · iter -
- Decision: Split pydanty's optional CLAI2 finding: filed https://github.com/pydantic/pydantic-ai/issues/13560 (immediate route: dsfaccini + pydanty:skip) instead of fixing here
- Why: Reproduced: CLAI2 code is identical to main, and on main it already withholds service_tier from Google, Anthropic and Bedrock, which core honors; it is a pkg:clai2 design choice about per-provider rows and choices, so folding would widen this pkg:core PR's blast radius
- Source: https://github.com/pydantic/pydantic-ai/issues/13560
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · pydanty finding 1: live Groq cassette parked on credentials · iter -
- Decision: Keep the MockTransport body capture; a live Groq cassette for the outgoing service_tier waits for a Groq key
- Why: No GROQ_API_KEY in the keys file or environment on this box; the maintainer decision on #12072 allows 'a captured request body' when no Groq key is available
- Source: https://github.com/pydantic/pydantic-ai/pull/13521#issuecomment-6902660089
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · pydanty finding 2: move service-tier tests out of test_groq.py · iter -
- Decision: Move test_service_tier, its ServiceTierCase cases and test_service_tier_streamed_request into tests/models/test_groq_service_tier.py; the snapshot updates to existing tests stay in test_groq.py
- Why: tests/AGENTS.md Best Practices prefers feature-centric test files over appending to monolithic test_.py files; tests/models/test_groq_gateway_cost.py is the Groq precedent
- Source: https://github.com/pydantic/pydantic-ai/pull/13521#issuecomment-6902660089
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · pre-push review 2 of 3 at a293f439448e4818090a4882bab4cf81e21152cd · iter -
- Decision: dispatched (reserved); outcome appended below
- Why: tree 2f9f89faa96d177048400d2f618552b7ebcd5f4d; follow-up scope 01dc643eb..a293f4394 on the PR's files, full branch diff as context; strong tier (hosted review has commented on 3+ pushes)
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · pre-push review 2 of 3 at a293f439448e4818090a4882bab4cf81e21152cd — outcome · iter -
- Decision: remediated: groq-performance case now stubs served_tier='performance'; PR body test links moved to tests/models/test_groq_service_tier.py anchors and decisions block republished. All prior findings and hosted dispositions verified
- Why: reviewed tree 2f9f89faa96d177048400d2f618552b7ebcd5f4d; follow-up scope 01dc643eb..a293f4394 on the PR's files
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
2026-11-15 · exempt delta a293f4394..5227bdade from reviewed a293f4394 · iter -
- Decision: No review 3: one test-case stub value, applying review 2's finding
- Why: Fixture correction to established intended behavior (row 1): test data only; the #12072 probe table shows Groq serves a granted tier as requested; tests/models/test_groq_service_tier.py passes
- Source: https://github.com/pydantic/pydantic-ai/pull/13521
- Session: 0c144fde-8068-4df5-8eca-5e0cd89f4e88
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.