How to Integrate the TTS API with OpenAI SDK?

By WordHush editorial team · Updated 2026-11-18

This page explains how to use the OpenAI Python and JavaScript SDKs with WordHush’s TTS API. By changing the base URL, you can generate audio files using the same methods you already know. This approach saves time for indie developers and no-code builders who want straightforward integration without learning a new library.

You will get concrete code examples for making your first request, configuring voices and speeds, and handling responses. The guide covers practical steps for setting up authentication, managing character limits, and debugging common issues. It is designed for users who prefer using established SDK tools for reliable, clear-text-to-audio conversion.

How to Integrate the TTS API with OpenAI SDK?

Frequently asked questions

Can I use the OpenAI SDK with this API?

Yes. The request shape matches the OpenAI speech endpoint, so official OpenAI SDKs work by changing the base_url to https://api.ktv88th.com/v1 and using your WordHush key.

What is the base URL for the API?

The API base URL is https://api.ktv88th.com/v1. Configure your SDK client to use this URL instead of the default OpenAI endpoint to route requests to our service.

How do I set the API key in the SDK?

Set the Authorization header to Bearer tts-... using your unique key. You can find this key on the /get-api-key/ page after signing in with Google or email.

Which programming languages are supported?

Any language supported by the official OpenAI SDK works. This includes Python, JavaScript, Go, Ruby, Java, C#, and PHP, as long as you can configure a custom base URL.

How do I handle audio responses?

The API returns the audio file directly in the response body. Save this binary data to a file with the requested format, such as mp3, wav, opus, flac, or pcm.

What happens if I exceed rate limits?

You are limited to 60 requests per minute per key. If you exceed this, requests may queue or fail. New accounts start with 10 requests per minute until the first top-up.

Can I use custom voices?

No. The API offers eight preset voices (aria, nova, luna, sage, felix, milo, atlas, orion). There is no custom voice cloning or uploading your own voice feature available.

How do I detect the language automatically?

If you do not set the language field, the API guesses it from the script. Latin text defaults to English. For other Latin-script languages, explicitly set the language ISO code.

Is the API synchronous or asynchronous?

The API is synchronous. You send a POST request and wait for the audio file response. It does not support streaming or WebSocket connections for real-time partial audio.

How do I calculate costs in my code?

Cost is $0.01 per 1,000 characters. Count all characters, including spaces and punctuation, in your input text. Multiply the character count by 0.00001 to estimate the charge.

Can I stream the audio?

No. The API returns the complete audio file in the response body. There is no streaming endpoint, so you must wait for the full synthesis to complete before receiving data.

Do I need to install extra libraries?

You can use the official OpenAI SDK or plain HTTP. No additional WordHush-specific libraries are required, as the API follows the standard OpenAI request structure for speech generation.

How do I test my integration?

Use the ready curl example on the /get-api-key/ page. Send a POST request with your key and a short text input to verify you receive an audio file successfully.

Where can I find code examples?

Ready code examples are available on the /get-api-key/ page. You can also refer to the official OpenAI SDK documentation, adjusting only the base_url and authentication header for our API.

Why Use OpenAI SDK

Sound wave illustration for: Why Use OpenAI SDK

Using the OpenAI SDK simplifies integration by leveraging a familiar interface you likely already know. This allows indie developers and no-code builders to connect WordHush’s text-to-speech API with minimal code changes, keeping your workflow consistent.

The API supports 23 languages, ensuring broad coverage for global projects. By adapting the base URL, you gain access to all available voices and formats without learning a new library syntax.

Migration is straightforward. Since the request shape mirrors the official OpenAI speech endpoint, you only need to update the base_url and provide your API key. This reduces setup time and lets you focus on building features rather than parsing new response structures.

Familiar interface

The OpenAI SDK provides a consistent structure for API calls. You use standard methods like Audio.speech.create, passing text and voice parameters in a format that feels native to Python or JavaScript developers.

This familiarity reduces the learning curve. Your existing error-handling logic and request patterns remain largely unchanged, allowing for quick integration into current projects without extensive refactoring.

  • Standard HTTP request structure
  • Consistent JSON body format
  • Predictable response handling

Wide language support

With 23 supported languages, you can generate audio in multiple languages using the same code structure. The API guesses the language from the script if not specified, but you can explicitly set it for better accuracy.

This flexibility means you don’t need separate integrations for different linguistic needs. A single SDK instance handles all supported languages, from English and Spanish to Arabic and Japanese.

  • 23 languages supported
  • Automatic language detection
  • Explicit language code override

Easy migration

Migrating to WordHush requires only two changes: updating the base_url to https://api.ktv88th.com/v1 and swapping your API key. The rest of the SDK calls remain identical.

This ease of migration makes it ideal for no-code users who can use simple HTTP clients or low-code connectors. You avoid rewriting business logic, ensuring a smooth transition from existing TTS providers.

  • Single base URL change
  • Drop-in API key replacement
  • No code logic changes needed

Setting Up the Base URL

Sound wave illustration for: Setting Up the Base URL

To integrate with the OpenAI SDK, you must redirect the client to our API domain. The base URL is https://api.ktv88th.com/v1. This allows you to use the same SDK methods you already know, pointing to our endpoint for speech synthesis.

Endpoint structure

Use the standard /v1/audio/speech endpoint for generating audio. The SDK handles the JSON structure automatically when you call the speech method.

Domain configuration

Set the base URL in your SDK client to https://api.ktv88th.com/v1. This ensures all requests go to the correct service without modifying the endpoint path.

Authentication setup

Pass your API key via the Authorization: Bearer tts-... header. The SDK injects this header automatically when you provide your key during initialization.

Making the First Request

Sound wave illustration for: Making the First Request

Sending your first request is straightforward. The API accepts JSON payloads via a POST request to the speech endpoint. You simply provide the text, model, and voice parameters to receive an audio file.

Python example

Install the OpenAI library and set the base URL to your API domain. Use the audio.speech.create method with your specific key and parameters.

  • Set base_url to https://api.ktv88th.com/v1
  • Use model="tts-1" or tts-1-hd
  • Pass input, voice, and response_format

JavaScript example

Initialize the OpenAI client with your custom base URL and API key. Call the speech method to generate audio and save the response.

  • Configure apiKey and baseURL
  • Request MP3 or WAV format
  • Handle the binary audio response

cURL example

Use a standard POST command with your bearer token. The request body contains your text and voice selection details.

  • Header: Authorization: Bearer tts-...
  • Body: JSON with model, input, voice
  • Output: Raw audio binary data

Configuring Parameters

Sound wave illustration for: Configuring Parameters

Configuring parameters allows you to tailor the audio output to your specific needs. The API accepts standard fields that control voice identity, file format, and playback speed, ensuring the generated speech matches your project’s requirements.

Voice selection

Choose from eight distinct voice presets, such as Aria for narration or Felix for promos. Each voice is selected by its name string in the voice field.

  • Aria: warm, clear narrator
  • Nova: bright, upbeat
  • Luna: soft, storytelling
  • Sage: calm, instructional
  • Felix: energetic, promo
  • Milo: friendly, conversational

Audio format

Specify the output format using the response_format field. Available options include mp3, wav, opus, flac, and pcm. MP3 is recommended for general use due to its balance of quality and file size.

Speed adjustment

Adjust the speech rate between 0.25 and 4.0 using the speed parameter. A value of 1.0 represents normal speed. Faster speeds may reduce audio quality, while slower speeds enhance clarity for complex texts.

Handling Responses

Sound wave illustration for: Handling Responses

The API returns the generated audio file directly in the response body, allowing you to save it as an MP3, WAV, or other supported format. For long texts, you must split the text into parts of up to 4096 characters and join the audio files yourself.

Audio file download

Simply write the response body to a file on your local machine or server. The SDK handles the binary data transfer seamlessly, ensuring the audio file is intact and ready for playback or further processing.

Error handling

If synthesis fails, the API returns a clear error message and the charge is returned in full. Always check for errors before attempting to save the file, as a failed request will not contain valid audio data.

  • Failed requests are free

Status codes

Standard HTTP status codes indicate the result of your request. A 200 OK means the audio is ready, while 4xx or 5xx codes indicate issues with your key, input, or server load.

Common Issues

Sound wave illustration for: Common Issues

Integration problems usually stem from simple boundary conditions. Understanding limits helps prevent failed requests and ensures smooth audio generation.

Common issues involve hitting rate caps, exceeding text length, or misidentifying the input language. These are easily resolved with proper configuration.

Rate limits

You are allowed 60 requests per minute per key. If you exceed this, requests queue or fail. New accounts start with 10 requests per minute until the first top-up.

Use a simple queue in your code to handle bursts gracefully.

  • 60 requests/minute after top-up
  • 10 requests/minute initially
  • Requests queue under load

Character limits

Each request supports up to 4096 characters. Longer texts must be split into parts and joined afterward.

Count spaces and punctuation as characters to stay within limits.

  • Max 4096 characters per request
  • Split and join for longer texts
  • Spaces count as characters

Language detection

If the language field is unset, the API guesses from the script. Latin text defaults to English.

Explicitly set the language parameter for non-English Latin-script text to avoid mispronunciation.

  • Defaults to English for Latin script
  • Set language for accuracy
  • 23 supported languages

Best Practices

Sound wave illustration for: Best Practices

Integrate exponential backoff for failed requests to handle the processing queue without wasting API calls. Requests are processed one after another, so under load a request may wait in a queue.

Store generated audio files locally or in your object storage to avoid re-synthesizing identical text. This reduces character consumption and latency for repeated content like FAQs or menu descriptions.

Error retries

Use exponential backoff when the API returns a 5xx error or a queue timeout. Start with a short delay and increase it gradually to prevent overwhelming the endpoint during peak load.

Do not retry failed requests that return a 4xx error, as these indicate invalid input or authentication issues that will persist without correction.

  • Start with a 1-second delay
  • Double delay on each retry
  • Max out at 10 seconds

Caching results

Hash the input text, voice, and speed parameters to create a cache key. Store the resulting audio file to skip re-generation for static content.

This approach lowers costs since you only pay for new, unique text segments.

Monitoring usage

Track character counts per request to stay within the 4096-character limit per call. Monitor your balance regularly, especially during the free trial period.

Set up alerts for low balance to ensure seamless top-ups via USDT on the TRON network before synthesis stops.

Best Practices

Voice and Language Options

Sound wave illustration for: Voice and Language Options

Our API supports 23 languages, allowing any of our eight voices to speak any supported language. This flexibility lets you maintain a consistent audio style across diverse content without needing different voice models for each region.

If you do not specify a language, the system guesses it from the text script, defaulting to English for Latin characters. For non-English Latin text, explicitly setting the language ensures accurate pronunciation and natural flow.

Available voices

Choose from eight distinct voice presets, including female voices like Aria and Nova, and male voices like Felix and Atlas. Each voice is based on licensed recordings from LibriTTS-R, ensuring high-quality, natural-sounding speech for your projects.

  • Aria (warm narrator)
  • Nova (bright, upbeat)
  • Luna (soft storytelling)
  • Sage (calm, instructional)
  • Felix (energetic promo)
  • Milo (friendly conversational)

Supported languages

Any voice can speak any of the 23 supported languages: Arabic, Chinese, Danish, Dutch, English, Finnish, French, German, Greek, Hebrew, Hindi, Italian, Japanese, Korean, Malay, Norwegian, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, Turkish.

Custom language code

You can pass an optional ISO language code to override automatic detection. This is particularly useful for Latin-script text that isn't English, ensuring the engine applies the correct phonetic rules rather than defaulting to English pronunciation.

Pricing in Code

Sound wave illustration for: Pricing in Code

To keep costs predictable, calculate the character count of your input text before sending the request. Since the rate is $0.01 per 1,000 characters, you can estimate the price by dividing the total character count by 100,000 and multiplying by the dollar amount.

Cost calculation

Include spaces and punctuation in your character count, as they are billed equally. For example, a 4,000-character request costs $0.04. Failed requests are free, so you only pay for successful synthesis, making it safe to test with longer texts.

  • Rate: $10 per 1 million characters
  • Spaces and punctuation count as characters
  • Failed requests are free

Trial usage

Accounts created via Google sign-in receive $0.50 in trial credit, valid for 7 days. This covers approximately 50,000 characters, allowing you to test the API without immediate payment. Email-based accounts start with zero balance.

  • $0.50 credit for Google sign-ups
  • Approximately 50,000 characters
  • Valid for 7 days

Top-up integration

To add funds, send USDT on the TRON network (TRC-20) with a minimum of $5. Credits are added automatically within minutes. There are no subscriptions or invoices, and your balance never expires, allowing you to top up only when needed.

  • Payment via USDT (TRC-20)
  • Minimum top-up: $5
  • Credits added automatically within minutes

Debugging Tips

Sound wave illustration for: Debugging Tips

Debugging is straightforward when you verify your setup step-by-step. Start by ensuring your API key is correctly formatted and active, then confirm that your input text does not exceed the 4,096-character limit per request.

Logging requests

Log the full request payload and response headers to identify silent failures. Since requests are processed sequentially, a high volume may cause queuing delays, so check the response time to distinguish between network latency and API processing time.

  • Log request timestamps and character counts
  • Monitor response duration for queue indicators

Checking keys

Verify that your Authorization: Bearer header matches the key shown on your dashboard. If you issued a new key, the old one stops immediately, so ensure you are not using a stale token from a previous session.

  • Ensure key matches dashboard exactly
  • Replace old key immediately upon new issuance

Validating inputs

Confirm that your text input is under 4,096 characters. If the language parameter is omitted for non-English Latin text, the system defaults to English, which may produce incorrect pronunciation. Always set the language code explicitly for clarity.

  • Check character count against 4,096 limit
  • Explicitly set language for non-English text

Next Steps

Sound wave illustration for: Next Steps

As your application grows, monitor your character consumption to ensure you stay within the 60 requests-per-minute rate limit. If you exceed this, requests may queue, so consider implementing simple retry logic with exponential backoff for smoother scaling.

Since the API returns static audio files, you can cache frequent phrases or sound effects locally to reduce API calls and costs. This is particularly effective for no-code builders using repetitive prompts or menu navigation sounds.

Scaling usage

Monitor your character consumption to ensure you stay within the 60 requests-per-minute rate limit. If you exceed this, requests may queue, so consider implementing simple retry logic with exponential backoff for smoother scaling.

Since the API returns static audio files, you can cache frequent phrases or sound effects locally to reduce API calls and costs. This is particularly effective for no-code builders using repetitive prompts or menu navigation sounds.

  • Implement exponential backoff for rate limit retries
  • Cache frequent audio responses locally
  • Split long texts into 4096-character chunks before sending

Adding features

You can easily add voice selection and speed adjustments to your existing workflow without changing the core integration. Use the /v1/voices endpoint to let users choose from the eight available presets or set a default voice in your code.

Consider adding language support by detecting the user's input language and passing the ISO code explicitly. This avoids default English detection for Latin-script non-English text, ensuring accurate pronunciation for your global audience.

  • Use /v1/voices to list available options
  • Set explicit language codes for accuracy
  • Adjust speed between 0.25 and 4.0

Community support

For questions or feedback, reach out via email. We do not offer live chat or phone support, so please include your API key and a description of your use case for faster assistance.

You can also check the documentation for ready-to-use curl examples and integration guides. While we do not have a dedicated forum, email remains the best channel for technical inquiries.

Support and Contact

Sound wave illustration for: Support and Contact

WordHush provides support exclusively via email. We do not offer phone lines, live chat, or on-site assistance. Our team reviews all inquiries and responds as quickly as possible.

For immediate answers, refer to the documentation or check the FAQ. This ensures you get precise, written instructions without waiting for a conversation to start.

Email support

Send your questions to . Include your API key (last 4 chars), the endpoint used, and any error logs. This helps us resolve issues faster.

We handle billing, technical, and general inquiries through this single channel. No tickets are created unless you request them.

Documentation links

The /docs/ page contains the complete reference for endpoints, parameters, and code examples. Use it to verify request shapes and response formats before contacting support.

Keep the documentation open while integrating to reduce back-and-forth questions.

  • /docs/
  • /pricing/
  • /get-api-key/

Feedback channel

Use the same email address to suggest features or report bugs. We read every message and prioritize requests that help indie developers and no-code builders.

Your feedback directly influences future updates to the API and voice options.

Listen to the 8 voices

Each sample below was generated by this API from the same sentence. The integration with IBM Cloud services allows for seamless deployment in enterprise environments.

Avatar of the voice aria
ariafemale
Avatar of the voice nova
novafemale
Avatar of the voice luna
lunafemale
Avatar of the voice sage
sagefemale
Avatar of the voice felix
felixmale
Avatar of the voice milo
milomale
Avatar of the voice atlas
atlasmale
Avatar of the voice orion
orionmale

23 languages

Any voice speaks any of these languages.

Sources and further reading

  1. Wikipedia
  2. Tether (USDT)
  3. Creative Commons Attribution 4.0
  4. FFmpeg documentation
  5. MDN: Web Speech API
  6. W3C WAI: making audio and video accessible
  7. LibriTTS-R paper (arXiv 2305.18802)
  8. ISO 639 language codes
  9. Node.js documentation
  10. openai-node on GitHub
  11. LibriVox public-domain audiobooks
  12. LibriTTS-R corpus (OpenSLR 141)

More on this site