# Quickstart

> Get an API key, send your first request and stream the answer.

Source: https://www.lyber.ai/docs/quickstart/ · Markdown: https://www.lyber.ai/docs/md/quickstart.md

## 1. Get an API key

1. [Request access](https://www.lyber.ai/access/) with a verified email. Keys work after your account is approved.
2. Sign in and create a key under [API keys](https://www.lyber.ai/dashboard/keys/). Keys start with `lyber_prepaid_`.
3. Add prepaid credit under [Billing](https://www.lyber.ai/dashboard/billing/), with a card or crypto.

## 2. Set your environment

Keep the key out of your code. The examples in these docs read it from `LYBER_API_KEY`.

```bash
export LYBER_API_KEY="lyber_prepaid_..."
```

## 3. Send a request

Install the OpenAI SDK for your language (`pip install openai` or `npm install openai`), point it at Lyber and pick a model.

Python (`main.py`):

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://lyber-paid-acceptance-gateway-production.up.railway.app/v1",
    api_key=os.environ["LYBER_API_KEY"],
)

response = client.chat.completions.create(
    model="minimax-m3.1-flash-abliterated",
    messages=[{"role": "user", "content": "Explain abliteration in two sentences."}],
    max_tokens=1024,
)
print(response.model)
print(response.choices[0].message.content)
```

TypeScript (`main.ts`):

```ts
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://lyber-paid-acceptance-gateway-production.up.railway.app/v1",
  apiKey: process.env.LYBER_API_KEY,
});

const response = await client.chat.completions.create({
  model: "minimax-m3.1-flash-abliterated",
  messages: [{ role: "user", content: "Explain abliteration in two sentences." }],
  max_tokens: 1024,
});
console.log(response.model);
console.log(response.choices[0].message.content);
```

curl (`request.sh`):

```bash
curl https://lyber-paid-acceptance-gateway-production.up.railway.app/v1/chat/completions \
  -H "Authorization: Bearer $LYBER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax-m3.1-flash-abliterated",
    "messages": [{"role": "user", "content": "Explain abliteration in two sentences."}],
    "max_tokens": 1024
  }'
```

> **Set max_tokens:** Before a request starts, Lyber holds enough credit for the model's full context plus the output you allow. Without `max_tokens` that allowance is the model's maximum output, so the hold is larger. You are charged only for the tokens used; the rest of the hold is released. See [Spending controls](https://www.lyber.ai/docs/capabilities/spending-controls/).

## 4. Stream the answer

Add `stream: true` to receive tokens as they are generated.

Python (`main.py`):

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://lyber-paid-acceptance-gateway-production.up.railway.app/v1",
    api_key=os.environ["LYBER_API_KEY"],
)

stream = client.chat.completions.create(
    model="minimax-m3.1-flash-abliterated",
    messages=[{"role": "user", "content": "Write a haiku about open weights."}],
    max_tokens=1024,
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if chunk.usage:
        print("\n", chunk.usage)
```

TypeScript (`main.ts`):

```ts
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://lyber-paid-acceptance-gateway-production.up.railway.app/v1",
  apiKey: process.env.LYBER_API_KEY,
});

const stream = await client.chat.completions.create({
  model: "minimax-m3.1-flash-abliterated",
  messages: [{ role: "user", content: "Write a haiku about open weights." }],
  max_tokens: 1024,
  stream: true,
  stream_options: { include_usage: true },
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
  if (chunk.usage) console.log("\n", chunk.usage);
}
```

curl (`request.sh`):

```bash
curl -N https://lyber-paid-acceptance-gateway-production.up.railway.app/v1/chat/completions \
  -H "Authorization: Bearer $LYBER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax-m3.1-flash-abliterated",
    "messages": [{"role": "user", "content": "Write a haiku about open weights."}],
    "max_tokens": 1024,
    "stream": true,
    "stream_options": {"include_usage": true}
  }'
```

## Next steps

- [Thinking](https://www.lyber.ai/docs/capabilities/thinking/): Control how much the model reasons before it answers.
- [Tool calling](https://www.lyber.ai/docs/capabilities/tool-calling/): Connect the model to your own functions.
- [Coding agents](https://www.lyber.ai/docs/agents/coding-agents/): Codex, OpenCode, Crush, Continue, aider and more.
- [Limits](https://www.lyber.ai/docs/api/limits/): Rate limits, request sizes and timeouts.
