Skip to content

Conversation

AstroAir
Copy link

@AstroAir AstroAir commented Oct 4, 2025

This pull request adds first-class support for Zhipu AI (智谱AI) models to Pydantic AI, including documentation, provider implementation, model profiles, and tests. Users can now use Zhipu's OpenAI-compatible API seamlessly in the framework, with support for advanced features like vision and function calling. The documentation and example scripts guide users through setup and usage.

Key changes in this pull request:

Zhipu AI Provider and Model Support:

  • Added ZhipuProvider class for Zhipu AI, enabling authentication via API key or environment variable, custom base URL, and HTTP client configuration. This allows users to access Zhipu's OpenAI-compatible API directly from Pydantic AI.
  • Added Zhipu AI model names (e.g., zhipu:glm-4.6, zhipu:glm-4.5, vision and code models) to the list of known models and updated model inference logic to support Zhipu as a provider. [1] [2]
  • Implemented Zhipu-specific model profile logic, handling differences from OpenAI (e.g., temperature range, strict tool definition mode, vision model support).

Documentation and Examples:

  • Added comprehensive documentation for Zhipu AI usage, including installation, configuration, available models, features (function calling, streaming, vision), and important behavioral notes.
  • Included Zhipu AI in the models overview and navigation, and added a runnable example script (examples/zhipu_example.py). [1] [2] [3]

Compatibility and Validation:

  • Improved OpenAI-compatible response handling to accommodate Zhipu's omission of the object field in API responses, ensuring schema validation succeeds.
  • Updated provider inference logic to recognize and instantiate the Zhipu provider.

Testing:

  • Added a dedicated test suite for the Zhipu provider, covering initialization, environment variable handling, error cases, and model profile features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant