# For AI agents

A compact reference for coding agents and LLMs that write VibeQL integrations, with correct calls, polling and retry rules.

This page is for coding agents and LLMs that write code against VibeQL. It lists the facts and rules in short form.

## Facts

- Base URL: `https://vibeql.com`. There is no separate free or test host.
- Auth header: `Authorization: DeepL-Auth-Key $VIBEQL_API_KEY`. `Authorization: Bearer $VIBEQL_API_KEY` also works.
- Key format: `vql_` followed by 40 letters and digits. Read it from the `VIBEQL_API_KEY` environment variable. Never hard-code it or send it to a browser.
- Formats: DOCX, PPTX, PDF, TXT. The output format equals the input format.
- Languages: 34 target codes, such as `DE`, `PT-BR`, `EN-US`, `ZH-HANS`. `EN` means `EN-US`, `PT` means `PT-PT`, `ZH` means `ZH-HANS`. Full list: [Languages](/docs/languages).
- Usage counts source characters. There is no minimum per document.
- Not supported: glossaries, formality, OCR for scanned PDFs. Do not generate code that depends on them.

## Pick an API shape

| Situation | Use |
|---|---|
| New code | DeepL v2: `/v2/translate`, `/v2/document` |
| Code that uses a DeepL client library | DeepL v2. Set the server URL to `https://vibeql.com`. |
| Code that calls Google Translate v2 | `https://vibeql.com/language/translate/v2` |
| Code that calls Azure Translator v3 | `https://vibeql.com` with `api-version=3.0` |
| An agent that has MCP tools | `https://vibeql.com/mcp` |

## Translate text

```bash
curl https://vibeql.com/v2/translate \
  -H "Authorization: DeepL-Auth-Key $VIBEQL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": ["Hello", "Goodbye"], "target_lang": "DE", "source_lang": "EN"}'
```

Response: `{"translations": [{"detected_source_language": "EN", "text": "Hallo"}, ...]}`, one item for each input, same order. Up to 50 `text` values and 128 KB per request. Split larger inputs into batches.

## Translate a document

1. `POST /v2/document`, multipart, fields `file` and `target_lang`. Returns `document_id` and `document_key`.
2. `POST /v2/document/{document_id}` with `document_key`. Returns `status`: `queued`, `translating`, `done` or `error`.
3. When `status` is `done`, `POST /v2/document/{document_id}/result` with `document_key`. The response body is the file.

Polling loop with backoff:

```python
import os, random, time, requests

BASE = "https://vibeql.com"
H = {"Authorization": f"DeepL-Auth-Key {os.environ['VIBEQL_API_KEY']}"}

def translate_file(path: str, out_path: str, target: str, timeout_s: int = 1800) -> None:
    with open(path, "rb") as f:
        r = requests.post(f"{BASE}/v2/document", headers=H, files={"file": f},
                          data={"target_lang": target}, timeout=120)
    r.raise_for_status()
    doc = r.json()
    key = {"document_key": doc["document_key"]}

    delay, deadline = 2.0, time.monotonic() + timeout_s
    while time.monotonic() < deadline:
        s = requests.post(f"{BASE}/v2/document/{doc['document_id']}", headers=H, data=key, timeout=30)
        s.raise_for_status()
        state = s.json()
        if state["status"] == "done":
            break
        if state["status"] == "error":
            raise RuntimeError(state.get("error_message", "Translation failed"))
        time.sleep(delay + random.uniform(0, 1))
        delay = min(delay * 1.5, 30)
    else:
        raise TimeoutError("Document not done in time")

    out = requests.post(f"{BASE}/v2/document/{doc['document_id']}/result", headers=H, data=key, timeout=120)
    out.raise_for_status()
    with open(out_path, "wb") as f:
        f.write(out.content)
```

Files are deleted 24 hours after upload. Download the result before then.

## Errors and retries

| Status | Retry? | Action |
|---|---|---|
| `400` | No | Fix the parameters. Read `message`. |
| `403` | No | The key is wrong, missing or revoked. |
| `404` | No | Wrong document ID or key, or the file expired. |
| `413` | No | The file or request is too large. Split it or use a smaller file. |
| `456` | No | The monthly plan limit is reached. Stop and tell the user. |
| `429` | Yes | Exponential backoff with jitter. |
| `500`, `502`, `504` | Yes | Exponential backoff with jitter, a few times. |
| `503` | Yes | On `/result`: the document is not done. Poll the status again. |

DeepL endpoints return errors as `{"message": "..."}`. Google and Azure endpoints use their own error formats. See [Limits and errors](/docs/limits-and-errors).

## File size limits

| Plan | Max file size |
|---|---|
| Free | 10 MB, 10 pages |
| Beta | 20 MB, 300 pages |
| Paid plans | 50 MB |

See [Limits and errors](/docs/limits-and-errors) for all plan limits.

## MCP tool order

Server: `https://vibeql.com/mcp`, streamable HTTP, `Authorization: Bearer <key>`.

1. `translate_document` with `target_lang` and either `file_url`, or `file_base64` plus `filename`. It returns a document `id` and a status.
2. `get_document` with that `id`. Repeat, with a pause between calls, until the status is `done` or `error`.
3. Give the user the `download_url`. It is valid for 24 hours.

For short strings, call `translate_text`. Call `list_languages` to check a code and `get_usage` to check the remaining characters. Setup: [MCP setup](/docs/mcp-setup).

## Docs as plain text

- [/llms.txt](/llms.txt): an index of the docs.
- [/llms-full.txt](/llms-full.txt): all docs in one file.
- Add `.md` to any docs URL to get the page as Markdown. Examples: `/docs.md`, `/docs/quickstart.md`, `/docs/for-ai-agents.md`.
