Skip to content

AI model setup

Translation is structured and instruction-following. Budget models handle it well, so you do not need a flagship model.

Pick a provider

Three paths work: local, cloud, or an aggregator.

Local: LM Studio

LM Studio runs models locally. This is ideal for development, testing, and privacy-sensitive work.

Download LM Studio, load any model that fits your hardware, and start the local server.

typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

const lmstudio = createOpenAICompatible({
  name: "lmstudio",
  baseURL: "http://127.0.0.1:1234/v1",
});

export default {
  model: lmstudio("your-model-name"),
};

Cloud: OpenAI-compatible providers

Any provider with an OpenAI-compatible endpoint works the same way: import the provider wrapper, pass a model identifier, and set your API key in the environment.

Example with OpenAI:

typescript
import { openai } from "@ai-sdk/openai";

export default {
  model: openai("your-model-name"),
};

Aggregator: OpenRouter

OpenRouter gives you one API key for many providers and a free tier. A stable free model at the time of writing is google/gemini-2.0-flash-exp:free. If it stops working, check OpenRouter's free model list and update this single reference.

typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

const openrouter = createOpenAICompatible({
  name: "openrouter",
  baseURL: "https://openrouter.ai/api/v1",
  headers: {
    "HTTP-Referer": "https://your-site.com",
    "X-Title": "your-app-name",
  },
});

export default {
  model: openrouter("google/gemini-2.0-flash-exp:free"),
};

Context window

Use a model with a minimum context window of 16,000 tokens. Every provider listed above exceeds this.

Troubleshooting

If translation fails, check:

  • The API key environment variable is set.
  • The provider's server is reachable from your machine.
  • Your model identifier matches the provider's documentation.