---
title: Quickstart
description: Create an API key, make your first request with the SDK you already use, and check what it cost.
---

You need an account and an API key. Post about Lovely Router on X to get $2 of free credit, enough for hundreds of requests to a small model ([how](/docs/account/billing#free-credit)).

:::steps
### Create an API key

[Sign up](/signup), then open [API keys](/app/keys) in the dashboard and click **New key**. Copy the key right away: it starts with `lr-` and is shown only once.

Store it in an environment variable so it stays out of your code:

```bash
export LOVELY_API_KEY="lr-..."
```

### Send your first request

Lovely Router speaks the Anthropic, OpenAI and Gemini APIs natively. Pick the one your code already uses and change only the base URL and the key.

```bash title="cURL"
curl https://lovelyrouter.com/v1/chat/completions \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "gpt-6.1-sol",
    "messages": [{"role": "user", "content": "Write a haiku about routers."}]
  }'
```

```python title="Python"
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://lovelyrouter.com/v1",
    api_key=os.environ["LOVELY_API_KEY"],
)
response = client.chat.completions.create(
    model="gpt-6.1-sol",
    messages=[{"role": "user", "content": "Write a haiku about routers."}],
)
print(response.choices[0].message.content)
```

```js title="Node.js"
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://lovelyrouter.com/v1',
  apiKey: process.env.LOVELY_API_KEY,
});
const response = await client.chat.completions.create({
  model: 'gpt-6.1-sol',
  messages: [{ role: 'user', content: 'Write a haiku about routers.' }],
});
console.log(response.choices[0].message.content);
```

The same key works for every model. To call Claude with the Anthropic SDK or Gemini with the Google SDK, see [Anthropic Messages](/docs/models/anthropic) and [Gemini](/docs/models/gemini).

### Stream the response

Add `stream: true` to get tokens as they are generated. Streaming works the same way it does with the vendor's own API.

```bash title="cURL"
curl -N https://lovelyrouter.com/v1/chat/completions \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/json" \
  -d '{"model": "gpt-6.1-sol", "stream": true,
       "messages": [{"role": "user", "content": "Count to ten, slowly."}]}'
```

```python title="Python"
stream = client.chat.completions.create(
    model="gpt-6.1-sol",
    messages=[{"role": "user", "content": "Count to ten, slowly."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

```js title="Node.js"
const stream = await client.chat.completions.create({
  model: 'gpt-6.1-sol',
  messages: [{ role: 'user', content: 'Count to ten, slowly.' }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}
```

### Check the cost

Every request appears in [Logs](/app/logs) within a few seconds, with its tokens, charge, time to first token and throughput. Each response also carries an `x-lovely-request-id` header. Include it when you contact support about a specific call.
:::

## Pick a model

Call `GET /v1/models` for the live list with context sizes and prices, or browse the [marketplace](/models). Model ids are forgiving: `claude-sonnet-5.5`, `claude-sonnet-5-5` and `anthropic/claude-sonnet-5.5` all resolve to the same model.

```bash title="cURL"
curl https://lovelyrouter.com/v1/models
```

## Next steps

:::cards
- :plug: [Use with your tools](/docs/integrations) Set up Claude Code, Codex CLI, Gemini CLI or a desktop chat app.
- :layers: [Prompt caching](/docs/models/caching) Keep long system prompts cheap across turns.
- :key: [API keys](/docs/account/api-keys) Limit a key to some models, cap its spend, or give it an expiry date.
- :tool: [Data tools](/docs/tools) Give your agent search and scraping with the same key.
:::
