# Quickstart

A key, some API credit and your first request, in a few minutes. You need an MLX Wallet with some USDC.

:::steps
### Sign in to the console
Open the [console](/console) and sign in with your wallet's passkey or recovery phrase. It's the same MLX Wallet you use at wallet.mlx.app.

### Add API credit
Choose **Add credit** and an amount (at least 1 USDC, at most 1,000 USDC in the pilot). Your wallet signs an `api_fund` transaction that moves the USDC into `api.mlx`, where it's held for your requests. $0.02 per million tokens means 1 USDC covers about 50 million tokens.

### Create a key
Choose **Create key** and copy the key it shows. It starts with `sk-mlx-` and is shown only once: the network keeps only its hash.

### Send a request
Point any OpenAI client at `https://api.mlx.app/v1` and send a chat completion.
:::

```bash tab=curl
curl https://api.mlx.app/v1/chat/completions \
  -H "Authorization: Bearer $MLX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen2.5-0.5b-instruct",
    "messages": [{"role": "user", "content": "Classify the sentiment of: The battery lasts all day. Answer positive, negative or neutral."}],
    "max_tokens": 8
  }'
```

```python tab=Python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.mlx.app/v1", api_key=os.environ["MLX_API_KEY"])
r = client.chat.completions.create(
    model="qwen2.5-0.5b-instruct",
    messages=[{"role": "user", "content": "Classify the sentiment of: The battery lasts all day. Answer positive, negative or neutral."}],
    max_tokens=8,
)
print(r.choices[0].message.content, r.model_extra["mlx"]["verified"])
```

```js tab=JavaScript
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.mlx.app/v1", apiKey: process.env.MLX_API_KEY });
const r = await client.chat.completions.create({
  model: "qwen2.5-0.5b-instruct",
  messages: [{ role: "user", content: "Classify the sentiment of: The battery lasts all day. Answer positive, negative or neutral." }],
  max_tokens: 8
});
console.log(r.choices[0].message.content, r.mlx.verified);
```

The reply is OpenAI's, with one extra object:

```json
{
  "id": "chatcmpl-5f1c0a9e3b2d47a1c8",
  "object": "chat.completion",
  "model": "qwen2.5-0.5b-instruct",
  "choices": [{ "index": 0, "message": { "role": "assistant", "content": "positive" }, "finish_reason": "stop" }],
  "usage": { "prompt_tokens": 41, "completion_tokens": 2, "total_tokens": 43 },
  "mlx": { "verified": true, "macs": 2, "gpu_group": "m5", "cost_usd": 0.00000086, "ms": 2140 }
}
```

`mlx.verified: true` means two Macs of different wallets gave exactly this answer. Check your credit and recent requests in the [console](/console), or with `GET /v1/account` and your key.

> [!TIP]
> Batch work goes fastest with several requests at once: up to 8 in flight per wallet, 60 a minute per key.
