Text-to-Speech API Endpoint using OpenAI - n8n Workflow

Create a seamless, real-time Text-to-Speech API endpoint using n8n. This n8n workflow utilizes a webhook n8n trigger to send text to the OpenAI n8n node, returning binary audio instantly.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers needing a serverless, instant TTS API endpoint for their applications.

  • Users looking for advanced examples of OpenAI integration within n8n.

  • n8n specialists interested in creating instantaneous, binary response APIs using n8n templates.

  • Teams seeking efficient n8n templates for robust AI audio generation tasks.

Overview

This powerful n8n workflow demonstrates how to build a highly responsive Text-to-Speech service. By utilizing the Webhook n8n trigger, the automation accepts text data via a simple POST request. It instantly passes this text to the OpenAI n8n node, which uses the TTS model (configured here to use the fable voice) to generate an audio file. Finally, the n8n workflow responds directly with the binary audio data, making it suitable for direct integration into applications or microservices that require on-demand audio content. This specific n8n template saves time by offering a ready-to-use solution for audio generation tasks, leveraging the speed and quality of the OpenAI API and the reliability of an n8n endpoint.

How it Works


  1. The process begins with the Webhook n8n trigger, configured to listen for external POST requests at the /generateaudio path.

  2. Upon receiving a request, the n8n node extracts the required text from the payload body, specifically accessing the texttoconvert field ({{ $json.body.textto_convert }}).

  3. This extracted text is immediately sent to the OpenAI n8n node, which is configured for the "Audio" resource (Text-to-Speech). It uses a specified voice, such as fable, to generate the corresponding audio file.

  4. The generated audio is returned as binary data by the OpenAI n8n node.

  5. The final n8n node, Respond to Webhook, is strategically configured to return the binary output directly to the original requesting client, completing the seamless, real-time Text-to-Speech API call managed entirely by this n8n workflow.

Installation Guide

To deploy this n8n workflow and create your own Text-to-Speech API endpoint, follow these steps:


  1. Import the n8n Workflow: Import this provided JSON code into your n8n instance.

  2. Setup OpenAI Credentials: Click on the OpenAI n8n node. You must set up a credential connection using a valid OpenAI API key. Ensure your key has access to the Text-to-Speech API endpoints.

  3. Identify Webhook URL: Note the unique Webhook URL generated by the Webhook n8n trigger. This URL, typically ending in /generateaudio, is your new API endpoint.

  4. Activation: Save and activate the n8n workflow using the toggle in the top-right corner. The production URL will only respond once the workflow is active.

  5. Testing: You can now test the endpoint by sending a POST request with a JSON body like {"textto_convert": "Your message here."} to the webhook URL. The endpoint will return the audio data immediately, thanks to this robust n8n template.

Node Details

Webhook (n8n trigger): Function: Initiates the n8n workflow upon receiving an external POST request. Key Configuration: HTTP Method set to POST, Path set to generateaudio, and Response Mode set to responseNode to delay the final response until the audio is processed.
OpenAI (n8n node): Function: Executes the core Text-to-Speech conversion using the OpenAI API. Key Configuration: Resource set to 'audio', Input dynamically mapped to extract the text from the webhook payload (={{ $json.body.text
to_convert }}), and Voice set to 'fable'.


  • Respond to Webhook (n8n node): Function: Sends the generated audio file back to the original caller immediately. Key Configuration: Respond With set to binary to correctly handle the audio data output generated by the preceding OpenAI n8n node.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

Featured*