Get started

# Quickstart

Three steps: create a key, add credit, call a model. No email and no password. You can also do all of this in the [console](https://inference.dagon.so/app/).

**On this page**

- [1. Create a key](https://inference.dagon.so/docs/quickstart#1-create-a-key)
- [2. Add credit](https://inference.dagon.so/docs/quickstart#2-add-credit)
- [3. Call a model](https://inference.dagon.so/docs/quickstart#3-call-a-model)
- [4. Check the balance](https://inference.dagon.so/docs/quickstart#4-check-the-balance)

## 1. Create a key

**curl**

```curl
curl -X POST https://inference.dagon.so/v1/keys
```

**Python**

```python
import requests

r = requests.post("https://inference.dagon.so/v1/keys", json={"name": "my app"})
print(r.json()["key"])  # gk_..., shown once
```

**TypeScript**

```ts
const r = await fetch("https://inference.dagon.so/v1/keys", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ name: "my app" }),
});
const { key } = await r.json(); // gk_..., shown once
```

The answer is `201` with `key` (the secret) and `data` (the key's id, name and balances in micro-USD). `name` is optional, at most 80 characters.

Save the key now

The secret is shown once. The gateway stores only a hash, so a lost key cannot be shown again or recovered, and its balance is lost with it. Keys minted under a [passkey account](https://inference.dagon.so/docs/passkeys) can be deleted and replaced.

## 2. Add credit

Open a hosted USDC checkout for $5 to $1,000, in whole cents:

**curl**

```curl
curl https://inference.dagon.so/v1/credits/checkout \
  -H "Authorization: Bearer $DAGON_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount_usd": 20}'
```

**Python**

```python
import os, requests

r = requests.post(
    "https://inference.dagon.so/v1/credits/checkout",
    headers={"Authorization": f"Bearer {os.environ['DAGON_KEY']}"},
    json={"amount_usd": 20},
)
print(r.json()["url"])  # open it and pay in USDC
```

**TypeScript**

```ts
const r = await fetch("https://inference.dagon.so/v1/credits/checkout", {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.DAGON_KEY}`, "content-type": "application/json" },
  body: JSON.stringify({ amount_usd: 20 }),
});
const { url } = await r.json(); // open it and pay in USDC
```

The answer is `{"session_id", "url"}`. Pay on the page at `https://pay.dagon.so`; the credit posts once the payment is final. An agent with a Solana wallet can instead [buy credits without a browser](https://inference.dagon.so/docs/wallet-purchase), or skip the key and [pay per request with x402](https://inference.dagon.so/docs/x402).

## 3. Call a model

**curl**

```curl
curl https://inference.dagon.so/v1/chat/completions \
  -H "Authorization: Bearer $DAGON_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "abliterated-model-large-flash",
    "messages": [{"role": "user", "content": "Explain this stack trace."}],
    "max_tokens": 1024
  }'
```

**Python**

```python
# pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="https://inference.dagon.so/v1", api_key=os.environ["DAGON_KEY"])

reply = client.chat.completions.create(
    model="abliterated-model-large-flash",
    messages=[{"role": "user", "content": "Explain this stack trace."}],
    max_tokens=1024,
)
print(reply.choices[0].message.content)
```

**TypeScript**

```ts
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://inference.dagon.so/v1", apiKey: process.env.DAGON_KEY });

const reply = await client.chat.completions.create({
  model: "abliterated-model-large-flash",
  messages: [{ role: "user", content: "Explain this stack trace." }],
  max_tokens: 1024,
});
console.log(reply.choices[0].message.content);
```

Any listed model id works; see [Models and pricing](https://inference.dagon.so/docs/models). The response is the provider's OpenAI-format answer, with `x-gateway-request-id` and `x-gateway-receipt-id` headers added.

## 4. Check the balance

**curl**

```curl
curl https://inference.dagon.so/v1/credits -H "Authorization: Bearer $DAGON_KEY"
```

**Python**

```python
r = requests.get("https://inference.dagon.so/v1/credits", headers={"Authorization": f"Bearer {os.environ['DAGON_KEY']}"})
print(r.json()["data"])  # total_credits, total_usage, available (USD)
```

**TypeScript**

```ts
const r = await fetch("https://inference.dagon.so/v1/credits", { headers: { authorization: `Bearer ${process.env.DAGON_KEY}` } });
console.log((await r.json()).data); // total_credits, total_usage, available (USD)
```

`available` is credit minus usage minus what in-flight requests hold. `GET /v1/credits/history` lists the last 50 credits (`id`, `amount_micros`, `source`, `created_at`).

Last updated 2026-11-07

[Previous **Introduction**](https://inference.dagon.so/docs) [Next **Models and pricing**](https://inference.dagon.so/docs/models)
