Skip to main content
Method: $client->createSpeech(...)

Example

<?php

require 'vendor/autoload.php';

use Phaseo\Sdk\Phaseo;

$client = new Phaseo(getenv('PHASEO_API_KEY'));
$audioFile = $client->createSpeech([
    'model' => 'openai/gpt-4o-mini-tts',
    'input' => 'Hello world',
    'voice' => 'alloy',
    'format' => 'mp3'
]);
file_put_contents('output.mp3', $audioFile->fread($audioFile->getSize()));

Key parameters

  • model (required): TTS-capable model id.
  • input (required): Text to synthesize.
  • voice: Voice preset (model-dependent, e.g., alloy).
  • format: mp3, wav, flac, etc.
  • speed: Playback speed multiplier (typically 0.25–4).

Returns

Audio binary (\SplFileObject)
Last modified on July 9, 2026