Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Các API GenAI của Bộ công cụ học máy khai thác sức mạnh của Gemini Nano để giúp các ứng dụng của bạn thực hiện các tác vụ. Các API này cung cấp chất lượng sẵn có cho các trường hợp sử dụng phổ biến thông qua một giao diện cấp cao. Các API GenAI của Bộ công cụ học máy được xây dựng dựa trên AICore, một dịch vụ hệ thống Android cho phép thực thi các mô hình nền tảng GenAI trên thiết bị để hỗ trợ các tính năng như chức năng nâng cao của ứng dụng và cải thiện quyền riêng tư của người dùng bằng cách xử lý dữ liệu cục bộ.
Các API GenAI của Bộ công cụ học máy hỗ trợ những tính năng sau:
Tóm tắt: Tóm tắt các bài viết hoặc cuộc trò chuyện dưới dạng danh sách có dấu đầu dòng.
Hiệu đính: Chỉnh sửa nội dung ngắn bằng cách tinh chỉnh ngữ pháp và sửa lỗi chính tả.
Viết lại: Viết lại tin nhắn ngắn theo nhiều giọng điệu hoặc phong cách.
Tương tự như các tính năng hiện có khác của Bộ công cụ học máy, các API GenAI chạy hoàn toàn trên thiết bị và do đó mang lại những lợi ích sau:
Dữ liệu đầu vào, dữ liệu suy luận và dữ liệu đầu ra được xử lý trên thiết bị
Chức năng vẫn giữ nguyên khi không có kết nối Internet ổn định
Không mất thêm chi phí máy chủ cho mỗi lệnh gọi API
Ngoài ra, vì các API GenAI được xây dựng dựa trên AICore và được hỗ trợ bởi Gemini Nano, nên mọi ứng dụng đều có thể sử dụng mô hình Gemini Nano dùng chung trên thiết bị. Điều này giúp bạn không cần phải đợi tải một mô hình xuống nếu mô hình đó đã có trên thiết bị, nhờ đó tiết kiệm được dung lượng lưu trữ. Tìm hiểu thêm về cách AICore tách biệt các yêu cầu để bảo vệ quyền riêng tư.
Truyền trực tuyến so với không truyền trực tuyến
Các API GenAI của Bộ công cụ học máy cung cấp cả lựa chọn phát trực tuyến và không phát trực tuyến để nhận kết quả. API truyền phát trực tiếp sẽ phân phối các phản hồi theo gia số khi chúng được tạo, cung cấp một luồng dữ liệu liên tục. Ngược lại, API không truyền trực tuyến sẽ đợi cho đến khi toàn bộ phản hồi hoàn tất rồi mới trả về phản hồi đó dưới dạng một khối duy nhất.
Chọn API truyền phát trực tuyến cho các câu trả lời dài vì API này cho phép nhận được ý kiến phản hồi ban đầu nhanh hơn. API không phát trực tuyến phù hợp hơn với các phản hồi ngắn hoặc khi xử lý kết quả theo lô.
Hỗ trợ về thiết bị
Các API GenAI của Bộ công cụ học máy có trên những thiết bị sau đây, và chúng tôi dự định mở rộng phạm vi hỗ trợ sang các thiết bị khác:
Google: Pixel 10, Pixel 10 Pro, Pixel 10 Pro XL, Pixel 10 Pro Fold, Pixel 9, Pixel 9 Pro, Pixel 9 Pro XL, Pixel 9 Pro Fold
vivo: vivo X200, vivo X200 Pro, vivo X Fold3 Pro, vivo X Fold5
Xiaomi: Xiaomi 15 Ultra, Xiaomi 15
Phạm vi hỗ trợ ngôn ngữ cụ thể có thể thay đổi tuỳ theo cấu hình của thiết bị cụ thể và các mô hình đã được tải xuống thiết bị.
Hạn mức cho mỗi ứng dụng
AICore áp dụng hạn mức suy luận cho mỗi ứng dụng. Điều này có nghĩa là việc gửi quá nhiều yêu cầu GenAI API trong một khoảng thời gian ngắn sẽ dẫn đến phản hồi ErrorCode.BUSY. Khi gặp phải lỗi như vậy, hãy cân nhắc sử dụng thuật toán thời gian đợi luỹ thừa để thử lại yêu cầu.
Mức sử dụng trong nền
Bạn chỉ được phép suy luận bằng GenAI API khi ứng dụng là ứng dụng trên nền trước hàng đầu. Việc sử dụng API khi ứng dụng không ở nền trước (kể cả khi sử dụng một dịch vụ trên nền trước) sẽ dẫn đến phản hồi ErrorCode.BUSY do hiện tại không có hạn mức sử dụng ở chế độ nền.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-10 UTC."],[],[],null,["| This API is offered in beta, and is not subject to any SLA or deprecation policy. Changes may be made to this API that break backward compatibility.\n\nML Kit's GenAI APIs harness the power of [Gemini Nano](https://developer.android.com/ai/gemini-nano/) to help your apps\nperform tasks. These APIs provide out-of-the-box quality for popular use cases\nthrough a high-level interface. The ML Kit GenAI APIs are built on top of\n[AICore](https://android-developers.googleblog.com/2023/12/a-new-foundation-for-ai-on-android.html), an Android system service that enables on-device execution of GenAI\nfoundation models to facilitate features such as enhanced app functionality and\nimproved user privacy by processing data locally.\n\nThe ML Kit GenAI APIs support the following features:\n\n- [**Summarization**](/ml-kit/genai/summarization/android): Summarize articles or chat conversations as a bulleted list.\n- [**Proofreading**](/ml-kit/genai/proofreading/android): Polish short content by refining grammar and fixing spelling errors.\n- [**Rewriting**](/ml-kit/genai/rewriting/android): Rewrite short messages in different tones or styles.\n- [**Image description**](/ml-kit/genai/image-description/android): Generate a short description of a given image.\n\nBenefits of GenAI APIs\n\nSimilar to other existing ML Kit features, GenAI APIs run entirely on-device and\nthus provide the following benefits:\n\n- Input, inference, and output data is processed locally\n- Functionality remains the same without reliable internet connection\n- No additional server cost incurred for each API call\n\nIn addition, since GenAI APIs are built on top of AICore and powered by Gemini\nNano, every app is able to use the shared Gemini Nano model that is on the\ndevice. This avoids the need to have to wait for a model to be downloaded if it\nalready exists on a device, and in turn conserves storage space. Learn [more\nabout how AICore isolates requests to protect privacy](https://android-developers.googleblog.com/2024/10/introduction-to-privacy-and-safety-gemini-nano.html).\n\nStreaming versus non-streaming\n\nML Kit GenAI APIs offer both streaming and non-streaming options for receiving\nresults. The streaming API delivers responses incrementally as they are\ngenerated, providing a continuous flow of data. In contrast, the non-streaming\nAPI waits until the entire response is complete before returning it as a single\nblock.\n\nChoose the streaming API for lengthy responses, as it allows for quicker initial\nfeedback. The non-streaming API is more suitable for short responses or when\nprocessing results in batches.\n\nDevice support\n\nThe ML Kit GenAI APIs are available on the following devices, with\nplans to expand support to additional devices:\n\n- Google: Pixel 10, Pixel 10 Pro, Pixel 10 Pro XL, Pixel 10 Pro Fold, Pixel 9, Pixel 9 Pro, Pixel 9 Pro XL, Pixel 9 Pro Fold\n- Honor: Honor 400 Pro, Magic 6 Pro, Magic 6 RSR, Magic 7, Magic 7 Pro, Magic V3\n- iQOO: iQOO 13\n- Motorola: Razr 60 Ultra\n- OnePlus: OnePlus 13, OnePlus 13s\n- OPPO: Find N5, Find X8, Find X8 Pro\n- POCO: POCO F7 Ultra\n- realme: realme GT 7 Pro\n- Samsung: Galaxy S25, Galaxy S25+, Galaxy S25 Ultra\n- vivo: vivo X200, vivo X200 Pro, vivo X Fold3 Pro, vivo X Fold5\n- Xiaomi: Xiaomi 15 Ultra, Xiaomi 15\n\nAvailability of specific language support may vary depending on the particular\ndevice's configuration and the models that have been downloaded to the device.\n\nQuota per application\n\nAICore enforces an inference quota per app. This means that making too many\nGenAI API requests in a short period will result in an `ErrorCode.BUSY`\nresponse. When receiving such an error, consider using exponential backoff to\nretry the request.\n\nBackground usage\n\nGenAI API inference is permitted only when the app is the top foreground\napplication. Using the API when the app is not in the foreground, including\nusing a foreground service, will result in an `ErrorCode.BUSY` response due to\nthe current lack of background usage quota.\n\nSample code\n\nTo get this code, check out the following samples:\n\n- [ML Kit GenAI Samples](https://github.com/googlesamples/mlkit/tree/master/android/genai)\n- [Android AI Catalog Sample](https://github.com/android/ai-samples/tree/main/ai-catalog)"]]