Q-Consultation for every industry

Securely hold virtual meetings and video conferences

Learn More>

Want to learn more about our products and services?

Speak to us now

AI Rephrase Implementation Guide for iOS Apps

Illia Chemolosov
14 Sep 2023
chat screen showing AI rephrase functionality

Welcome to the AI Rephrase Implementation Guide for iOS, your key to integrating the remarkable capabilities of AI Rephrase into your iOS applications. If you’re looking to enhance the clarity of communication, add a touch of personality to your messaging, or simply explore the potential of this cutting-edge technology, you’ve come to the right place.

With QuickBlox, you can easily integrate AI rephrasing features into your iOS chat App. Whether you’re building a chat app from scratch or using our convenient iOS UI Kit, the QuickBlox iOS AI Library empowers you to seamlessly integrate AI rephrasing capabilities using the QBAIRephrase Swift package.

I. Integrate QBAIRephrase Library

How to Install QBAIRephrase

QuickBlox is dedicated to creating developer friendly tools to make AI integration effortless. Our lightweight AI Rephrase library can be implemented in a few simple steps.

  1. Open your project in Xcode.
  2. Navigate to **File** > **Swift Packages** > **Add Package Dependency**.
  3. Enter the repository URL `https://github.com/QuickBlox/ios-ai-rephrase` and click “Next”.
  4. Choose the appropriate version rule and click “Next”.
  5. Click “Finish” to add the package to your project.

How to Use QBAIRephrase

1. Import the QBAIRephrase module:

   import QBAIRephrase

2. Rephrase text using the OpenAI API:

   let text: String = ... // Replace with your text

   // Rephrase text using an API key
   do {
       let apiKey = "YOUR_OPENAI_API_KEY"
       let rephrasedText = try await QBAIRephrase.openAI(rephrase: text, tone: .empathetic, secret: apiKey)
       print("Rephrased Text: \(rephrasedText)")
   } catch {
       print("Error: \(error)")

   // Rephrase text using a QuickBlox user token and proxy URL
   do {
       let qbToken = "YOUR_QUICKBLOX_USER_TOKEN"
       let proxyURL = "https://your-proxy-server-url"
       let rephrasedText = try await QBAIRephrase.openAI(rephrase: text, tone: .empathetic, qbToken: qbToken, proxy: proxyURL)
       print("Rephrased Text: \(rephrasedText)")
   } catch {
       print("Error: \(error)")

Follow these steps to integrate QBAIRephrase into your project, and you’ll be able to rephrase text using the OpenAI API seamlessly.

II. UI Kit Rephrase Feature

We have already integrated the AI Rephrase feature within our iOS UI Kit. This feature leverages the OpenAI API key or proxy server to generate responses more securely and efficiently.

How to Use

1. Open your project with QuickBlox UI Kit Swift package.

2. Configure the settings:

   // Enable AI Rephrase
   QuickBloxUIKit.feature.ai.rephrase.enable = true

If this option is enabled, the menu bar for the Rephrase tones will appear above the chat message when you type the text.

chat screen showing AI rephrase

When you click your selected tone, this message content will be rephrased.

Clicking “Back to original text” in a tone menu list will revert the text to its original version.

3. Set up the AI settings by providing either the OpenAI API key:

   // Set OpenAI API key or proxy server URL
   QuickBloxUIKit.feature.ai.rephrase.openAIAPIKey = "YOUR_OPENAI_API_KEY"

Or set up with a proxy server:

   QuickBloxUIKit.feature.ai.rephrase.proxyServerURLPath = "https://your-proxy-server-url"

Please note: using the proxy server is the recommended method because it is more secure.

OpenAI API Key

To use the OpenAI API for rephrasing, you need an API key. Follow these steps to get your API key:

  1. Sign in to your OpenAI account or create a new one on the OpenAI website.
  2. Navigate to the API section and sign up for API access.
  3. Once approved, obtain your API key.

Proxy Server

Enhance security and functionality by using a proxy server like the QuickBlox AI Assistant Proxy Server

  • Protect sensitive information like API keys.
  • Implement access control mechanisms for secure communication.
  • Mitigate the risk of API key exposure.
  • Enforce rate limiting and throttling for API usage compliance.
  • Monitor and log API requests for auditing purposes.

Wrapping up

Integrating AI Rephrase into your iOS chat app has never been easier. By following the steps outlined above, you can seamlessly empower your users with real-time rephrasing capabilities using QuickBlox and the QBAIRephrase Swift package. Unlock the power of AI-driven interactions and enhance user communication in your app.

For more information and resources, explore the QuickBlox AI Proxy Server and the QBAIRephrase Swift package repositories.


QuickBlox AI Proxy Server

QBAIRephrase Swift Package

QuickBlox Documentation

Happy coding! 🚀

Have Questions? Need Support?

Join the QuickBlox Developer Discord Community, where you can share ideas, learn about our software, & get support.

Join QuickBlox Discord

Read More

Ready to get started?

QuickBlox post-box