DEV Community

APIVAI
APIVAI

Posted on • Originally published at apivai.com

How to Batch-Translate Thousands of Items with a Cheap API

Batch-translate thousands of items with a cheap API

When you need to translate a whole catalog, a spreadsheet of messages, or a backlog of documents,
you want a fast, low-cost API and a simple loop with some concurrency. APIVAI fits: it's
OpenAI-compatible, GPT-5.5 is fast and fluent for translation, and the per-token price is a fraction
of list — which matters at thousands of items.

The approach

  1. Read your items (CSV/JSON/DB).
  2. Translate each with GPT-5.5 over the OpenAI-compatible endpoint, a few in parallel.
  3. Write the results back.

Code (Python, with concurrency)

import os, asyncio
from openai import AsyncOpenAI

ai = AsyncOpenAI(api_key=os.environ["APIVAI_API_KEY"], base_url="https://api.apivai.com/v1")
SEM = asyncio.Semaphore(5)  # limit concurrency to be gentle on rate limits

async def translate(text, target="Spanish"):
    async with SEM:
        r = await ai.chat.completions.create(
            model="gpt-5.5",
            messages=[
                {"role": "system", "content": f"Translate to {target}. Output only the translation, preserve meaning and any product specs."},
                {"role": "user", "content": text},
            ],
            temperature=0.2,
        )
        return r.choices[0].message.content.strip()

async def main(items, target="Spanish"):
    return await asyncio.gather(*(translate(t, target) for t in items))

# items = [...]  # your strings
# results = asyncio.run(main(items))
Enter fullscreen mode Exit fullscreen mode

Tips for large batches

  • Concurrency: 3–8 parallel requests is usually a good balance; back off on 429s.
  • Retries: wrap calls with exponential backoff for transient errors.
  • Glossary: include key terms in the system prompt to lock terminology across the batch.
  • Cost control: keep prompts tight; a smaller model can do a first pass, GPT-5.5 for the rest.
  • Idempotency: record which items succeeded so a re-run only does the remainder.

Use cases

  • Localize an e-commerce catalog (titles, descriptions) for a new market.
  • Translate a backlog of support messages or reviews.
  • Pre-translate UI strings or knowledge-base articles.

FAQ

What's the cheapest way to batch-translate? A fast model (GPT-5.5) over a discounted
OpenAI-compatible gateway like APIVAI, with light concurrency — far cheaper than official list at
volume.

Which model for bulk translation? GPT-5.5 for quality; a smaller model for a cheap first pass.

How do I avoid rate limits? Limit concurrency (a semaphore) and retry 429s with backoff.

Can I pay without a card? Yes — APIVAI takes crypto, USDT, and Alipay.

Get started

Get an APIVAI key and run the concurrent loop above over your items. Examples:
APIVAI examples repo.

Top comments (0)