© 2026 Hedgehog Software, LLC
FileUpload::make('ai_image') ->image(), Actions::make([ Action::make('aiImage') ->icon('heroicon-o-camera') ->form([ TextInput::make('prompt') ->label(__('input.prompt')), ]) ->action(function (array $arguments, Set $set, array $data) { $prompt = $data['prompt']; OpenAIController::getImage($prompt); }) ]),
public static function getImage(String $prompt) { $apiKey = env('OPENAI_KEY'); $client = OpenAI::client($apiKey); $aiResponse = $client->images()->create([ 'model' => 'dall-e-3', 'prompt' => $prompt, 'n' => 1, 'size' => '1024x1024', 'response_format' => 'url', ]); $client = new Client(); $url = $aiResponse->data[0]->url; $filename = uuid_create().'.jpg'; $imageResponse = $client->request('GET', $url); Storage::disk('public')->put($filename, $imageResponse->getBody()->getContents()); }