v2.41.0

pydantic/pydantic-aiv2.41.0Sep 8, 2026by dsfaccini

AI Summary

This release introduces a direct image generation API and a new `openai-codex` provider for subscription authentication. It also deprecates `fallback_model` in favor of `fallback_subagent_model` for `ImageGeneration` and `XSearch`, alongside bug fixes for Anthropic usage reporting and Bedrock error handling.

Key Highlights

  • New direct image generation API with `ImageGenerator`
  • New `openai-codex` provider for ChatGPT/Codex subscription authentication
  • Deprecation of `fallback_model` in favor of `fallback_subagent_model`
  • Improved Anthropic usage reporting in `RequestUsage.details` and `cost`
  • Enhanced Bedrock error handling with `ModelAPIError` wrapping

New Features

  • Direct image generation API with `ImageGenerator`
  • `openai-codex` provider for ChatGPT/Codex subscription authentication

Full Release Notes

<!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed
### 🚀 Features
* Deprecate `fallback_model` in favor of `fallback_subagent_model` on `ImageGeneration` and `XSearch` by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/8077
* Add `openai-codex` provider for ChatGPT/Codex subscription authentication by @mpfaffenberger in https://github.com/pydantic/pydantic-ai/pull/7769
* Add a direct image generation API with `ImageGenerator` by @EgonFerri in https://github.com/pydantic/pydantic-ai/pull/5357
### 🐛 Bug Fixes
* Report Anthropic native web searches in `RequestUsage.details` and price them in `cost` by @adtyavrdhn in https://github.com/pydantic/pydantic-ai/pull/8169
* Wrap botocore transport errors in `ModelAPIError` in `BedrockConverseModel` by @kimnamu in https://github.com/pydantic/pydantic-ai/pull/8131
* Snap Gemini thinking levels to the nearest supported level by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/8165

## New Contributors
* @kimnamu made their first contribution in https://github.com/pydantic/pydantic-ai/pull/8131
* @EgonFerri made their first contribution in https://github.com/pydantic/pydantic-ai/pull/5357

**Full Changelog**: https://github.com/pydantic/pydantic-ai/compare/v2.40.0...v2.41.0