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 with email or Google. Verify your email address: you can't create API keys until it is verified.
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:
- Subscribe to a plan for a weekly or monthly credit allowance. Compare them on 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: Invoice via billing portal. If you want to pay in taka, read paying in BDT first.
3. Create an API key#
Open /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 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:
export TOKENS_API_KEY="tok_live_your_key"$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 that your plan or wallet covers.
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."}]
}'# 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)// 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 |
The full list is in errors.
List the models your key can use#
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:
curl -fsSL https://tokens.bd/cli/tokens.mjs -o tokens.mjs && node tokens.mjs setup --base-url https://tokens.bdiwr https://tokens.bd/cli/tokens.mjs -OutFile tokens.mjs; node tokens.mjs setup --base-url https://tokens.bdSee Tokens CLI for what it changes. If you prefer to configure things by hand, or use another tool, /dashboard/connect has copy-and-paste settings for each agent, and the guides cover them in detail:
- Claude Code (Anthropic-compatible, base URL
https://tokens.bd) - Codex CLI, OpenCode, Crush
- Cursor, Cline, Roo Code, Kilo Code, Continue, Zed, 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.
Live connection test
Check latency and token generation before you start coding.
Next steps#
- Choosing a model: which model for which job.
- Usage, limits and alerts: watch spend and set up alerts before you hand a key to an agent.
- Streaming and tool calling for the API details agents rely on.