> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meliai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with Meliai

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

| Approach                               | Best for                                  |
| -------------------------------------- | ----------------------------------------- |
| [OpenAI SDK](#install-the-openai-sdk)  | Existing Python or Node.js applications   |
| [HTTP API](#make-your-first-call)      | Any language with an HTTP client          |
| [Integrations](/integrations/overview) | LangChain, Vercel AI SDK, and other tools |

## Get an API key

Head to [meliai.ai/account/api/keys](https://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:

```bash theme={null}
export MELIAI_API_KEY="sk-mel-<YOUR_KEY>"
```

<Tip>
  Add that line to your shell profile (`.bashrc`, `.zshrc`, etc.) so the variable persists across sessions.
</Tip>

## Install the OpenAI SDK

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

<CodeGroup>
  ```bash Python theme={null}
  pip install openai
  ```

  ```bash Node.js theme={null}
  npm install openai
  ```
</CodeGroup>

## 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.

<CodeGroup>
  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(
      api_key=os.environ["MELIAI_API_KEY"],
      base_url="https://api.meliai.ai/v1",
  )

  response = client.chat.completions.create(
      model="<MODEL_ID>",
      messages=[{"role": "user", "content": "Name three European capitals."}],
  )
  print(response.choices[0].message.content)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.MELIAI_API_KEY,
    baseURL: "https://api.meliai.ai/v1",
  });

  const response = await client.chat.completions.create({
    model: "<MODEL_ID>",
    messages: [{ role: "user", content: "Name three European capitals." }],
  });
  console.log(response.choices[0].message.content);
  ```

  ```bash curl theme={null}
  curl https://api.meliai.ai/v1/chat/completions \
    -H "Authorization: Bearer $MELIAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "<MODEL_ID>",
      "messages": [{"role": "user", "content": "Name three European capitals."}]
    }'
  ```
</CodeGroup>

<Note>
  Replace `<MODEL_ID>` with an actual model identifier from the Meliai catalog. You can browse models at [meliai.ai/hub](https://meliai.ai/hub) or fetch them programmatically with `GET /v1/models`. Model IDs support routing suffixes such as `:speed` or `:eco` — see the [Routing](/concepts/routing) page for details.
</Note>

## Read the response

Meliai returns a standard OpenAI-shaped response body, extended with two additional top-level fields: `environment_impact` and `billing_cost`.

```json theme={null}
{
  "id": "chatcmpl-...",
  "model": "<MODEL_ID>",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Berlin, Paris, Madrid."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 8,
    "total_tokens": 22
  },
  "environment_impact": {
    "energy_kwh": 0.00015,
    "carbon_g_co2": 0.06,
    "water_liters": 0.0002,
    "renewable_percent": 85,
    "pue": 1.18,
    "provider_id": "ovhcloud",
    "location": "FR"
  },
  "billing_cost": {
    "energy": "0.0008",
    "credits": "0.0",
    "paid_with": "energy"
  }
}
```

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

<CardGroup cols={2}>
  <Card title="Routing" icon="shuffle" href="/concepts/routing">
    Use `:speed`, `:price`, `:eco`, and `:batch` suffixes to control how Meliai routes your requests across providers.
  </Card>

  <Card title="Models" icon="microchip" href="/concepts/models">
    Browse the full catalog of 60+ open-weight models and find the right one for your task.
  </Card>

  <Card title="Streaming" icon="wave-sine" href="/guides/streaming">
    Enable token-by-token streaming responses with a single extra parameter.
  </Card>

  <Card title="Migrate from OpenAI" icon="right-left" href="/get-started/from-openai">
    Already using OpenAI? See the exact two-line change needed to switch.
  </Card>
</CardGroup>
