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

# Real-Time Text Translation

> Translate up to 500 characters with streaming responses and no credit charge during the preview

Translate up to **500 characters** and receive the translation as a stream of server-sent events (SSE). It does not create an order or save a translation deliverable.

<Note>
  **No Ollang credits are charged during the temporary preview.** A valid Ollang API key is required. This offer applies only to this endpoint and is not a permanent pricing commitment.
</Note>

## Authentication

<ParamField header="X-Api-Key" type="string" required>
  Your usual Ollang API key for a client account. Keep the key on your server, not in public browser code.
</ParamField>

## Request body

Send `Content-Type: application/json`.

<ParamField body="text" type="string" required>
  Source text, from 1 to 500 characters. Empty or whitespace-only text is rejected. Longer input is rejected, not truncated.
</ParamField>

<ParamField body="targetLanguage" type="string" required>
  Target language, such as `Turkish`. Must contain non-whitespace text and be 1 to 80 characters long.
</ParamField>

<ParamField body="sourceLanguage" type="string">
  Optional source language, such as `English`. Omit it to let the model detect the source language. When supplied as a string, it must contain non-whitespace text and be 1 to 80 characters long.
</ParamField>

Extra request fields are rejected.

Set `OLLANG_API_KEY` securely in your environment before running the cURL example.

<RequestExample>
  ```bash cURL wrap theme={null}
  BASE_URL='https://api-integration.ollang.com'

  curl --no-buffer --fail-with-body \
    "${BASE_URL}/integration/real-time-text-translation" \
    -H "X-Api-Key: ${OLLANG_API_KEY}" \
    -H 'Content-Type: application/json' \
    -d '{
      "text": "Hello, how are you?",
      "targetLanguage": "Turkish",
      "sourceLanguage": "English"
    }'
  ```
</RequestExample>

## Streaming response

A successful response has HTTP status `200` and content type `text/event-stream`. Read the response incrementally; it is not a single JSON document.

The following excerpts show text arriving in two events, followed by completion. Additional metadata is omitted for readability.

<ResponseExample>
  ```text SSE wrap theme={null}
  data: {"choices":[{"delta":{"content":"Merhaba, "}}]}

  data: {"choices":[{"delta":{"content":"nasılsın?"}}]}

  data: {"choices":[{"delta":{},"finish_reason":"stop"}]}

  data: [DONE]
  ```
</ResponseExample>

The assembled translation is **Merhaba, nasılsın?**

### Reading the stream

* Append each `choices[0].delta.content` string to assemble the translation. Events without text, including role, finish, and usage events, are not translation text.
* Buffer incomplete SSE events across network reads. A network chunk is not necessarily one complete event or one complete UTF-8 character.
* `[DONE]` marks the end of the stream. Usage events may precede it and report tokens, **not Ollang credit deductions**.
* Inspect `finish_reason`; a `length` finish indicates truncated output.
* A disconnect cancels the translation. If the stream ends without `[DONE]`, treat it as incomplete. Errors after streaming starts may terminate the connection rather than return a new HTTP status.

The model is instructed to return only translated text, but output quality and formatting are not guaranteed. Validate output before using it in a production workflow.

## Preview limits and errors

The preview has shared capacity limits. If you receive `429`, wait before retrying and reduce concurrent requests. Requests may time out; if the stream ends without `[DONE]`, do not treat the partial output as a complete translation.

| Status | Meaning |
| - | - |
| `400` | Invalid request body, including text longer than 500 characters. |
| `401` | Missing, expired, or unrecognized API key. |
| `403` | Your account is not permitted to access this endpoint. |
| `429` | Translation capacity or rate limit reached. Retry later. |
| `502` | Translation failed. Try again later. |
| `503` | Translation is temporarily unavailable. |
| `504` | Translation timed out before the stream started. |

Existing account access restrictions still apply during the no-credit-charge preview.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.