# 音声合成

**API:** Model API

**Endpoint:** `POST /api/v1/audio/speech`

**Tags:** Audio

Use model to select the speech generation model. Channel selection is unavailable for speech generation requests.

## Base URL

- `https://openapi.felo.ai` — 本番環境

## Authentication

- `FeloBearerAuth` (http bearer) — Felo APIキーを `Authorization: Bearer <key>` として送信します。
- `FeloApiKey` (apiKey in header `X-API-Key`) — Felo APIキーを `X-API-Key: <key>` として送信します。

## Request body

Required: **yes**

### application/json

Schema:

```json
{
  "type": "object",
  "required": [
    "model",
    "input"
  ],
  "additionalProperties": false,
  "properties": {
    "model": {
      "type": "string",
      "maxLength": 256
    },
    "input": {
      "type": "string",
      "minLength": 1,
      "maxLength": 4096
    },
    "voice": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "description": "Optional non-blank voice ID. The upstream model determines whether a voice is required and which IDs it accepts. Catalog voices are examples."
    },
    "response_format": {
      "type": "string",
      "enum": [
        "pcm",
        "mp3"
      ],
      "default": "pcm"
    },
    "speed": {
      "type": "number",
      "default": 1,
      "description": "Currently only 1 is supported."
    }
  }
}
```

## Responses

### 200 — 成功時は音声バイト列です。MP3 は `audio/mpeg`、生 PCM は `audio/pcm` で、WAV・JSON・SSEではありません。HTTP状態と転送完了を確認してから再生します。`--fail` はエラー本文の音声ファイルへの保存を防ぎます。切断時の不完全なファイルは破棄してください。生 PCM の再生パラメータはチャネルで確認し、推測しないでください。 STT は `input_audio_second` または token、TTS は `input_character` で課金されます。`speech_billing_unit` の `utf16_code_unit` と `unicode_code_point` では絵文字の数え方が異なります。仮押さえは上限ではなく、精算が非同期になる場合があります。証拠不足は無料を意味しません。両APIは `X-Felo-Channel` に対応し、選択チャネルへ一度だけ送信します。タイムアウト・切断後の自動再試行（SDKを含む）を無効にし、`X-Request-Id` と取得できた `X-Generation-Id` を保管してください。Console Playground は音声呼び出し未対応です。 `configured_rates` は固定済み単価と確認済み使用量、`upstream_cost` は確認済み上流コストと公開マークアップ・割引で精算します。

**audio/mpeg**

Schema: string, (binary)

```json
{
  "type": "string",
  "format": "binary"
}
```

**audio/pcm**

Schema: string, (binary)

```json
{
  "type": "string",
  "format": "binary"
}
```
