Skip to content

Conversation

@kevariable
Copy link

Description

Add Z AI provider integration with Text and Structure support

This PR adds a new AI provider "Z" to Prism, enabling users to interact with Z AI models for text generation and structured data responses.

Features Added:

  • Text Generation: Full support for text generation with prompts, system prompts, and temperature/top_p configuration
  • Structured Output: Support for structured data generation with JSON schema validation
  • Tool Calling: Multi-step tool execution with parallel tool calls support
  • Error Handling: Proper exception handling including rate limiting (429 errors)
  • Flexible Configuration: Support for custom client options and retry configuration

Provider Implementation:

  • Provider class: Prism\Prism\Providers\Z\ZProvider
  • Text handler: Prism\Prism\Providers\Z\Handlers\Text
  • Structure handler: Prism\Prism\Providers\Z\Handlers\Structure
  • Comprehensive test coverage for all features

Usage Example:

// Text generation
$response = Prism::text()
    ->using(Provider::Z, 'z-model')
    ->withPrompt('Hello, world!')
    ->asText();

// Structured output
$response = Prism::structured()
    ->using(Provider::Z, 'z-model')
    ->with(schema: ['name' => 'string'], prompt: 'Extract a name')
    ->asStructured();

@kevariable kevariable marked this pull request as ready for review December 22, 2025 18:22
@kevariable
Copy link
Author

This is my first time contribute to Open Source, very happy to contribute this!

Haven't test yet about Stream, but looking forward to update in meaning time.

Tested with Structured with Tools, Text, Text with Tools, Tools built-in

- Add Z provider for text and structured completions
- Implement message mapping for Z AI API format
- Add JSON encoder for structured output schemas
- Register Z provider in PrismManager
- Include comprehensive test coverage for the provider
- Add Z provider to Provider enum
- Simplify Z provider by removing custom exception handling
- Fix API endpoint path in Structured handler (remove leading slash)
- Change Z class from final to extensible
- Make encoder methods protected for better extensibility
- Make client method protected for better extensibility
- Update tests to use Prism facade instead of direct provider instantiation
- Change test functions from test() to it() for better Pest compliance
- Update test fixtures to use consistent mock data
- Remove HTTP mocking in favor of FixtureResponse
- Simplify test structure and improve maintainability
- Update import paths for test doubles
- Add beforeEach configuration for API key setup
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