---
title: "Convert Text to Audio"
method: POST
path: "/text-to-audio"
tags: ["Audio"]
---

# Convert Text to Audio

`POST /text-to-audio`

**Available for**: Chatflow, Workflow, Agent, Chatbot, Legacy Agent, Text Generator apps.

Converts text to speech audio. Pass `text` to synthesize arbitrary text, or `message_id` to voice an existing message's answer.

## Request body

- TextToAudioRequest — Request body for text-to-audio conversion. Provide either `message_id` or `text`.
  - `message_id` string, uuid — ID of the message whose answer to voice. Takes priority over `text` when both are provided. Get message IDs from [List Conversation Messages](/en/api-reference/conversations/list-conversation-messages).
  - `text` string — Text to synthesize into speech.
  - `user` string — End-user identifier, defined by your app and unique within it. See [End User Identity](/en/api-reference/guides/end-user-identity).
  - `voice` string — Voice to use for text-to-speech. Available voices depend on the TTS provider configured for this app. Use the `voice` value from [Get App Parameters](/en/api-reference/applications/get-app-parameters) → `text_to_speech.voice` for the default.
  - `streaming` boolean — Accepted for backward compatibility but has no effect. Whether the audio is streamed is determined by the configured TTS provider's output, not by this field.

## Response `200`

Returns the generated audio. The `Content-Type` header reflects the provider's audio container, verified from the response bytes when recognizable.

The body can be AAC, FLAC, MP4, MP3, Ogg, WAV, or WebM. Output that cannot be recognized is labeled with the provider's declared type, or `audio/mpeg` when none is declared.

Streamed provider output is delivered with chunked transfer encoding; the request `streaming` field does not control this.

## Other responses

- `400` — - `app_unavailable` : The app is unavailable or misconfigured. - `invalid_param` : Text-to-speech is not enabled, `text` is missing, or no voice is available. - `provider_not_initialize` : No valid model provider credentials are configured. - `provider_quota_exceeded` : The model provider quota is exhausted. - `model_currently_not_support` : The current model does not support this operation. - `completion_request_error` : The text-to-speech request failed.
- `500` — `internal_server_error` : Internal server error.

## Changes

- **2026-08-25** `f7ff0fd62699` — 6 info
  - added the media type `audio/aac` for the response with the status `200`
  - added the media type `audio/flac` for the response with the status `200`
  - added the media type `audio/mp4` for the response with the status `200`
  - added the media type `audio/ogg` for the response with the status `200`
  - …2 more

[Change history](https://skmtc.dev/langgenius/apis/dify-service-api/changes/text-to-audio/post.md)

---

[API](https://skmtc.dev/langgenius/apis/dify-service-api.md) · [All operations](https://skmtc.dev/langgenius/apis/dify-service-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/langgenius/dify-service-api/revisions/9c8c06aed889/schema)
