Search by

ez-php / ai-media

AU9500

Image generation, audio transcription, and text-to-speech via OpenAI/Gemini drivers over ez-php/http-client

Package info

github.com/ez-php/ai-media

pkg:composer/ez-php/ai-media

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.5.6 2026-09-30 18:37 UTC

This package is auto-updated.

Last update: 2026-10-04 02:27:17 UTC


README

Image generation, audio transcription, and text-to-speech via OpenAI/Gemini drivers over ez-php/http-client.

Installation

composer require ez-php/ai-media

Usage

use EzPhp\AiMedia\AiMedia;
use EzPhp\AiMedia\Request\ImageGenerationRequest;
use EzPhp\AiMedia\Request\SpeechRequest;
use EzPhp\AiMedia\Request\TranscriptionRequest;

// Image generation
$images = AiMedia::image(ImageGenerationRequest::make('a red bicycle on a beach'));
$url = $images->first()->url();

// Transcription
$audioBytes = file_get_contents('recording.mp3');
$transcript = AiMedia::transcribe(TranscriptionRequest::make($audioBytes, 'recording.mp3', 'audio/mpeg'));
echo $transcript->text();

// Text-to-speech
$speech = AiMedia::speech(SpeechRequest::make('Hello there.'));
file_put_contents('hello.mp3', $speech->audio());

Register EzPhp\AiMedia\AiMediaServiceProvider and configure config/ai_media.php:

return [
    'image_driver' => 'openai',
    'transcription_driver' => 'openai',
    'speech_driver' => 'openai',
    'openai' => ['api_key' => getenv('OPENAI_API_KEY') ?: null],
    'gemini' => ['api_key' => getenv('GEMINI_API_KEY') ?: null],
];

image_driver, transcription_driver, and speech_driver are selected independently (openai, gemini, or null — the default) since a provider offering one capability does not necessarily offer the others.

License

MIT