Skip to main content
Use the OpenAI SDK or send an HTTP request to make your first Meliai API call. Choose the approach that fits your application.

Get an API key

Head to meliai.ai/account/api/keys and create a new key. Your key will look like sk-mel-.... Store it as an environment variable so you never hard-code credentials in source files:
Add that line to your shell profile (.bashrc, .zshrc, etc.) so the variable persists across sessions.

Install the OpenAI SDK

Meliai is fully compatible with the official OpenAI SDK — no separate package required.

Make your first call

Point the SDK at Meliai by setting base_url to https://api.meliai.ai/v1 and supplying your Meliai API key. Everything else stays exactly the same as any OpenAI SDK usage.
Replace <MODEL_ID> with an actual model identifier from the Meliai catalog. You can browse models at meliai.ai/hub or fetch them programmatically with GET /v1/models. Model IDs support routing suffixes such as :speed or :eco — see the Routing page for details.

Read the response

Meliai returns a standard OpenAI-shaped response body, extended with two additional top-level fields: environment_impact and billing_cost.
The environment_impact block tells you exactly how much energy, carbon, and water this specific request consumed, which EU provider served it, and what share of the facility’s power came from renewables. The billing_cost block shows the cost broken down by energy charges and any credits applied.

Where to go next

Routing

Use :speed, :price, :eco, and :batch suffixes to control how Meliai routes your requests across providers.

Models

Browse the full catalog of 60+ open-weight models and find the right one for your task.

Streaming

Enable token-by-token streaming responses with a single extra parameter.

Migrate from OpenAI

Already using OpenAI? See the exact two-line change needed to switch.