With ML Kit's GenAI Prompt API, you can send natural language requests on-device to Gemini Nano. GenAI Prompt API accepts either a text input or a combined image and text input, and emits text output.
You can use GenAI Prompt API for a variety of use cases, including the following:
Use case |
Example |
Image understanding |
Analyzing photos for classification, such as "pets", "food", or "travel". |
Short translations |
Translating short messages between a delivery driver and customer. |
Guided summarization |
Summarizing reviews of a restaurant based on a user's specific interest. |
Entity extraction |
Extracting important details about an upcoming event from an email thread. |
Content generation inspiration |
Suggesting prompts for a journal entry. |
Intelligent document scanning |
Extracting and categorizing items from a receipt image. |
Text classification |
Classifying customer reviews into a positive, neutral, or negative category. |
Prompt API versus feature-specific APIs
The existing ML Kit GenAI APIs support the Summarization, Proofreading, Rewriting, and Image Description use cases, which Prompt API also supports. The following table outlines the benefits of each:
Consideration |
Prompt API |
Feature-specific APIs |
Integration effort |
High. Requires more effort to implement, due to prompt engineering and quality assurance. |
Low. Requires less effort, as these APIs are already fine-tuned for specific use cases. No need to work directly with the LLM. |
Flexibility |
More flexibility, as you can custom engineer the prompt. |
Less flexibility. Each API has fixed fine-tuning and a built-in prompt that has the following characteristics:
|
As a general rule, use Prompt API when you need more customization and flexibility, and use the feature-specific APIs for standard tasks that don't require complex logic.