# Seed TTS

Call the Seed TTS unidirectional streaming endpoint through Kaien API.

Seed TTS is a unidirectional streaming HTTP endpoint. Request fields, voices, and audio parameters follow the compatible provider format; authentication and billing follow Kaien API rules.

## Endpoint

```http
POST https://kaienapi.com/api/v3/tts/unidirectional
```

Use `Authorization: Bearer` with your Kaien API key. Do not send the provider's `X-Api-Key` header.

## Minimal request

```bash
curl https://kaienapi.com/api/v3/tts/unidirectional \\
  -H "Authorization: Bearer <YOUR_API_KEY>" \\
  -H "Content-Type: application/json" \\
  -H "X-Api-Resource-Id: seed-tts-2.0" \\
  -H "X-Api-Request-Id: $(uuidgen)" \\
  -d '{
    "req_params": {
      "text": "This is a short speech synthesis test.",
      "model": "seed-tts-2.0-standard",
      "speaker": "zh_female_mizai_uranus_bigtts",
      "audio_params": {
        "format": "mp3",
        "sample_rate": 24000,
        "bit_rate": 64000
      }
    }
  }'
```

Available resource IDs include `seed-tts-2.0` and `seed-icl-2.0` when the account has the corresponding capability. Confirm access with the model list and account configuration.

## Reading the stream

The endpoint returns multiple JSON objects through HTTP chunked transfer. Each object's `data` field contains base64 audio. Decode the chunks in order and concatenate the bytes before writing the final audio file.

A successful stream usually starts with `code: 0` and ends with `20000000`. Treat other non-zero codes as errors and preserve the complete response for diagnosis.

## Integration notes

- A single request accepts at most 200 Unicode characters, including punctuation and spaces.
- Split longer text into sentences and send multiple requests.
- Keep the API key on your server.
- Use the provider's voice list for valid `speaker` IDs.
- Usage is billed per request; preserve the model or resource ID in your request log.
