# POST /translate: $0.01 per call

Translate text between 100+ languages with AI. POST JSON {"text": "...", "target": "French"} (language name or code such as fr, de, es, ja, zh, ar). Optional "source" language, otherwise it is detected. Up to about 12,000 characters of English (4,000 of Chinese/Japanese) per call. Keeps formatting such as Markdown and line breaks. Failed calls are not charged.

- **Price:** $0.01 in USDC, the same on Base, Solana, Polygon, Arbitrum. Failed calls are never charged.
- **Free trial:** no, paid only (it uses a paid AI model or data source, or costs more than the trial covers). Other ways to pay: x402 or [prepaid credits](/credits).
- **Answers cached for:** 1 day(s)
- **Data sources:** Workers AI (metered)
- **Lane:** LLM gateway ([OpenAPI](/openapi/llm.json))
- **Live health:** [status page](/status)

## Free sample

See an answer for the demo input first, free (no payment, 10 a minute): [https://aayatai.com/sample/translate](/sample/translate). It is a stored real answer when we have one, otherwise an example marked `"kind": "illustrative"`.

```bash
curl "https://aayatai.com/sample/translate"
```

## 1. See the price (free)

Call it without paying: you get `402 Payment Required` and a `PAYMENT-REQUIRED` header with the exact price and where to pay.

```bash
curl -i -X POST https://aayatai.com/translate -H "content-type: application/json" -d '{"text":"Hello, how are you?","target":"es"}'
```

## 2. Pay and call (TypeScript)

```bash
npm install @x402/fetch @x402/evm viem
```

```ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A wallet used only by your agent, holding a little USDC on Base.
const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await pay("https://aayatai.com/translate", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"text":"Hello, how are you?","target":"es"}),
});
console.log(await res.json());
```

## 3. Or as an MCP tool

```ts
// MCP server: https://aayatai.com/mcp (Streamable HTTP). With the x402 MCP client (see /start):
const result = await client.callTool("translate", {"text":"Hello, how are you?","target":"es"});
```

## Inputs

- `text` **(required)** (string): Text to translate.
- `target` **(required)** (string): Language to translate into, e.g. French or fr.
- `source` (string): Language of the text. Default: detect automatically.

Bad inputs are rejected with HTTP 400 before any payment is asked for.

## Example answer

```json
{
  "translation": "Hola, ¿cómo estás?",
  "target": "es",
  "source": "auto",
  "chars": 19,
  "model": "@cf/mistralai/mistral-small-3.1-24b-instruct"
}
```

## Related

- [POST /chat/fast](/services/chat-fast) ($0.003): Pay-per-call LLM chat (Llama 3.2 3B): Fast, cheap model for classification, extraction, short answers and routing.
- [POST /chat](/services/chat) ($0.01): Pay-per-call LLM chat (Mistral Small 3.1 24B): Balanced multilingual model (140+ languages) for writing, reasoning and long inputs.
- [POST /chat/premium](/services/chat-premium) ($0.03): Pay-per-call LLM chat (Llama 3.3 70B): Strongest model for harder reasoning, coding and careful writing; supports JSON output.
- [POST /embeddings](/services/embeddings) ($0.002): Text embeddings for semantic search, clustering and RAG: 1024-dimension multilingual vectors (BGE-M3, 100+ languages).
- [POST /summarise](/services/summarise) ($0.02): Summarise text or any public web page with AI.

New here? [Getting started in 60 seconds](/start). All services: [Aayat AI](/).