Forward `service_tier` to xAI for `default` and `priority` processing

Closed
PY
22d ago
+34-3

Closes #12071

Setting service_tier on an xAI model was rejected as unsupported, so the unified ModelSettings.service_tier could not opt an xAI request into priority processing.

Changes

  • pydantic_ai_slim/pydantic_ai/models/xai.py: map service_tier in _XAI_MODEL_SETTINGS_MAPPING, drop values without an xAI gRPC equivalent (auto, flex) in _map_model_settings, and remove service_tier from XaiModel.unsupported_settings.
  • pydantic_ai_slim/pydantic_ai/settings.py: add xAI to the service_tier Supported-by list.

priority and default now reach xAI. Requests that previously had priority silently dropped may now run with priority processing and incur xAI priority billing when the response confirms that tier. Live end-to-end transmission is unverified (no xAI API key; tests mock the gRPC send boundary). Recording the response tier in provider_details and the REST-only fast tier are follow-ups.

Tests: tests/models/test_xai.py::test_service_tier_priority_and_default_forwarded, tests/models/test_xai.py::test_service_tier_auto_and_flex_stay_unsupported, and tests/models/test_model_settings_support.py via uv run pytest tests/models/test_xai.py::test_service_tier_priority_and_default_forwarded tests/models/test_xai.py::test_service_tier_auto_and_flex_stay_unsupported tests/models/test_model_settings_support.py

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.

Summary by cubic

xAI models now forward service_tier values default and priority instead of rejecting the setting, enabling priority processing. Priority requests may incur xAI priority billing.

  • Values auto and flex are dropped because the xAI gRPC API has no equivalent.