Skip to main content

How to use the plugin

The Runtime AI Chatbot Integrator provides two main functionalities: Text-to-Text chat and Text-to-Speech (TTS). Both features follow a similar workflow:

  1. Register your API provider token
  2. Configure feature-specific settings
  3. Send requests and process responses

Register Provider Token

Before sending any requests, register your API provider token using the RegisterProviderToken function.

Register Provider Token in Blueprint

Text-to-Text Chat Functionality

The plugin supports two chat request modes for each provider:

Non-Streaming Chat Requests

Retrieve the complete response in a single call.

Send OpenAI Chat Request

Streaming Chat Requests

Receive response chunks in real-time for a more dynamic interaction.

Send OpenAI Streaming Chat Request

Text-to-Speech (TTS) Functionality

Convert text to high-quality speech audio using leading TTS providers. The plugin returns raw audio data (TArray<uint8>) that needs to be processed to be usable in Unreal Engine. The recommended way to handle this is with the Runtime Audio Importer plugin (see here).

Send OpenAI TTS Request

Error Handling

When sending any requests, it's crucial to handle potential errors by checking the ErrorStatus in your callback. The ErrorStatus provides information about any issues that might occur during the request.

Error Handling

Cancelling Requests

The plugin allows you to cancel both text-to-text and TTS requests while they are in progress. This can be useful when you want to interrupt a long-running request or change the conversation flow dynamically.

Cancel Request

Best Practices

  1. Always handle potential errors by checking the ErrorStatus in your callback
  2. Be mindful of API rate limits and costs
  3. Use streaming mode for long-form or interactive conversations
  4. Consider cancelling requests that are no longer needed to manage resources efficiently
  5. For TTS functionality, process audio data immediately or store it for later use
  6. Use appropriate audio formats supported by Runtime Audio Importer plugin (MP3, WAV, FLAC, OGG VORBIS, OGG OPUS, BINK, RAW (PCM))

Troubleshooting

  • Verify your API credentials are correct
  • Check your internet connection
  • Ensure Runtime Audio Importer plugin is properly installed when using TTS features
  • Verify you're using the correct audio format when importing TTS response data