Registry /
aws / amplify-category-predictions
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Amplify
✓ import { Amplify } from 'aws-amplify';
✗ const Amplify = require('aws-amplify');
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.
Predictions
✓ import { Predictions } from 'aws-amplify';
✗ import Predictions from '@aws-amplify/predictions';
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.
configure
✓ Amplify.configure(amplifyconfig);
✗ Amplify.configure({}); // Missing generated config
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.
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.
/* --- 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);
}
}
*/
Debug
Known issues
breakingAmplify 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.fixRun `amplify override <category>` or `amplify update <category>` in a test environment first, then `amplify push`. Follow the official Amplify migration guides for detailed steps.
affects: >=7.0.0
breakingAWS 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.fixEnsure 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.
affects: >=1.0.0 (hosting impact)
gotchaWhen 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.fixRefer 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.
affects: <v7.0.0
gotchaThe `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.fixAlways 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.
affects: >=1.0.0
Errors
Common errors & fixes
AccessDeniedException: User: arn:aws:sts::... is not authorized to perform: rekognition:DetectLabels on resource: arn:aws:rekognition:...
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).
fixEnsure 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.
Amplify has not been configured. Please call Amplify.configure() before using any Amplify APIs.
The `Amplify.configure(amplifyconfig)` call is missing or not executed before attempting to use `Predictions` APIs in your client-side application.
fixMake 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.
Error: Cannot find module '@aws-amplify/predictions'
The `@aws-amplify/predictions` package is not installed as a dependency in your client-side project.
fixInstall 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.
Audit
Dependencies
No dependency data recorded yet.