---
title: "AI Translate Strings"
method: POST
path: "/users/{userId}/ai/translate"
tags: ["AI"]
---

# AI Translate Strings

`POST /users/{userId}/ai/translate`

## Request

- Base URL: `https://api.crowdin.com/api/v2`
- URL: `https://api.crowdin.com/api/v2/users/{userId}/ai/translate`
- Auth: none declared
- TypeScript: <https://skmtc.dev/crowdin/apis/crowdin-api-v2/docs/users/:userId/ai/translate/post.ts> (a function with typed inputs; its response is checked against the schema)

**Required scopes:** `ai.translate` (Read and Write).

## Path parameters

- `userId` integer, required

## Request body

- union
  - AiTranslateByPromptForm
    - `strings` string[], required: Array of strings to translate (max 500 strings, each max 10000 characters)
    - `sourceLanguageId` string: Source Language Identifier. Get via [List Supported Languages](#operation/api.languages.getMany). If not specified, auto-detection will be used.
    - `targetLanguageId` string, required: Target Language Identifier. Get via [List Supported Languages](#operation/api.languages.getMany)
    - `tmIds` integer[]: Array of Translation Memory Identifiers. Get via [List TMs](#operation/api.tms.getMany)
    - `glossaryIds` integer[]: Array of Glossary Identifiers. Get via [List Glossaries](#operation/api.glossaries.getMany)
    - `styleGuideIds` integer[]: Array of Style Guide Identifiers. Get via [List Style Guides](#operation/api.style-guides.getMany)
    - `instructions` string[]: Custom instructions for translation
    - `attachmentIds` integer[]: Storage IDs of images to pass to AI as attachments (max 10). Get via [List Storages](#operation/api.storages.getMany) Only image files are allowed: * jpeg * jpg * png * gif * webp
    - `aiPromptId` integer, required: Pre-Translation Prompt Identifier. Get via [List Prompts](#operation/api.ai.prompts.getMany) __Note:__ Can't be used with `aiProviderId` or `aiModelId` in same request
  - AiTranslateByProviderModelForm
    - `strings` string[], required: Array of strings to translate (max 500 strings, each max 10000 characters)
    - `sourceLanguageId` string: Source Language Identifier. Get via [List Supported Languages](#operation/api.languages.getMany). If not specified, auto-detection will be used.
    - `targetLanguageId` string, required: Target Language Identifier. Get via [List Supported Languages](#operation/api.languages.getMany)
    - `tmIds` integer[]: Array of Translation Memory Identifiers. Get via [List TMs](#operation/api.tms.getMany)
    - `glossaryIds` integer[]: Array of Glossary Identifiers. Get via [List Glossaries](#operation/api.glossaries.getMany)
    - `styleGuideIds` integer[]: Array of Style Guide Identifiers. Get via [List Style Guides](#operation/api.style-guides.getMany)
    - `instructions` string[]: Custom instructions for translation
    - `attachmentIds` integer[]: Storage IDs of images to pass to AI as attachments (max 10). Get via [List Storages](#operation/api.storages.getMany) Only image files are allowed: * jpeg * jpg * png * gif * webp
    - `aiProviderId` integer, required: AI Provider Identifier. Get via [List AI Providers](#operation/api.ai.providers.getMany) __Note:__ Must be used together with `aiModelId`. Can't be used with `aiPromptId` in same request
    - `aiModelId` string, required: AI Model ID. Get via [List AI Provider Models](#operation/api.ai.providers.models.getMany) __Note:__ Must be used together with `aiProviderId`. Can't be used with `aiPromptId` in same request

## Response `200`

Strings translated successfully

- AiTranslateResource: Base schema of resource container. Container is a wrapper object that contains payload in required `data` property and provides space for adding any other metadata.
  - `data` AiTranslateResponseModel, required
    - `sourceLanguageId` string: Source language identifier
    - `targetLanguageId` string: Target language identifier
    - `translations` string[]: Translated strings for the target language

## Other responses

- `400`: Invalid Request Parameters
- `401`: Unauthorized
- `403`: Forbidden
- `404`: AI provider, AI prompt or user with specified id was not found
- `405`: Method Not Allowed

---

[API](https://skmtc.dev/crowdin/apis/crowdin-api-v2.md) - [All operations](https://skmtc.dev/crowdin/apis/crowdin-api-v2/llms.txt) - [OpenAPI document](https://skmtc.dev/crowdin/apis/crowdin-api-v2/revisions/27aae7751699?raw)
