> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elanlanguages.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Text Processing

> On this page, we'll dive into the direct text translation, revision, and rewriting endpoints for real-time text processing.

Direct text processing endpoints allow you to translate, revise, and rewrite text synchronously without creating background jobs. These endpoints return results immediately, making them ideal for real-time applications. Streaming variants are available for translate and rewrite, delivering results via Server-Sent Events.

## Translate text

**`POST /v1/text/translate`**

This endpoint allows you to translate text directly using AI. It accepts a list of source texts and returns a corresponding list of translations.

### Required attributes

<ParamField body="source_text" type="array of strings" required>
  List of texts to translate.
</ParamField>

<ParamField body="source_language" type="string" required>
  The source language code (e.g., "en").
</ParamField>

<ParamField body="target_language" type="string" required>
  The target language code (e.g., "de").
</ParamField>

### Optional attributes

<ParamField body="domain" type="string">
  Content domain for the translation (e.g., "technical", "legal", "marketing").
</ParamField>

<ParamField body="provider" type="string">
  The AI provider to use: `openai`, `anthropic`, `mistral`, `gemini`, `lara`, `widn` (default: `openai`).
</ParamField>

<ParamField body="context_window" type="integer">
  Processing mode (1=full\_document, 2=bucketing, 3=segment\_per\_segment, default: 3).
</ParamField>

<ParamField body="glossaries" type="array of integers">
  List of glossary IDs to use for terminology consistency.
</ParamField>

<ParamField body="context_stores" type="array of integers">
  Context store IDs for styleguide content.
</ParamField>

<ParamField body="instructions" type="string">
  Additional instructions for the translation.
</ParamField>

<ParamField body="extra_instructions" type="array of strings">
  Additional instructions passed to the translation provider.
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.elanlanguages.ai/v1/text/translate \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    -H "Content-Type: application/json" \
    -d '{
      "source_text": ["Welcome to our product documentation."],
      "source_language": "en",
      "target_language": "de",
      "domain": "technical",
      "glossaries": [1]
    }'
  ```
</CodeGroup>

```json Response theme={null}
{
  "status": "success",
  "source_text": ["Welcome to our product documentation."],
  "translated_text": ["Willkommen in unserer Produktdokumentation."],
  "source_language": "en",
  "target_language": "de",
  "provider": "openai",
  "domain": "technical",
  "context_window": 3,
  "processing_mode": "direct"
}
```

***

## Stream translate text

**`POST /v1/text/translate/stream`**

This endpoint streams translated text via Server-Sent Events. It accepts the same request body as the synchronous translate endpoint but streams the translation of the first text in the `source_text` list.

The stream emits three event types:

* **delta** — A chunk of translated text: `{"text": "..."}`
* **done** — The final result with metadata: `{"text": "...", "source_language": "...", ...}`
* **error** — An error occurred: `{"error": "...", "status": 402|400|500}`

### Required attributes

<ParamField body="source_text" type="array of strings" required>
  List of texts to translate. The stream translates the first item.
</ParamField>

<ParamField body="source_language" type="string" required>
  The source language code (e.g., "en").
</ParamField>

<ParamField body="target_language" type="string" required>
  The target language code (e.g., "de").
</ParamField>

### Optional attributes

<ParamField body="domain" type="string">
  Content domain for the translation (e.g., "technical", "legal", "marketing").
</ParamField>

<ParamField body="provider" type="string">
  The AI provider to use: `openai`, `anthropic`, `mistral`, `gemini`, `lara`, `widn` (default: `openai`).
</ParamField>

<ParamField body="context_window" type="integer">
  Processing mode (1=full\_document, 2=bucketing, 3=segment\_per\_segment, default: 3).
</ParamField>

<ParamField body="glossaries" type="array of integers">
  List of glossary IDs to use for terminology consistency.
</ParamField>

<ParamField body="context_stores" type="array of integers">
  Context store IDs for styleguide content.
</ParamField>

<ParamField body="instructions" type="string">
  Additional instructions for the translation.
</ParamField>

<ParamField body="extra_instructions" type="array of strings">
  Additional instructions passed to the translation provider.
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -N -X POST https://api.elanlanguages.ai/v1/text/translate/stream \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    -H "Content-Type: application/json" \
    -d '{
      "source_text": ["Welcome to our product documentation."],
      "source_language": "en",
      "target_language": "de"
    }'
  ```
</CodeGroup>

```txt Response (SSE) theme={null}
event: delta
data: {"text": "Willkommen"}

event: delta
data: {"text": " in unserer"}

event: delta
data: {"text": " Produktdokumentation."}

event: done
data: {"text": "Willkommen in unserer Produktdokumentation.", "source_language": "en", "target_language": "de"}
```

***

## Revise text

**`POST /v1/text/revise`**

This endpoint allows you to revise translated text directly using AI post-editing. It provides synchronous text revision without TMS integration, using the same post-editing adapters and processing logic as the AIPE handler.

### Required attributes

<ParamField body="source_text" type="string" required>
  The original source text.
</ParamField>

<ParamField body="target_text" type="string" required>
  The existing translation to revise.
</ParamField>

<ParamField body="source_language" type="string" required>
  The source language code (e.g., "en").
</ParamField>

<ParamField body="target_language" type="string" required>
  The target language code (e.g., "de").
</ParamField>

### Optional attributes

<ParamField body="domain" type="string">
  Content domain for the revision (e.g., "technical", "legal", "marketing").
</ParamField>

<ParamField body="provider" type="string">
  The AI provider to use: `openai`, `anthropic`, `mistral`, `gemini` (default: `openai`).
</ParamField>

<ParamField body="context_window" type="integer">
  Processing mode (1=full\_document, 2=bucketing, 3=segment\_per\_segment, default: 3).
</ParamField>

<ParamField body="glossaries" type="array of integers">
  List of glossary IDs to use for terminology consistency.
</ParamField>

<ParamField body="context_stores" type="array of integers">
  Context store IDs for styleguide content.
</ParamField>

<ParamField body="instructions" type="string">
  Additional instructions for the revision.
</ParamField>

<ParamField body="styleguide" type="string">
  Direct styleguide text to follow for the revision. Used if `context_stores` is not provided.
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.elanlanguages.ai/v1/text/revise \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    -H "Content-Type: application/json" \
    -d '{
      "source_text": "Welcome to our product documentation.",
      "target_text": "Wilkommen zu unsere Produktdokumentation.",
      "source_language": "en",
      "target_language": "de",
      "domain": "technical"
    }'
  ```
</CodeGroup>

```json Response theme={null}
{
  "status": "success",
  "source_text": "Welcome to our product documentation.",
  "original_target_text": "Wilkommen zu unsere Produktdokumentation.",
  "revised_text": "Willkommen in unserer Produktdokumentation.",
  "source_language": "en",
  "target_language": "de",
  "provider": "openai",
  "domain": "technical",
  "context_window": 3,
  "processing_mode": "direct"
}
```

***

## Rewrite text

**`POST /v1/text/rewrite`**

This endpoint allows you to rewrite text using AI. You specify a rewrite type to control how the text is transformed — for example, simplifying complex language, summarizing long passages, or elaborating on brief content.

### Required attributes

<ParamField body="source_text" type="string" required>
  The text to rewrite.
</ParamField>

<ParamField body="source_language" type="string" required>
  The language code of the text (e.g., "en").
</ParamField>

<ParamField body="type" type="string" required>
  The rewrite type. One of: `simplify`, `summarize`, `elaborate`, `continue`, `align`.
</ParamField>

### Optional attributes

<ParamField body="domain" type="string">
  Content domain for the rewrite (e.g., "technical", "legal", "marketing").
</ParamField>

<ParamField body="glossaries" type="array of integers">
  List of glossary IDs to use for terminology consistency.
</ParamField>

<ParamField body="context_stores" type="array of integers">
  Context store IDs for styleguide content.
</ParamField>

<ParamField body="instructions" type="string">
  Additional rewriting instructions.
</ParamField>

<ParamField body="template" type="integer">
  Explicit prompt template ID override.
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.elanlanguages.ai/v1/text/rewrite \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    -H "Content-Type: application/json" \
    -d '{
      "source_text": "The implementation of the aforementioned functionality necessitates the utilization of advanced computational paradigms.",
      "type": "simplify",
      "source_language": "en"
    }'
  ```
</CodeGroup>

```json Response theme={null}
{
  "status": "success",
  "source_text": "The implementation of the aforementioned functionality necessitates the utilization of advanced computational paradigms.",
  "rewritten_text": "Building this feature requires advanced computing techniques.",
  "source_language": "en",
  "domain": null,
  "type": "simplify",
  "template": null
}
```

***

## Stream rewrite text

**`POST /v1/text/rewrite/stream`**

This endpoint streams rewritten text via Server-Sent Events. It accepts the same request body as the synchronous rewrite endpoint but delivers results incrementally as they are generated.

The stream emits three event types:

* **delta** — A chunk of rewritten text: `{"text": "..."}`
* **done** — The final result with metadata: `{"text": "...", "source_language": "...", ...}`
* **error** — An error occurred: `{"error": "...", "status": 402|400|500}`

### Required attributes

<ParamField body="source_text" type="string" required>
  The text to rewrite.
</ParamField>

<ParamField body="source_language" type="string" required>
  The language code of the text (e.g., "en").
</ParamField>

<ParamField body="type" type="string" required>
  The rewrite type. One of: `simplify`, `summarize`, `elaborate`, `continue`, `align`.
</ParamField>

### Optional attributes

<ParamField body="domain" type="string">
  Content domain for the rewrite (e.g., "technical", "legal", "marketing").
</ParamField>

<ParamField body="glossaries" type="array of integers">
  List of glossary IDs to use for terminology consistency.
</ParamField>

<ParamField body="context_stores" type="array of integers">
  Context store IDs for styleguide content.
</ParamField>

<ParamField body="instructions" type="string">
  Additional rewriting instructions.
</ParamField>

<ParamField body="template" type="integer">
  Explicit prompt template ID override.
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -N -X POST https://api.elanlanguages.ai/v1/text/rewrite/stream \
    -H "Authorization: Bearer {token}" \
    -H "X-Org-Id: {orgId}" \
    -H "Content-Type: application/json" \
    -d '{
      "source_text": "The implementation of the aforementioned functionality necessitates the utilization of advanced computational paradigms.",
      "type": "simplify",
      "source_language": "en"
    }'
  ```
</CodeGroup>

```txt Response (SSE) theme={null}
event: delta
data: {"text": "Building this"}

event: delta
data: {"text": " feature requires"}

event: delta
data: {"text": " advanced computing techniques."}

event: done
data: {"text": "Building this feature requires advanced computing techniques.", "source_language": "en", "type": "simplify"}
```
