Skip to main content
Meliai implements the OpenAI API shape exactly — the same request fields, the same response structure, the same streaming format, and the same SDK interfaces. Migrating means changing two values: your API key and the base_url. Every other line of your existing code stays untouched.
1

Get a Meliai API key

Create a key at meliai.ai/account/api/keys. It will be formatted as sk-mel-<KEY>.Store it in your environment alongside (or instead of) your existing OpenAI key:
If some services in your stack still need the OpenAI key, keep both environment variables. You can reference OPENAI_API_KEY for those services and MELIAI_API_KEY for Meliai-routed calls.
2

Update base_url and api_key

Open the file where you initialise your OpenAI client and make the following two-line change:
For Node.js projects the change is identical in shape:
That is the complete migration for SDK-based code. No other changes are required.
3

Pick a model

OpenAI model names (e.g. gpt-4o, gpt-3.5-turbo) don’t map 1:1 to Meliai model IDs, because Meliai routes exclusively to open-weight models. Browse equivalent models by capability at meliai.ai/hub, or list them programmatically:
Substitute the model ID you choose into your model field:
4

Optionally add a routing suffix

Meliai lets you influence how your request is routed across EU providers by appending a suffix to the model ID. No code changes beyond the suffix are needed.
See the Routing page for the full details.
All OpenAI SDK features work identically through Meliai: streaming (stream=True), tool calling, vision (image inputs), structured output (response_format), and logprobs. You do not need to change any feature-specific code.

What you gain after migrating

Switching to Meliai gives you everything your existing OpenAI code already produces, plus:
  • EU data residency — requests are routed only to providers inside the European Union.
  • GDPR compliance — your data is never used for model training.
  • Environmental telemetry — every response carries an environment_impact block with energy, carbon, water, and renewable-percentage figures for that specific call.
  • Auto-failover — if one EU provider is unavailable, Meliai automatically retries on another, with no change to your code.