Custom AI Keyboard With Multi-Provider Proofreading

GroqKeyFreeAPI · Updated 2026-11-24 · 14 min read

Smartphone keyboard with AI suggestion popup
A privacy-focused keyboard displaying AI corrections in real-time

Typing on a smartphone means surrendering your keystrokes to cloud servers, often without knowing how they are stored or used. A privacy-focused keyboard changes this dynamic by allowing you to choose where your data goes, or keeping it entirely on-device. By integrating multiple AI providers, you can balance speed, cost, and privacy in a single input method. This approach gives you granular control over your digital footprint, ensuring that sensitive text is processed exactly how you want it to be.

The HeliboardL project demonstrates how an AOSP-based keyboard can route text through different engines—Gemini, Groq, or OpenAI—depending on your settings. It also supports offline proofreading using ONNX models, ensuring that sensitive documents never leave your device. This approach gives you granular control over your digital footprint. The site you are reading is not affiliated with Groq, though it uses their free API for demonstration purposes.

In this guide, we will build a similar system. We will configure a keyboard that uses the free Groq-compatible API for real-time grammar correction while maintaining the option to use local models. You will learn how to structure the network calls, handle streaming responses, and integrate the logic into an Android input method editor (IME). We will also explore how to optimize performance and ensure a smooth user experience across different devices.

Frequently asked questions

What is HeliboardL?

HeliboardL is an open-source, AOSP-based Android keyboard that supports multi-provider AI proofreading. It allows users to switch between cloud services like Groq and OpenAI, or use local ONNX models for offline correction. It is designed for privacy, giving users control over where their text data is processed.

How does Groq compare to local ONNX models for keyboard proofreading?

Groq offers high-speed cloud inference with minimal latency, ideal for real-time suggestions. Local ONNX models run entirely on your device, ensuring zero data transmission but requiring more processing power. Groq is better for complex grammar; local models are better for privacy and offline use.

Which is better: Groq or OpenAI for keyboard AI?

Groq provides faster response times due to its hardware architecture, making it superior for real-time typing assistance. OpenAI models often have broader knowledge but may introduce slight latency. For a keyboard, speed is critical, so Groq is generally the better choice for proofreading workflows.

What is the role of ONNX in this keyboard?

ONNX (Open Neural Network Exchange) allows the keyboard to run local AI models without internet connectivity. This ensures that sensitive text, such as passwords or personal notes, is processed entirely on-device, providing a strong privacy layer for users who prefer not to send data to any cloud provider.

How do you handle API keys in the keyboard app?

API keys are typically stored in the Android Keystore system or shared preferences, encrypted where possible. The keyboard app reads these keys at runtime to authenticate requests to providers like Groq. Users can manage keys through the app settings, allowing them to rotate or remove access without uninstalling the keyboard.

Can the keyboard work without an internet connection?

Yes, if configured with local ONNX models. The keyboard can fall back to offline proofreading when no network is available. Cloud providers like Groq require an active connection, so the app must support switching between online and offline modes based on network status.

What are the trade-offs of using a custom keyboard?

Custom keyboards can offer better privacy and customization but may lack the polished UI of mainstream options. They might also have compatibility issues with certain apps or gestures. However, for users prioritizing data control, the trade-off is worth the added security and tailored AI features.

How does the keyboard handle streaming responses?

Streaming allows suggestions to appear word-by-word as they are generated. This reduces perceived latency, making the AI feel responsive. The keyboard buffer collects these tokens and updates the input field in real-time, providing a smooth user experience without waiting for the entire response to finish.

Step by step

  1. Set Up Android Studio — Install Android Studio and create a new project with the Input Method service template. Ensure you have the necessary permissions for network access and storage. Configure your build tools to support the latest Android SDK versions.
  2. Integrate AI Libraries — Add the OpenAI SDK and ONNX Runtime to your project. Configure the dependencies to support both cloud and local inference methods. Use Python for prototyping the logic before moving it to Java or Kotlin.
  3. Configure Groq API — Set up the Groq API endpoint in your code. Use the free API keyless endpoint for testing. Implement the network call logic to send text and receive corrections. Ensure you handle streaming responses for real-time feedback.
  4. Build the IME Service — Extend the BaseInputMethodService to handle input events. Implement the logic to capture text, send it to the AI engine, and display suggestions in the UI. Test the integration with various text inputs.
  5. Test and Optimize — Test the keyboard with various inputs and network conditions. Optimize latency and accuracy by caching responses and quantizing local models. Use Android Profiler to monitor performance and identify bottlenecks.
  6. Deploy the Keyboard — Publish the keyboard on the Play Store or distribute it as an APK. Provide clear documentation for users on how to configure and use the AI features. Include a link to /llms.txt for technical details.

Understanding the Architecture

A privacy-focused keyboard acts as a middleware between your keystrokes and the AI model. It captures text input, analyzes it for errors, and returns suggestions. By supporting multiple providers, the keyboard can route requests to the best available service. For example, it might use a local model for simple spell checks and a cloud model for complex grammar corrections. This architecture ensures that you are not locked into a single provider, allowing you to switch based on cost, speed, or privacy needs.

The HeliboardL project demonstrates this flexibility by allowing users to select their preferred provider. This is crucial because no single model excels at everything. Some models are faster, some are cheaper, and some are more private. By decoupling the input method from the AI engine, you gain the ability to optimize for your specific needs. You can also integrate local models for offline use, ensuring that your data remains secure even when you are not connected to the internet.

Data Flow in a Multi-Provider Keyboard

When you type, the keyboard captures the text buffer and sends it to the AI engine. The engine processes the text and returns corrections. If you are using Groq, the request is sent to the API. If you are using ONNX, the model runs locally. The keyboard then applies the corrections to the input field, updating the text in real-time. This flow must be efficient to avoid lag, which is why streaming responses are preferred.

Privacy Considerations

Privacy is the core feature. By allowing local processing, you ensure that sensitive data never leaves your device. Even when using cloud providers, you can choose services that do not store your data. The keyboard can also encrypt the text before sending it, adding an extra layer of security for users who are cautious about their digital footprint. The site you are reading is not affiliated with Groq, but uses their API for demonstration.

Setting Up the Environment

Before building the keyboard, you need a development environment. Android Studio is the standard tool for creating input methods. You will need to set up an Android project with the necessary permissions for network access. This allows the keyboard to communicate with cloud providers like Groq. You should also configure your build tools to support the latest Android SDK versions, ensuring compatibility with modern devices.

You will also need to install the libraries for AI inference. If you are using local models, you will need the ONNX Runtime. For cloud providers, you can use the OpenAI-compatible SDK, which works with Groq. These libraries handle the network requests and data parsing, simplifying the integration process. You can also use Python for prototyping the logic before moving it to Java or Kotlin.

Dependencies and Libraries

The key dependencies include the Android SDK, the OpenAI Python library for API calls, and the ONNX Runtime for local inference. These libraries provide the necessary tools to send requests and process responses. You will also need a JSON parser to handle the structured data returned by the AI models. Ensure that your dependencies are up-to-date to avoid compatibility issues.

Network Permissions

The keyboard app must request internet access to communicate with cloud providers. In the AndroidManifest.xml file, you need to add the <uses-permission> tag for internet access. Without this, the keyboard will fail to send requests to Groq or other services, resulting in offline-only behavior. You should also consider adding permissions for storage if you plan to cache responses locally.

AI provider settings on a smartphone
Users can switch between cloud and local AI providers

Configuring the AI Provider

The core of the keyboard is the AI provider configuration. You need to define how the keyboard connects to the API. For Groq, this involves setting the base URL and the model name. The free API allows you to start without an API key, making it easy to test the integration. You can also configure local models by pointing the ONNX Runtime to the model file, allowing the keyboard to work offline.

By supporting both cloud and local models, you create a hybrid system that balances speed and privacy. The user can switch between modes based on their current needs, such as switching to local mode when on a private network or when sending sensitive data. This flexibility is key to building a truly privacy-focused keyboard that adapts to the user's context.

Groq API Configuration

The Groq API uses the OpenAI-compatible endpoint. You need to set the base URL to the free API endpoint. The model name is 'free-ai'. This setup allows you to send requests using standard OpenAI SDK methods, making it easy to switch providers if needed. The API supports streaming, which is crucial for real-time typing assistance. You can also use the /ask endpoint for simple queries.

Local ONNX Configuration

For local models, you need to load the ONNX model into memory. This process can take a few seconds, so it is best done at app startup. The model processes the text input and returns corrections. This method is slower than cloud inference but ensures that your data remains on the device, providing a strong privacy guarantee. You can quantize the model to improve performance.

Implementing the Proofreading Logic

Proofreading involves analyzing the text for errors and suggesting corrections. The keyboard captures the text buffer and sends it to the AI engine. The engine returns a list of corrections, which the keyboard applies to the input field. This process must be fast to avoid lag, so streaming responses are preferred. You can also implement a fallback mechanism that uses local models if the cloud provider is unavailable.

The logic also includes error handling. If the API is down, the keyboard should fall back to offline mode or display an error message. This ensures a smooth user experience even when the network is unreliable. The keyboard can also cache previous responses to reduce latency for repeated inputs. This is particularly useful for common phrases or frequently used words.

Real-Time Correction

Real-time correction requires low latency. Streaming responses allow the keyboard to display suggestions as they are generated. This makes the AI feel responsive and natural. The keyboard buffers the tokens and updates the input field in real-time, providing a seamless experience for the user. You can also implement a debounce mechanism to prevent excessive API calls.

Error Handling and Fallback

If the cloud provider is unavailable, the keyboard should switch to offline mode. This can be done by checking the network status and falling back to local models. The user should be informed of the switch, either through a notification or a status indicator. This ensures that the keyboard remains functional even during outages, providing a consistent user experience.

Data flow diagram for AI keyboard
Data flow in a multi-provider keyboard system

Building the User Interface

The user interface (UI) of the keyboard should be intuitive and unobtrusive. It needs to display suggestions without blocking the user's view. A common approach is to show corrections in a popup or as a suggested word above the keyboard. This allows the user to accept or reject the suggestion easily. The UI should also be customizable, allowing users to adjust the size and position of the suggestions.

The UI should also include settings for configuring the AI provider. Users need to be able to switch between cloud and local modes, manage API keys, and adjust sensitivity settings. These settings should be accessible through a dedicated menu, allowing users to customize the keyboard to their preferences. You can also add a 'Copy Prompt' button that links to /prompt.txt for advanced users.

Displaying Suggestions

Suggestions can be displayed as a popup above the keyboard or as a highlighted word in the text field. The popup approach is less intrusive but requires more screen space. The highlighted word approach is more subtle but may be harder to see for some users. Choose the method that best fits your design goals and user feedback.

Settings Menu

The settings menu should allow users to configure the AI provider, manage API keys, and adjust sensitivity. This menu should be easy to access, either through a gear icon on the keyboard or through the app settings. Clear labels and descriptions will help users understand the options and make informed decisions. You can also add a link to /llms.txt for more information on the models used.

Testing and Optimization

Testing is crucial to ensure the keyboard performs well under different conditions. You should test with various text inputs, network conditions, and device configurations. This will help you identify any bottlenecks or bugs in the AI integration. Focus on latency, accuracy, and resource usage. You can also use Android Profiler to monitor memory and CPU usage during testing.

Optimization involves reducing latency and improving accuracy. You can achieve this by caching responses, optimizing the model size, and using efficient data structures. For cloud providers, you can use streaming to reduce perceived latency. For local models, you can quantize the model to reduce memory usage and improve speed. You can also implement a retry mechanism to handle transient network errors.

Latency Testing

Measure the time it takes for the keyboard to return a suggestion. This should be under 100ms for a seamless experience. Use tools like Android Profiler to identify bottlenecks in the network or processing pipeline. Adjust the model or network settings to reduce latency. You can also test with different network speeds to ensure consistent performance.

Accuracy Evaluation

Evaluate the accuracy of the suggestions by comparing them to human corrections. This can be done manually or by using a benchmark dataset. Focus on common errors like spelling, grammar, and punctuation. Ensure that the keyboard does not introduce new errors or change the meaning of the text. You can also gather user feedback to improve the model's performance over time.

Developer workspace for building AI keyboards
Setting up the environment for building a custom keyboard

Integrating with Android IME

The Android Input Method Editor (IME) framework provides the foundation for building a keyboard. You need to extend the BaseInputMethodService class and implement the necessary methods for handling input events. This includes capturing keystrokes, displaying suggestions, and managing the input state. The IME framework also handles the keyboard layout and view management, allowing you to customize the appearance and behavior of the keyboard.

The IME framework also handles the keyboard layout and view management. You can customize the layout to include AI-specific keys, such as a 'Correct' button or a 'Switch Provider' toggle. This allows users to interact with the AI features directly from the keyboard interface, enhancing the user experience. You can also implement gestures for quick actions, such as swiping to accept suggestions.

Input Event Handling

Handle input events by overriding the onKey method. This method is called for each keystroke, allowing you to capture the text and send it to the AI engine. You can also handle special keys, such as the space bar, to trigger proofreading or suggestion display. This method is the core of the keyboard's interaction with the user.

View Management

Manage the keyboard view by extending the InputMethodService. This allows you to customize the layout and add custom views, such as a suggestion popup. You can also handle view state changes, such as switching between alphabetic and numeric keyboards, to ensure the AI features work correctly in all modes. This ensures a consistent experience across different input contexts.

Deployment and Distribution

Once the keyboard is built and tested, you can distribute it to users. You can publish it on the Google Play Store or distribute it as an APK. The Play Store offers wider reach but requires compliance with their policies. Distributing as an APK gives you more control but requires users to enable installation from unknown sources. You can also use GitHub Releases to distribute the APK to early adopters.

You should also provide clear documentation for users, explaining how to configure the AI provider and manage their data. This includes instructions for setting up API keys, switching between modes, and troubleshooting common issues. Good documentation will help users get the most out of the keyboard and reduce support requests. You can also link to the /llms.txt file for more technical details.

Play Store Submission

To publish on the Play Store, you need to create a developer account and submit your APK. You will need to provide a description, screenshots, and a privacy policy. Ensure that your privacy policy clearly explains how you handle user data, especially if you are using cloud providers. You can also include a link to the /prompt.txt file for advanced users.

APK Distribution

For APK distribution, you can host the file on your website or use a service like GitHub Releases. Users will need to enable installation from unknown sources in their device settings. This method is faster and gives you more control, but it requires users to manually update the app when new versions are released. You can also provide a direct download link for easy access.

Smartphone with privacy icon
Ensuring data privacy in custom AI keyboards
Try the free API

Test the keyless API directly in your browser or via the Python SDK to see Groq's speed in action without configuring any keys.

Read also