> ## Documentation Index
> Fetch the complete documentation index at: https://docs.responsivevoice.org/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP SDK

Official PHP client for the ResponsiveVoice Text-to-Speech API. Source: [`sdk-php`](https://github.com/responsivevoice/sdk-php).

## Installation

```bash
composer require responsivevoice/sdk
```

## Quick Start

```php
<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;
use ResponsiveVoice\Sdk\Api\SynthesisApi;
use ResponsiveVoice\Sdk\Api\VoicesApi;
use ResponsiveVoice\Sdk\Configuration;

$config = (new Configuration())
    ->setApiKey('X-API-Key', getenv('RESPONSIVEVOICE_API_KEY'))
    ->setApiKey('X-API-Secret', getenv('RESPONSIVEVOICE_API_SECRET'));

// Synthesize speech — returns raw MP3 bytes.
$audio = (new SynthesisApi(new Client(), $config))
    ->v2TextSynthesizeGet('Hello world', 'UK English Female');
file_put_contents('hello.mp3', $audio);

// List voices, optionally filtered by language.
$voices = (new VoicesApi(new Client(), $config))->v2VoicesGet()->getVoices();
```

## Authentication

Server-side callers send an API key + secret pair as `X-API-Key` + `X-API-Secret` headers. Get both from your website's settings in the [ResponsiveVoice dashboard](https://app.responsivevoice.org) ([sign up](https://responsivevoice.org/register)): the **API key** from the "Your site code" snippet, and the **API secret** under "Server-to-server API secrets" (shown only once, revocable). PHP runs server-side, which is exactly where the secret belongs — browser apps use [`@responsivevoice/core`](/getting-started/quick-start/), which authenticates by origin and needs no secret.

## Reference Documentation

- [Package README on GitHub](https://github.com/responsivevoice/sdk-php#readme) — full walkthrough, error handling, and the voice/synthesis surface
- [Runnable examples](https://github.com/responsivevoice/sdk-php/tree/main/examples) — standalone PHP and a Laravel integration
- [REST API reference](/rest-api/) — the underlying HTTP endpoints, for any language

> [!TIP]
> Requires PHP 8.2+. For help: [support@responsivevoice.org](mailto:support@responsivevoice.org).
