Skip to content

Comments

feat: Add ModelsLab provider for image generation#918

Open
adhikjoshi wants to merge 1 commit intoprism-php:mainfrom
adhikjoshi:add-modelslab-provider
Open

feat: Add ModelsLab provider for image generation#918
adhikjoshi wants to merge 1 commit intoprism-php:mainfrom
adhikjoshi:add-modelslab-provider

Conversation

@adhikjoshi
Copy link

Summary

Adds ModelsLab as a new image generation provider in Prism — a unified AI interface for Laravel.

What this PR adds

Provider class (src/Providers/ModelsLab/ModelsLab.php)

  • Implements the images() method following the Provider interface
  • Uses the standard Prism HTTP client pattern

Image handler (src/Providers/ModelsLab/Handlers/Images.php)

  • Handles text-to-image generation via ModelsLab REST API
  • Supports: Flux, SDXL, Realistic Vision, DreamShaper, Anything, and community models
  • API key in request body (ModelsLab uses "key": "api_key", not Bearer token)

Configuration (config/prism.php)

'modelslab' => [
    'api_key' => env('MODELSLAB_API_KEY', ''),
    => env('MODELSLAB_URL', 'https:// 'url'modelslab.com/api/v6'),
],

Usage

use Prism\Prism\Facades\Prism;

// Using the facade
\$image = Prism::images()
    ->using('modelslab', [api_key => 'your-key'])
    ->generate('A sunset over mountains in watercolor style');

// Or via config
// Set MODELSLAB_API_KEY in .env, then:
\$image = Prism::images()
    ->using('modelslab')
    ->generate('A sunset over mountains');

Supported provider options

  • width (default: 1024)
  • height (default: 1024)
  • samples (default: 1)
  • num_inference_steps (default: 30)
  • guidance_scale (default: 7.5)
  • negative_prompt
  • seed
  • safety_checker (default: "no")

API Reference

Adds ModelsLab as a new provider for text-to-image generation in Prism.

Changes:
- src/Enums/Provider.php: Add ModelsLab case
- src/Providers/ModelsLab/ModelsLab.php: Provider class with images() method
- src/Providers/ModelsLab/Handlers/Images.php: Image generation handler
- src/PrismManager.php: Add createModelslabProvider factory method
- config/prism.php: Add modelslab config with MODELSLAB_API_KEY

Supports Flux, SDXL, and community models via ModelsLab REST API.
API key goes in request body (not Bearer token).

Usage:
  Prism::images()
    ->using('modelslab', [api_key => 'your-key'])
    ->generate('A sunset over mountains')

API docs: https://docs.modelslab.com/image-generation/overview
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