Skip to content

AI Prompt Provider

The AI Prompt Provider module is designed to streamline the process of generating prompts for both custom and natively supported AI providers.

index.js
const crowdinModule = require('@crowdin/app-project-module');
const {PromptActions} = require("@crowdin/app-project-module/out/modules/ai-prompt-provider/types");
const configuration = {
baseUrl: 'https://123.ngrok.io',
clientId: 'clientId',
clientSecret: 'clientSecret',
name: 'Sample App',
identifier: 'sample-app',
description: 'Sample App description',
dbFolder: __dirname,
imagePath: __dirname + '/' + 'logo.png',
aiPromptProvider: {
actions: [PromptActions.PRE_TRANSLATE],
allowRetryOnQaIssues: false,
formSchema: {
type: "object",
properties: {
firstOption: {
title: "Option 1",
type: "string"
}
},
required: ['firstOption']
},
compile: async function({ options, payload, client, context, requestData }) {
return 'Prompt text compiled based on options and payload';
}
}
};
crowdinModule.createApp(configuration);
ParameterDescription
actionsAn array of supported prompt actions. If not provided, all actions are supported. Available action types: pre_translate, assist, qa_check, custom:type-of-action.
allowRetryOnQaIssuesIf false, disables auto-retry on QA issues in the user interface. Default: true.
formSchemaReact JSON Schema for the form.
statusOptional handler that returns prompt status info (used providers, configuration state, errors/warnings). When provided, a statusUrl is automatically exposed in the manifest.

Used to generate prompts based on the options and payload provided.

  • options - Options selected by the user.
  • payload - Data provided by the AI provider.
  • client - Crowdin API client.
  • context - Context object.

The function should return the prompt text.

Optional handler that returns prompt status information. When provided, Crowdin will call this endpoint to display real-time status for external prompts.

  • options - Options selected by the user.
  • aiPromptId - The ID of the AI prompt.
  • client - Crowdin API client.
  • context - Context object.

The function should return an object with the following properties:

PropertyTypeDescription
usedAiProviderIdsnumber[]IDs of AI providers used by the prompt.
isConfiguredbooleanWhether the prompt is fully configured.
errorsArray<{ code: string; message: string }>List of errors, if any.
warningsArray<{ code: string; message: string }>List of warnings, if any.
index.js
const configuration = {
// ... other configuration
aiPromptProvider: {
compile: async ({ options, payload }) => {
return 'Prompt text';
},
status: async ({ options, aiPromptId, client, context }) => {
return {
usedAiProviderIds: [1, 2],
isConfigured: true,
errors: [],
warnings: [],
};
}
}
};

You can register multiple AI prompt providers in a single app by providing an array:

index.js
const { PromptActions } = require('@crowdin/app-project-module/out/modules/ai-prompt-provider/types');
const configuration = {
// ... other configuration
aiPromptProvider: [
{
name: 'Translation Prompt',
actions: [PromptActions.PRE_TRANSLATE],
compile: async ({ options, payload }) => {
return 'Translate the following text: ' + payload;
}
},
{
name: 'QA Prompt',
actions: [PromptActions.QA_CHECK],
compile: async ({ options, payload }) => {
return 'Check the quality of the following translation: ' + payload;
}
}
]
};