Amplify CLI Predictions Category Plugin
raw JSON →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.
Common errors
error AccessDeniedException: User: arn:aws:sts::... is not authorized to perform: rekognition:DetectLabels on resource: arn:aws:rekognition:... ↓
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. error Amplify has not been configured. Please call Amplify.configure() before using any Amplify APIs. ↓
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. error Error: Cannot find module '@aws-amplify/predictions' ↓
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. Warnings
breaking 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. ↓
breaking 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. ↓
gotcha 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. ↓
gotcha 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. ↓
Install
npm install amplify-category-predictions yarn add amplify-category-predictions pnpm add amplify-category-predictions Imports
- Amplify wrong
const Amplify = require('aws-amplify');correctimport { Amplify } from 'aws-amplify'; - Predictions wrong
import Predictions from '@aws-amplify/predictions';correctimport { Predictions } from 'aws-amplify'; - configure wrong
Amplify.configure({}); // Missing generated configcorrectAmplify.configure(amplifyconfig);
Quickstart
/* --- CLI Setup (Run in your terminal) --- */
# Install the Amplify CLI globally
npm install -g @aws-amplify/cli
# Configure the CLI with your AWS account (interactive flow)
amplify configure
# Initialize a new Amplify project
mkdir my-predictions-app
cd my-predictions-app
amplify init # Follow prompts: choose frontend, framework, project name, environment
# Add the Predictions category (interactive flow)
amplify add predictions
# Prompts example:
# ? Please select from one of the categories below: Convert
# ? What would you like to convert?: translateText
# ? Would you like to allow unauthenticated users to use this category?: No
# ? Who should have access?: Auth users only
# ? What is the default language?: English
# ? What other languages do you want to support?: Spanish, French
# Deploy your backend resources to AWS
amplify push
/* --- Client-Side Usage (e.g., src/App.js or src/main.ts) --- */
import { Amplify } from 'aws-amplify';
import { Predictions } from 'aws-amplify'; // Or 'import { Predictions } from '@aws-amplify/predictions';
import amplifyconfig from './amplifyconfiguration.json'; // Ensure this file exists after `amplify push`
// Configure Amplify with your backend details
Amplify.configure(amplifyconfig);
async function translateExample() {
try {
const textToTranslate = 'Hello, how are you?';
console.log(`Translating: "${textToTranslate}"`);
const result = await Predictions.convert({
translateText: {
source: {
text: textToTranslate,
language: 'en' // Source language
},
targetLanguage: 'es' // Target language
}
});
console.log('Translated text (Spanish):', result.text);
const resultFrench = await Predictions.convert({
translateText: {
source: {
text: textToTranslate,
language: 'en'
},
targetLanguage: 'fr'
}
});
console.log('Translated text (French):', resultFrench.text);
} catch (error) {
console.error('Error during translation:', error);
}
}
translateExample();
// Example for identifying text in an image (requires appropriate backend config)
/*
async function identifyTextInImage(file: File) {
try {
const result = await Predictions.identify({
text: {
source: { file },
format: 'PLAIN' // or 'FORM', 'TABLE', 'ALL'
}
});
console.log('Detected text:', result.text.fullText);
} catch (error) {
console.error('Error identifying text:', error);
}
}
*/