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

> ## Agent Instructions
> Phaseo Gateway base URL: https://api.phaseo.app/v1. Send `Authorization: Bearer $PHASEO_API_KEY` with every request.
> Model IDs look like `provider/model`, for example `openai/gpt-6-astra`. Do not guess IDs: list them with `GET /v1/models` or check https://phaseo.app/models. `phaseo/free` routes to an available free model and needs no wallet balance.
> For new text integrations prefer `POST /v1/responses`. `POST /v1/chat/completions` (OpenAI format) and `POST /v1/messages` (Anthropic format) suit existing code.
> The full API contract is https://phaseo.app/docs/openapi/v1/openapi.yaml. Official SDKs: `@phaseo/sdk` (TypeScript) and `phaseo` (Python), plus Go, C#, PHP, Ruby and Rust.
> Search these docs over MCP at https://phaseo.app/docs/mcp, and install Phaseo skills with `npx skills add https://phaseo.app/docs`. If a page is wrong or out of date, report it with the MCP `submit_feedback` tool.
> Manage Phaseo accounts with the `phaseo` CLI (`npm install -g @phaseo/cli`, then `phaseo login` or `phaseo login --device-code`), the `/v1` Management API or the MCP server at `https://mcp.phaseo.app/mcp?access=manage`. Do not send users to the dashboard for account tasks. A person is still needed for sign-up, approving a sign-in, paying the first top-up on the checkout link that `phaseo credits add` returns when no card is saved, confirming each saved-card top-up from the emailed link, and account security (password, MFA, passkeys). Create API keys with `phaseo keys create --name <name> --json`; never guess one. Credit top-ups need `phaseo login --scopes billing:write` first. Task map: https://phaseo.app/docs/v1/developers/manage-from-an-agent.md.

# TTS (synthèse vocale)

> Transformez du texte en audio avec POST /v1/audio/speech depuis n’importe quel SDK Phaseo.

Envoyez du texte à `POST /v1/audio/speech` et recevez l’audio parlé dans le format demandé. Les exemples utilisent un `client` créé comme dans [Installation](https://phaseo.app/docs/fr/v1/sdk-reference/client/installation.md).

```typescript TypeScript theme={null}
import { writeFile } from "node:fs/promises";

const audio = await client.generateSpeech({
  model: "openai/gpt-4o-mini-tts",
  input: "Hello world",
  voice: "alloy",
  format: "mp3",
});

await writeFile("hello.mp3", Buffer.from(await audio.arrayBuffer()));
```

```python Python theme={null}
audio = client.generate_speech({
    "model": "openai/gpt-4o-mini-tts",
    "input": "Hello world",
    "voice": "alloy",
    "format": "mp3",
})

with open("hello.mp3", "wb") as file:
    file.write(audio)
```

```go Go theme={null}
audio, err := client.CreateSpeech(context.Background(), map[string]interface{}{
  "model":  "openai/gpt-4o-mini-tts",
  "input":  "Hello world",
  "voice":  "alloy",
  "format": "mp3",
})
if err != nil {
  panic(err)
}
fmt.Printf("%T\n", audio) // vérifiez le type concret avant de l’écrire dans un fichier
```

```csharp C# theme={null}
var audio = await client.CreateSpeech(new Dictionary<string, object>
{
    ["model"] = "openai/gpt-4o-mini-tts",
    ["input"] = "Hello world",
    ["voice"] = "alloy",
    ["format"] = "mp3",
});
```

```php PHP theme={null}
$audio = $client->createSpeech([
    'model' => 'openai/gpt-4o-mini-tts',
    'input' => 'Hello world',
    'voice' => 'alloy',
    'format' => 'mp3',
]);
```

```ruby Ruby theme={null}
audio = client.generate_speech(
  model: 'openai/gpt-4o-mini-tts',
  input: 'Hello world',
  voice: 'alloy',
  format: 'mp3'
)
```

```java Java theme={null}
String body = """
{
  "model": "openai/gpt-4o-mini-tts",
  "input": "Hello world",
  "voice": "alloy",
  "format": "mp3"
}
""";

byte[] audio = client.rawClient().requestBytes("POST", "/audio/speech", null, null, body);
java.nio.file.Files.write(java.nio.file.Path.of("hello.mp3"), audio);
```

## Méthode par langage

| Langage | Méthode | Renvoie |
| - | - | - |
| TypeScript | `client.generateSpeech(request)` | Un `Blob` |
| Python | `client.generate_speech(request)` ou `client.audio.speech.create(request)` | `bytes` |
| Go | `client.CreateSpeech(ctx, req)` | `interface{}` ; vérifiez le type concret avant de l’écrire dans un fichier |
| C# | `client.CreateSpeech(request)` | `object?` ; vérifiez le type concret avant de l’écrire dans un fichier |
| PHP | `$client->createSpeech($request)` | L’audio ; vérifiez le type de la valeur avant de l’écrire dans un fichier |
| Ruby | `client.generate_speech(...)`, alias `create_speech` | L’audio ; vérifiez la classe de la valeur avant de l’écrire dans un fichier |
| Java | Pas de méthode de synthèse vocale. `client.rawClient().requestBytes("POST", "/audio/speech", ...)` envoie le corps JSON | `byte[]` |

Rust n’a pas de méthode de synthèse vocale, et son assistant `post()` analyse les réponses comme du JSON : il ne peut donc pas renvoyer d’audio.

## Paramètres

Les noms de champs sont ceux du corps JSON, dans tous les SDK. Utilisez `format` : l’API accepte aussi `response_format`, mais le type de requête TypeScript le rejette.

| Champ | Remarques |
| - | - |
| `model` | Obligatoire. Un identifiant de modèle de synthèse vocale. |
| `input` | Obligatoire. Le texte à prononcer. La plupart des fournisseurs acceptent jusqu’à 4 096 caractères ; les modèles ElevenLabs en autorisent de 5 000 à 40 000 selon le modèle. |
| `voice` | Un alias de voix normalisé entre fournisseurs (recommandé), la valeur de voix propre au fournisseur, ou un objet avec `id` ou `name`. Si la voix n’est pas valide pour le fournisseur choisi par le routage, l’API renvoie `400` avec `param: "voice"`. |
| `format` | `mp3`, `wav`, `ogg`, `aac`, `flac`, `opus` ou `pcm`. |
| `speed` | Vitesse de lecture, de `0.25` à `4`. |
| `instructions` | Indications de style, quand le modèle les prend en charge. |
| `config` | Réglages propres au fournisseur ; voir plus bas. |
| `provider` | Préférences de routage des fournisseurs. |

Le schéma complet se trouve dans la [référence de l’API Speech](https://phaseo.app/docs/fr/v1/api-reference/endpoint/audio-speech.md).

## Choisir la voix propre à un fournisseur

Passez la voix exacte du fournisseur sous `config`. Le même objet imbriqué fonctionne dans la table de requête de chaque SDK.

```typescript TypeScript theme={null}
// ElevenLabs : choisir un identifiant de voix exact
await client.generateSpeech({
  model: "eleven-labs/eleven-v3",
  input: "Hello from ElevenLabs",
  voice: "rachel",
  config: {
    elevenlabs: {
      voice_id: "21m00Tcm4TlvDq8ikWAM",
    },
  },
});

// Google : choisir un nom de voix exact
await client.generateSpeech({
  model: "google/gemini-3.1-flash-tts-preview",
  input: "Hello from Gemini",
  voice: "kore",
  config: {
    google: {
      voice_name: "Kore",
    },
  },
});
```

```python Python theme={null}
# ElevenLabs : choisir un identifiant de voix exact
client.generate_speech({
    "model": "eleven-labs/eleven-v3",
    "input": "Hello from ElevenLabs",
    "voice": "rachel",
    "config": {"elevenlabs": {"voice_id": "21m00Tcm4TlvDq8ikWAM"}},
})

# Google : choisir un nom de voix exact
client.generate_speech({
    "model": "google/gemini-3.1-flash-tts-preview",
    "input": "Hello from Gemini",
    "voice": "kore",
    "config": {"google": {"voice_name": "Kore"}},
})
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.