{"id":31917586,"url":"https://github.com/rulilg/laravel-stable-diffusion","last_synced_at":"2025-10-13T20:44:33.696Z","repository":{"id":58875512,"uuid":"534184362","full_name":"RuliLG/Laravel-Stable-Diffusion","owner":"RuliLG","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-17T20:33:47.000Z","size":38,"stargazers_count":39,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-10T13:35:56.518Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RuliLG.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-08T11:40:15.000Z","updated_at":"2024-12-17T20:33:51.000Z","dependencies_parsed_at":"2024-07-20T12:21:40.467Z","dependency_job_id":"da9feec8-5128-4a88-bb9b-655379f269a9","html_url":"https://github.com/RuliLG/Laravel-Stable-Diffusion","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/RuliLG/Laravel-Stable-Diffusion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuliLG%2FLaravel-Stable-Diffusion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuliLG%2FLaravel-Stable-Diffusion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuliLG%2FLaravel-Stable-Diffusion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuliLG%2FLaravel-Stable-Diffusion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RuliLG","download_url":"https://codeload.github.com/RuliLG/Laravel-Stable-Diffusion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RuliLG%2FLaravel-Stable-Diffusion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016930,"owners_count":26085911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-13T20:44:21.202Z","updated_at":"2025-10-13T20:44:33.688Z","avatar_url":"https://github.com/RuliLG.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stable Diffusion integration with Replicate and Laravel\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/rulilg/laravel-stable-diffusion.svg?style=flat-square)](https://packagist.org/packages/rulilg/laravel-stable-diffusion)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/rulilg/laravel-stable-diffusion/Fix%20PHP%20code%20style%20issues?label=code%20style)](https://github.com/rulilg/laravel-stable-diffusion/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/rulilg/laravel-stable-diffusion.svg?style=flat-square)](https://packagist.org/packages/rulilg/laravel-stable-diffusion)\n\nLaravel wrapper around the Replicate API to use Stable Diffusion to generate text2img.\n\n- 🎨 Built-in prompt helper to create better images\n- 🚀 Store the results in your database\n- 🎇 Generate multiple images in the same API call\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require rulilg/laravel-stable-diffusion\n```\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --tag=\"stable-diffusion-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"stable-diffusion-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n    'url' =\u003e env('REPLICATE_URL', 'https://api.replicate.com/v1/predictions'),\n    'token' =\u003e env('REPLICATE_TOKEN'),\n    'version' =\u003e env('REPLICATE_STABLEDIFFUSION_VERSION', 'a9758cbfbd5f3c2094457d996681af52552901775aa2d6dd0b17fd15df959bef'),\n];\n\n```\n\nRegister in [Replicate](https://replicate.com/) and store your token in the `REPLICATE_TOKEN` .env variable.\n\nOptionally, you can publish the views using\n\n```bash\nphp artisan vendor:publish --tag=\"laravel-stable-diffusion-views\"\n```\n\n## Usage\n\nIt's important to understand that the image generation process is **async**. We need first to send a request to Replicate and, after a few seconds, we can fetch the results back.\n\nThis is the code we need to generate an image. This will return a `StableDiffusionResult` model.\n\n```php\nuse RuliLG\\StableDiffusion\\StableDiffusion;\nuse RuliLG\\StableDiffusion\\Prompt;\n\nStableDiffusion::make()\n    -\u003ewithPrompt(\n        Prompt::make()\n            -\u003ewith('a panda sitting on the streets of New York after a long day of walking')\n            -\u003ephotograph()\n            -\u003eresolution8k()\n            -\u003etrendingOnArtStation()\n            -\u003ehighlyDetailed()\n            -\u003edramaticLighting()\n            -\u003eoctaneRender()\n    )\n    -\u003egenerate(4);\n```\n\nAfter the `generate()` method is called, an API request to Replicate is sent so they can start processing the prompt. This will generate a record in our database with a `status=\"starting\"` value, and the ID returned by Replicate.\n\nTo retrieve the results back from Replicate, we need to run the following code:\n\n```php\nuse RuliLG\\StableDiffusion\\StableDiffusion;\n\n// we get the Replicate ID and fetch the results back.\n// This method will automatically update the record with the new information\n$freshResults = StableDiffusion::get($result-\u003ereplicate_id);\nif ($freshResults-\u003eis_successful) {\n    dd($freshResults-\u003eoutput); // List of URLs with the images\n}\n```\n\nIf the results were already fetched, then no API request will be made, so we can safely call this method every time.\n\n### The StableDiffusionResult model\n\nAfter a request to Replicate is made, a new record is inserted in your database with the following information:\n\nColumn | Description\n----- | -----\nreplicate_id | ID from Replicate, which we can use to retrieve the results back\nuser_prompt | Prompt passed to the `Prompt::make()-\u003ewith()` method\nfull_prompt | Prompt generated with all the modifiers\nurl | Internal URL to fetch the results back from Replicate\nstatus | Status. Can be one of: `starting`, `processing`, `succeeded`, `failed` or `cancelled`. This library doesn't support cancelling requests.\noutput | Array of URLs containing the images\nerror | Error description if needed (i.e. no NSFW content is allowed)\npredict_time | Time spent by Replicate processing your image, which you will be charged for\n\nAdditionally, the model has the following attributes to know the status of the prediction:\n\n- `$result-\u003eis_successful`\n- `$result-\u003eis_failed`\n- `$result-\u003eis_starting`\n- `$result-\u003eis_processing`\n\nAlso, as results have to be manually updated through the `StableDiffusion::get($id)` method, we can also fetch the results that are not in a finished status:\n\n```php\nuse RuliLG\\StableDiffusion\\Models\\StableDiffusionResult;\nuse RuliLG\\StableDiffusion\\StableDiffusion;\n\n$results = StableDiffusionResult::unfinished()-\u003eget();\nforeach ($results as $result) {\n    StableDiffusion::get($result-\u003ereplicate_id);\n}\n```\n\n## Generating prompts\n\nThere are several styles already built-in:\n\nMethod | Prompt modification\n---- | ----\n`realistic()` | {prompt}, realistic\n`hyperrealistic()` | {prompt}, hyperrealistic\n`conceptArt()` | {prompt}, concept art\n`abstractArt()` | {prompt}, abstract art\n`oilPainting()` | {prompt}, oil painting\n`watercolor()` | {prompt}, watercolor\n`acrylic()` | {prompt}, acrylic\n`pencilDrawing()` | {prompt}, pencil drawing\n`digitalPainting()` | {prompt}, digital painting\n`penDrawing()` | {prompt}, pen drawing\n`charcoalDrawing()` | {prompt}, charcoal drawing\n`byPicasso()` | {prompt}, by Pablo Picasso\n`byVanGogh()` | {prompt}, by Vincent Van Gogh\n`byRembrandt()` | {prompt}, by Rembrandt\n`byMunch()` | {prompt}, by Edvard Munch\n`byKlimt()` | {prompt}, by Paul Klimt\n`byKandinsky()` | {prompt}, by Jackson Pollock\n`byMonet()` | {prompt}, by Claude Monet\n`byDali()` | {prompt}, by Salvador Dali\n`byDegas()` | {prompt}, by Edgar Degas\n`byKahlo()` | {prompt}, by Frida Kahlo\n`byCezanne()` | {prompt}, by Pablo Cezanne\n`photograph()` | a photo of {prompt}\n`highlyDetailed()` | {prompt}, highly detailed\n`surrealism()` | {prompt}, surrealism\n`trendingOnArtStation()` | {prompt}, trending on art station\n`triadicColorScheme()` | {prompt}, triadic color scheme\n`smooth()` | {prompt}, smooth\n`sharpFocus()` | {prompt}, sharp focus\n`matte()` | {prompt}, matte\n`elegant()` | {prompt}, elegant\n`theMostBeautifulImageEverSeen()` | {prompt}, the most beautiful image ever seen\n`illustration()` | {prompt}, illustration\n`digitalPaint()` | {prompt}, digital paint\n`dark()` | {prompt}, dark\n`gloomy()` | {prompt}, gloomy\n`octaneRender()` | {prompt}, octane render\n`resolution8k()` | {prompt}, 8k\n`resolution4k()` | {prompt}, 4k\n`washedColors()` | {prompt}, washed colors\n`sharp()` | {prompt}, sharp\n`dramaticLighting()` | {prompt}, dramatic lighting\n`beautiful()` | {prompt}, beautiful\n`postProcessing()` | {prompt}, post processing\n`pictureOfTheDay()` | {prompt}, picture of the day\n`ambientLighting()` | {prompt}, ambient lighting\n`epicComposition()` | {prompt}, epic composition\n\nAdditionally, you can add custom styles with the following methods:\n\n- `as(string $canvas)`: to add a string at the beginning (i.e. \"a photograph of\")\n- `paintingStyle(string $style)`: to add a painting style (i.e. realistic, hiperrealistic, etc.)\n- `by(string $author)`: to instruct the system to paint it with the style of a certain author\n- `effect(string $effect)`: to add a finishing touch to the prompt. You can add as many as you want.\n\nTo learn more on how to build prompts for Stable Diffusion, please [enter this link](https://beta.dreamstudio.ai/prompt-guide).\n\n## Borah Digital Labs\n[Borah Digital Labs](https://borah.digital/) crafts web applications, open-source packages, and offers a team of full-stack solvers ready to tackle your next project. We have built a series of projects:\n\n- [CodeDocumentation](https://codedocumentation.app/): Automatic code documentation platform\n- [AutomaticDocs](https://automaticdocs.app/): One-time documentation for your projects\n- [Talkzy](https://talkzy.app/): A tool to summarize meetings\n- Compass: An agent-driven tool to help manage companies more efficiently\n- [Prompt Token Counter](https://prompttokencounter.com/): Simple tool to count tokens in prompts\n- [Sabor en la Oficina](https://saborenlaoficina.es/): Website + catering management platform\n\nWe like to use Laravel for most of our projects and we love to tackle big, complicated problems. Feel free to reach out and we can have a virtual coffee!\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frulilg%2Flaravel-stable-diffusion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frulilg%2Flaravel-stable-diffusion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frulilg%2Flaravel-stable-diffusion/lists"}