Skip to content

Allow external Prism providers in PrismGateway#284

Open
meirdick wants to merge 1 commit intolaravel:0.xfrom
meirdick:feat/extensible-prism-providers
Open

Allow external Prism providers in PrismGateway#284
meirdick wants to merge 1 commit intolaravel:0.xfrom
meirdick:feat/extensible-prism-providers

Conversation

@meirdick
Copy link
Contributor

Summary

  • toPrismProvider() now returns the driver name as a string for unrecognized drivers instead of throwing InvalidArgumentException
  • Return type changed from PrismProvider to PrismProvider|string (matches what Prism::using() already accepts)
  • All existing built-in drivers continue to map to their PrismProvider enum values — zero behavior change for current users

Problem

External Prism providers registered via PrismManager::extend() — like prism-php/bedrock (100k+ Packagist downloads) — cannot be used through the agent() system because toPrismProvider() throws for any driver not in its hardcoded match.

The Prism layer already supports this: Prism::using() accepts string|ProviderEnum, and PrismManager::resolve() checks customCreators first. The gap is only in the Laravel AI gateway layer.

Fix

- default => throw new InvalidArgumentException('Gateway does not support provider ['.$provider.'].'),
+ default => $provider->driver(),

The string driver name flows through to Prism::using()PrismManager::resolve() which resolves custom providers via extend(), or throws its own InvalidArgumentException("Provider [{$name}] is not supported.") if truly unknown.

Test plan

  • All 11 built-in drivers still return correct PrismProvider enum values
  • Unknown drivers (e.g. 'bedrock', 'workers-ai') return the driver name as a string
  • All 21 existing unit tests pass (91 assertions)

Closes #283

The toPrismProvider() method previously threw an InvalidArgumentException
for any driver not in its hardcoded match statement. This prevented
external Prism providers registered via PrismManager::extend() — such as
prism-php/bedrock or custom Workers AI providers — from being used
through the agent() system.

Since Prism's using() method already accepts string|ProviderEnum and
PrismManager::resolve() already handles custom providers via extend(),
the fix is to return the driver name as a string for unrecognized
drivers instead of throwing. Prism's own resolution handles the error
case if the provider is truly unregistered.

Closes laravel#283
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.

Support external Prism providers in PrismGateway (bedrock, workers-ai, etc.)

1 participant