python Pydantic AI Releases · · 2.2.0

pydantic-ai v2.2.0: New AI model support and numerous bug fixes

sdkaiengineermediapython-agentic
feature patch

Pydantic-ai version 2.2.0 introduces support for Anthropic's Claude Sonnet 5 and adds usage cost fields for OpenRouter. Several bug fixes are included, addressing issues with GroqModel metadata, Pyodide callbacks, usage accumulation, and Heroku routing. These updates benefit developers integrating various AI models and enhance the stability and functionality of the pydantic-ai library.

  • add TwelveLabs Pegasus video-understanding example by @mohit-twelvelabs in https://github.com/pydantic/pydantic-ai/pull/6061
  • Add Claude Sonnet 5 (claude-sonnet-5) support by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6161
  • Allow factory functions as lifecycle arg for Dataset.evaluate by @nlsfnr in https://github.com/pydantic/pydantic-ai/pull/6107
  • Add prompt and completions cost fields to OpenRouter by @ali-corpo in https://github.com/pydantic/pydantic-ai/pull/4899
  • add retry_options parameter to GoogleProvider by @graydeon in https://github.com/pydantic/pydantic-ai/pull/4966
Features (5)
  • feat add TwelveLabs Pegasus video-understanding example by @mohit-twelvelabs in https://github.com/pydantic/pydantic-ai/pull/6061
  • Add Claude Sonnet 5 (claude-sonnet-5) support by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6161
  • Allow factory functions as lifecycle arg for Dataset.evaluate by @nlsfnr in https://github.com/pydantic/pydantic-ai/pull/6107
  • feat Add prompt and completions cost fields to OpenRouter by @ali-corpo in https://github.com/pydantic/pydantic-ai/pull/4899
  • feat add retry_options parameter to GoogleProvider by @graydeon in https://github.com/pydantic/pydantic-ai/pull/4966
Fixes (16)
  • Forward image detail from vendor_metadata for GroqModel and MistralModel by @pydanty[bot] in https://github.com/pydantic/pydantic-ai/pull/6014

  • fix(utils): run sync callbacks inline on Pyodide/emscripten by default by @syf2211 in https://github.com/pydantic/pydantic-ai/pull/6088
  • Fix group_by_temporal emitting first item alone when delayed past soft_max_interval by @pydanty[bot] in https://github.com/pydantic/pydantic-ai/pull/5947

  • Fix missing output_audio_tokens in usage accumulation by @jnMetaCode in https://github.com/pydantic/pydantic-ai/pull/4594
  • fix(heroku): route model names through family profiles so thinking isn't dropped by @Bartok9 in https://github.com/pydantic/pydantic-ai/pull/6070

  • Guard TogetherProvider.model_profile against model names without a / by @immuhammadfurqan in https://github.com/pydantic/pydantic-ai/pull/6113

  • fix(GoogleModel): include CodeExecutionTool in include_server_side_tool_invocations check by @aarsh767 in https://github.com/pydantic/pydantic-ai/pull/6052

  • fix(groq): surface reasoning_tokens in usage details by @tcconnally in https://github.com/pydantic/pydantic-ai/pull/5986
  • Fix map downstream_join_id double-firing the join on a non-empty iterable by @clavedeluna in https://github.com/pydantic/pydantic-ai/pull/6009

  • fix de-duplicate output_audio_tokens accumulation in _incr_usage_tokens by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/6141
  • Suppress ClosedResourceError when cancelling a graph run mid-send by @conradlee in https://github.com/pydantic/pydantic-ai/pull/6149
  • fix(ui): round-trip file vendor_metadata through Vercel AI & AG-UI adapters by @Bartok9 in https://github.com/pydantic/pydantic-ai/pull/5790
  • Handle CRLF markdown JSON fences in strip_markdown_fences by @CodingFeng101 in https://github.com/pydantic/pydantic-ai/pull/6090
  • fix(heroku): avoid duplicating /v1 in base_url by @VectorPeak in https://github.com/pydantic/pydantic-ai/pull/6142
  • Fix absolute schema_path handling in Dataset.to_file by @VectorPeak in https://github.com/pydantic/pydantic-ai/pull/6143
  • Fix deps deserialization in non-streaming Temporal model-request activity by @dsfaccini in https://github.com/pydantic/pydantic-ai/pull/5900
Read the original announcement →

https://github.com/pydantic/pydantic-ai/releases/tag/v2.2.0

Related releases