# Quickstart

> Create a key and send a first request in a few minutes.

## Create a key

Open [API keys](https://deference.si/keys) and select **Create key**. Name it after what will use it, and copy the key when it appears: it is shown once.

New accounts get up to $2.50 of [free credit](https://deference.si/docs/concepts/free-credit) for open-weight text models, like the one below. For any other model, [add credit](https://deference.si/wallet?tab=add) with USDC or INFERENCE.

## Set the key

**macOS and Linux**

```bash
export DEFERENCE_API_KEY="sk-df-..."
```

**Windows**

```powershell
$env:DEFERENCE_API_KEY = "sk-df-..."
```

## Send a request

**curl**

```bash
curl https://deference.si/v1/chat/completions \
  -H "Authorization: Bearer $DEFERENCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v3.2",
    "messages": [{ "role": "user", "content": "Say hello in one sentence." }],
    "max_tokens": 100
  }'
```

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://deference.si/v1",
    api_key=os.environ["DEFERENCE_API_KEY"],
)

response = client.chat.completions.create(
    model="deepseek/deepseek-v3.2",
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
    max_tokens=100,
)
print(response.choices[0].message.content)
```

**TypeScript**

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://deference.si/v1",
  apiKey: process.env.DEFERENCE_API_KEY,
});

const response = await client.chat.completions.create({
  model: "deepseek/deepseek-v3.2",
  messages: [{ role: "user", content: "Say hello in one sentence." }],
  max_tokens: 100,
});
console.log(response.choices[0].message.content);
```

Swap `model` for any id from [Models](https://deference.si/models). Models that are not open-weight need credit.

## Check it in Activity

Open [Activity](https://deference.si/activity). The request is the top row, with its model, tokens and cost. The cost reads "estimating" for a few seconds, then shows the final amount. A request rejected with a 401, 402, 404 or 429 does not appear there.

**If it fails**

| You see                        | Cause                                                                        | Fix                                                                                             |
| ------------------------------ | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `401 missing_api_key`          | The variable is empty, so no key was sent                                    | Set the variable in the shell that runs the code                                                |
| `401 invalid_api_key`          | The key is mistyped                                                          | Set the variable again from your saved key, or create a replacement. Keep the value out of logs |
| `402 insufficient_credit`      | The account has no available credit                                          | [Add credit](https://deference.si/wallet?tab=add)                                                                   |
| `402 free_credit_not_eligible` | The account has only free credit, and this model or request does not qualify | Use an open-weight text model, or set a lower `max_tokens`                                      |
| `404 model_not_found`          | The model id is not in the catalog                                           | Copy an id from the Models page                                                                 |
| `429 rate_limited`             | Too many requests in a minute                                                | Wait for the `retry-after` seconds                                                              |

## Set up a tool

Point your coding tool at Deference next. Every guide is in [Coding tools](https://deference.si/docs/coding-tools).

* [Claude Code](https://deference.si/docs/coding-tools/claude-code) (Messages)
* [Codex](https://deference.si/docs/coding-tools/codex-cli) (Responses)
* [Cursor](https://deference.si/docs/coding-tools/cursor) (Chat Completions, beta)

Writing code instead? See [what your key can do](https://deference.si/docs/what-you-can-do).
