# Quickstart

> Create an account, add credit, create an API key and make your first request to Tokens with cURL, Python or Node.js, then connect your coding agent.

This quickstart takes you from a new account to a working API call, then to a connected coding agent. You need a terminal and, for the SDK examples, a recent Python 3 or Node.js 18+.

## 1. Create an account

Sign up at [tokens.bd/register](/register) with email or Google. Verify your email address: you can't create API keys until it is verified. If the link has expired or was already used, the sign-in page offers to send you a new one.

## 2. Add credit: a plan or a top-up

Keys only work when there is something to pay for usage with. Pick one (or both) in [/dashboard/billing](/dashboard/billing):

- **Subscribe to a plan** for a weekly or monthly amount of usage. Compare them on [pricing](/pricing).
- **Top up your wallet** for pay-as-you-go use. The minimum top-up is $5 or ৳500.

Prices are shown in USD, BDT. Available payment methods: bKash, Nagad, Visa Card, Master Card, Rocket, AMEX, DBBL Nexus, Google Pay, Internet Banking, SSL. If you want to pay in taka, read [paying in BDT](/docs/paying-in-bdt) first.

## 3. Create an API key

Open [/dashboard/keys](/dashboard/keys) and create a key. Give it a name you will recognise later ("laptop", "ci", "staging-bot"). You can also set a monthly spend cap and limit the key to certain models; both are optional, and both are fixed once the key exists. [API keys](/docs/api-keys) explains when to use them.

The secret starts with `tok_live_` and is shown **once**. Copy it now and put it in an environment variable:

:::code-tabs

```bash title="macOS / Linux"
export TOKENS_API_KEY="tok_live_your_key"
```

```powershell title="Windows PowerShell"
$env:TOKENS_API_KEY = "tok_live_your_key"
```

:::

:::warning
Never paste the key into code you commit, and never ship it in a web page. Browser calls to Tokens are not supported; call it from a server, script or CLI.
:::

## 4. Make your first request

The OpenAI-compatible base URL is `https://tokens.bd/v1`. The examples use `deepseek/deepseek-v4.1-flash`; swap in any model id from [/models](/models) that your plan or wallet covers.

:::code-tabs

```bash title="cURL"
curl https://tokens.bd/v1/chat/completions \
  -H "Authorization: Bearer $TOKENS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek/deepseek-v4.1-flash",
    "messages": [{"role": "user", "content": "Say hello in one short sentence."}]
  }'
```

```python title="Python"
# pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://tokens.bd/v1",
    api_key=os.environ["TOKENS_API_KEY"],
)

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

```js title="Node.js"
// npm install openai   (save as hello.mjs, run: node hello.mjs)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://tokens.bd/v1",
  apiKey: process.env.TOKENS_API_KEY,
});

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

:::

A successful response is a normal OpenAI chat completion. If you get an error instead, the `error.code` field tells you why:

| Code                                  | Usual cause                                                  | Fix                                                             |
| ------------------------------------- | ------------------------------------------------------------ | --------------------------------------------------------------- |
| `invalid_api_key`                     | Typo, or the variable isn't set in this shell                | `echo $TOKENS_API_KEY` and re-export                            |
| `model_not_found`                     | The model id is wrong                                        | Copy the id from `GET /v1/models`                               |
| `tier_permission_denied`              | Your plan doesn't include that model and the wallet is empty | Pick another model or top up                                    |
| `no_funding` / `insufficient_credits` | No plan and no wallet balance                                | Subscribe or top up in [/dashboard/billing](/dashboard/billing) |

The full list is in [errors](/docs/errors).

### List the models your key can use

```bash
curl https://tokens.bd/v1/models -H "Authorization: Bearer $TOKENS_API_KEY"
```

The `id` of each entry in `data` is exactly what you put in `model`.

## 5. Connect your coding agent

The quickest route for OpenCode, Claude Code, Codex CLI and Crush is the Tokens CLI. It signs you in through the browser, lets you pick a default model, and edits the agents' config files with a backup of each:

:::code-tabs

```bash title="macOS / Linux"
curl -fsSL https://tokens.bd/cli/tokens.mjs -o tokens.mjs && node tokens.mjs setup --base-url https://tokens.bd
```

```powershell title="Windows PowerShell"
iwr https://tokens.bd/cli/tokens.mjs -OutFile tokens.mjs; node tokens.mjs setup --base-url https://tokens.bd
```

:::

See [Tokens CLI](/docs/tokens-cli) for what it changes. If you prefer to configure things by hand, or use another tool, [/dashboard/connect](/dashboard/connect) has copy-and-paste settings for each agent, and the guides cover them in detail:

- [Claude Code](/docs/claude-code) (Anthropic-compatible, base URL `https://tokens.bd`)
- [Codex CLI](/docs/codex-cli), [OpenCode](/docs/opencode), [Crush](/docs/crush)
- [Cursor](/docs/cursor), [Cline](/docs/cline), [Roo Code](/docs/roo-code), [Kilo Code](/docs/kilo-code), [Continue](/docs/continue), [Zed](/docs/zed), [Aider](/docs/aider)

## Test your key from this page

Paste your key below to send a short test request through the gateway. It costs a few tokens.

::connection-tester

## Next steps

- [Choosing a model](/docs/choosing-a-model): which model for which job.
- [Usage, limits and alerts](/docs/usage-and-alerts): watch spend and set up alerts before you hand a key to an agent.
- [Streaming](/docs/streaming) and [tool calling](/docs/tool-calling) for the API details agents rely on.

---
Page: https://tokens.bd/docs/quickstart
