{"id":17487,"library":"amplify-category-predictions","title":"Amplify CLI Predictions Category Plugin","description":"The `amplify-category-predictions` package is a core plugin for the AWS Amplify Command Line Interface (CLI), enabling developers to provision and manage AWS AI/ML services within their Amplify projects. It facilitates the integration of services like Amazon Rekognition (for image identification), Amazon Translate (for language conversion), Amazon Polly (for text-to-speech), Amazon Transcribe (for speech-to-text), Amazon Comprehend (for text interpretation), and Amazon Textract (for document text extraction). This plugin abstracts complex AWS resource configuration, including IAM permissions, into a streamlined CLI workflow. While the broader Amplify CLI ecosystem is currently on version `14.x.x` (e.g., `14.3.0` as of March 2026), this specific plugin's latest stable version is `5.5.25` (as of October 2025). It adheres to the rapid release cadence of the Amplify CLI, with frequent updates often bundled with broader CLI releases, and is primarily differentiated by its opinionated, CLI-driven approach to integrating sophisticated AI/ML capabilities into web and mobile applications for frontend consumption via the `@aws-amplify/predictions` client library.","status":"active","version":"4.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/aws-amplify/amplify-cli","tags":["javascript","amplify","aws","typescript"],"install":[{"cmd":"npm install amplify-category-predictions","lang":"bash","label":"npm"},{"cmd":"yarn add amplify-category-predictions","lang":"bash","label":"yarn"},{"cmd":"pnpm add amplify-category-predictions","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is for the client-side library to configure your application, not for the CLI plugin itself. Ensure `aws-amplify` is installed in your project.","wrong":"const Amplify = require('aws-amplify');","symbol":"Amplify","correct":"import { Amplify } from 'aws-amplify';"},{"note":"While `Predictions` can be imported from `@aws-amplify/predictions`, it's commonly re-exported and configured via `aws-amplify` for unified setup. Both packages (`aws-amplify` and `@aws-amplify/predictions`) are required for client-side usage.","wrong":"import Predictions from '@aws-amplify/predictions';","symbol":"Predictions","correct":"import { Predictions } from 'aws-amplify';"},{"note":"After running `amplify push`, a `src/amplifyconfiguration.json` (or `aws-exports.js` for older setups) file is generated containing your backend resource details. This file MUST be imported and passed to `Amplify.configure` for client-side functionality.","wrong":"Amplify.configure({}); // Missing generated config","symbol":"configure","correct":"Amplify.configure(amplifyconfig);"}],"quickstart":{"code":"/* --- CLI Setup (Run in your terminal) --- */\n# Install the Amplify CLI globally\nnpm install -g @aws-amplify/cli\n\n# Configure the CLI with your AWS account (interactive flow)\namplify configure\n\n# Initialize a new Amplify project\nmkdir my-predictions-app\ncd my-predictions-app\namplify init # Follow prompts: choose frontend, framework, project name, environment\n\n# Add the Predictions category (interactive flow)\namplify add predictions\n# Prompts example:\n# ? Please select from one of the categories below: Convert\n# ? What would you like to convert?: translateText\n# ? Would you like to allow unauthenticated users to use this category?: No\n# ? Who should have access?: Auth users only\n# ? What is the default language?: English\n# ? What other languages do you want to support?: Spanish, French\n\n# Deploy your backend resources to AWS\namplify push\n\n/* --- Client-Side Usage (e.g., src/App.js or src/main.ts) --- */\nimport { Amplify } from 'aws-amplify';\nimport { Predictions } from 'aws-amplify'; // Or 'import { Predictions } from '@aws-amplify/predictions';\nimport amplifyconfig from './amplifyconfiguration.json'; // Ensure this file exists after `amplify push`\n\n// Configure Amplify with your backend details\nAmplify.configure(amplifyconfig);\n\nasync function translateExample() {\n  try {\n    const textToTranslate = 'Hello, how are you?';\n    console.log(`Translating: \"${textToTranslate}\"`);\n\n    const result = await Predictions.convert({\n      translateText: {\n        source: {\n          text: textToTranslate,\n          language: 'en' // Source language\n        },\n        targetLanguage: 'es' // Target language\n      }\n    });\n    console.log('Translated text (Spanish):', result.text);\n\n    const resultFrench = await Predictions.convert({\n      translateText: {\n        source: {\n          text: textToTranslate,\n          language: 'en'\n        },\n        targetLanguage: 'fr'\n      }\n    });\n    console.log('Translated text (French):', resultFrench.text);\n\n  } catch (error) {\n    console.error('Error during translation:', error);\n  }\n}\n\ntranslateExample();\n\n// Example for identifying text in an image (requires appropriate backend config)\n/*\nasync function identifyTextInImage(file: File) {\n  try {\n    const result = await Predictions.identify({\n      text: {\n        source: { file },\n        format: 'PLAIN' // or 'FORM', 'TABLE', 'ALL'\n      }\n    });\n    console.log('Detected text:', result.text.fullText);\n  } catch (error) {\n    console.error('Error identifying text:', error);\n  }\n}\n*/\n","lang":"typescript","description":"This quickstart guides you through setting up an Amplify project with predictions via the CLI, deploying the backend, and then demonstrates client-side text translation using the configured resources. It also includes commented examples for other prediction features."},"warnings":[{"fix":"Run `amplify override <category>` or `amplify update <category>` in a test environment first, then `amplify push`. Follow the official Amplify migration guides for detailed steps.","message":"Amplify CLI `v7` introduced significant changes to project structure and override capabilities for IAM, Cognito, and S3. Projects created with older CLI versions require a migration process, which involves updating resource configurations and potentially re-deploying your backend.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Ensure your local development environment meets Node.js requirements (v12+). For Amplify Hosting, update your `amplify.yaml` or console settings to use Node.js 20 or 22.","message":"AWS Amplify Hosting will deprecate support for Node.js 14, 16, and 18 runtimes after September 15, 2025. Applications deployed on Amplify Hosting should target Node.js 20 or 22 for build and runtime environments to ensure continued support and performance. The Amplify CLI itself requires Node.js 12.x or greater and npm 6.x or greater.","severity":"breaking","affected_versions":">=1.0.0 (hosting impact)"},{"fix":"Refer to the Amplify documentation for the exact `parameters.json` updates needed for `identify-text-resource` and `identify-labels-resource` if you encounter unexpected behavior or permission issues with these features.","message":"When using `Identify Labels` or `Identify Text` features via `amplify add predictions` in older versions of the CLI, some configuration items (e.g., `identifyDoc`, `access`, `format`, `type`) might need to be manually added to specific `parameters.json` files within your `amplify/backend` directory. This was a known issue that might still affect projects on older CLI versions.","severity":"gotcha","affected_versions":"<v7.0.0"},{"fix":"Always keep your global `amplify-cli` installation updated (`npm install -g @aws-amplify/cli@latest`). When issues arise, verify the versions of core `@aws-amplify/*` packages in your project's `node_modules` and ensure they are consistent with the `amplify-cli` version.","message":"The `amplify-category-predictions` package version (`5.5.25`) may not directly align with the main `amplify-cli` version (`14.x.x`). While plugins are generally compatible with the latest CLI, unexpected behaviors can occur if there's a significant mismatch, especially during core CLI updates or SDK migrations within the monorepo.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure that during `amplify add predictions`, you grant the correct access levels (authenticated or guest) and that the automatically generated IAM policies (visible in the AWS console under your Identity Pool roles) have the required actions for the services you intend to use. You may need to manually update the IAM policy for the roles if default options were insufficient or a new feature was added.","cause":"The authenticated or unauthenticated IAM role configured by Amplify for predictions lacks the necessary permissions for the specific AWS AI service being invoked (e.g., Rekognition, Translate, Comprehend).","error":"AccessDeniedException: User: arn:aws:sts::... is not authorized to perform: rekognition:DetectLabels on resource: arn:aws:rekognition:..."},{"fix":"Make sure to import and call `Amplify.configure(amplifyconfig)` at the root level of your application (e.g., `index.js` or `main.ts`) after `amplify push` has generated the `amplifyconfiguration.json` file. Ensure the `amplifyconfiguration.json` file is correctly imported and available.","cause":"The `Amplify.configure(amplifyconfig)` call is missing or not executed before attempting to use `Predictions` APIs in your client-side application.","error":"Amplify has not been configured. Please call Amplify.configure() before using any Amplify APIs."},{"fix":"Install the predictions library: `npm install @aws-amplify/predictions aws-amplify` or `yarn add @aws-amplify/predictions aws-amplify`. Ensure both `aws-amplify` and `@aws-amplify/predictions` are present and at compatible versions.","cause":"The `@aws-amplify/predictions` package is not installed as a dependency in your client-side project.","error":"Error: Cannot find module '@aws-amplify/predictions'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}