DOCS

Text Model API Guide

Chat Completions API, billing rules, API key management and connecting AI coding tools.

1. Overview and Billing Rules

An API key is the credential used to call the large language model endpoints provided by BytomDAO. After a request succeeds, the system automatically deducts the corresponding amount from your account balance based on the resources actually consumed (token usage).

1.1 Basics

  • Billing currency: US dollars (USD). Balances, charges and top-ups are all shown in USD.
  • Billing method: Pay as you go. After a call consumes tokens, the cost is deducted automatically from your account balance. Make sure your balance is sufficient before sending requests.
  • Model prices: Prices differ from model to model. Always refer to the live prices published in the Model Catalog.

1.2 Pricing Formula

Pricing details vary slightly between model architectures. There are two main cases:

Basic pricing (applies to most models)

Cost per request = (input tokens ÷ 1,000,000) × input price + (output tokens ÷ 1,000,000) × output price

Tiered pricing (price adjusts with context length)

Some models support long context windows and use tiered pricing. For these models, the unit price is selected based on the actual number of input tokens in a single request. Example (for illustration only): if a model charges $0.50 per million tokens when input tokens < 32k, the price rises to $1.00 per million tokens when input tokens ≥ 32k.

2. Before You Start

Before calling the API, complete the following steps:

  1. Create and sign in to your BytomDAO account
  2. Add funds to your balance
  3. Create and save an API key
  4. Call the API with your key

3. Add Funds

Token usage is deducted from your account balance, so make sure you have enough funds first.

How to add funds:

  • Open the BytomDAO Dashboard
  • Go to Billing and click Add funds
  • Choose an amount (or enter a custom amount) and a payment method, then follow the on-screen instructions

Supported payment methods:

  • Stripe: bank card, Apple Pay or Google Pay
  • USDT / USDC: ERC-20 transfers on Ethereum, confirmed with your wallet

Notes:

  • If your balance is insufficient, API calls may fail or you may be unable to send further requests
  • Top-ups, balance and spending history can all be viewed on the Billing page

4. API Key Management

Manage your API keys here:

On this page you can:

  • Create a new API key
  • View your existing keys
  • Edit or revoke keys you no longer use

Recommendations:

  • Create a separate key for each project so access is isolated and easier to troubleshoot
  • Never expose a key in front-end code
  • Never commit a key to a Git repository
  • If you suspect a key has leaked, revoke it immediately on the API Keys page and create a new one

Create an API Key

Click Create on the API Keys page and fill in the form.

Recommendations:

  • Give the key a clear name so it is easy to recognize (for example, production or testing)
  • Keys are not restricted to specific models: you choose the model per request. See the Model Catalog for the supported models
  • Expiration: set an expiry date as needed, or leave it open for a key that never expires
  • Quota: set an available quota as needed, or leave it unlimited (not recommended).

After the key is created, copy it right away and store it in a safe place.

5. Endpoint

Example endpoint:

text
https://token.bytomdao.com/v1/chat/completions

Authentication:

http
Authorization: Bearer YOUR_API_TOKEN

Request headers must include:

  • Content-Type: application/json
  • Authorization: Bearer YOUR_API_TOKEN

6. Calling the API

curl example

bash
curl https://token.bytomdao.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your_api_key_here" \
  -d '{
    "model": "Claude-Sonnet-4.6",
    "messages": [
      { "role": "system", "content": "You are a helpful assistant" },
      { "role": "user", "content": "Write a product launch announcement" }
    ],
    "temperature": 0.7
  }'

Request parameters

  • model: the model to call, for example Claude-Sonnet-4.6
  • messages: the list of conversation messages
  • temperature: sampling randomness; higher values produce more varied output

messages roles

  • system: the system prompt, used to set the model's behavior
  • user: the user's input

Example:

json
[
  { "role": "system", "content": "You are a helpful assistant" },
  { "role": "user", "content": "Write a product launch announcement" }
]

Python example (requests)

python
import requests

url = "https://token.bytomdao.com/v1/chat/completions"
token = "your_api_key_here"

payload = {
    "model": "Claude-Sonnet-4.6",
    "messages": [
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Write a product launch announcement"},
    ],
    "temperature": 0.7,
}

headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {token}",
}

response = requests.post(url, json=payload, headers=headers, timeout=60)

print(response.status_code)
print(response.text)

The BytomDAO API is fully compatible with the OpenAI specification, so most developers simply use the official openai Python library. You only need to override base_url:

python
from openai import OpenAI

client = OpenAI(
    api_key="your_api_key_here",
    # Point the base URL to the BytomDAO endpoint
    base_url="https://token.bytomdao.com/v1"
)

response = client.chat.completions.create(
    model="Claude-Sonnet-4.6",
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Write a product launch announcement"}
    ],
    temperature=0.7
)

print(response.choices[0].message.content)

Likewise, for front-end or Node developers, we recommend the official openai npm package:

javascript
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: "your_api_key_here",
  baseURL: "https://token.bytomdao.com/v1" // Point to the BytomDAO endpoint
});

async function main() {
  const completion = await openai.chat.completions.create({
    model: "Claude-Sonnet-4.6",
    messages: [
        { role: "system", content: "You are a helpful assistant" },
        { role: "user", content: "Write a product launch announcement" }
    ],
    temperature: 0.7,
  });

  console.log(completion.choices[0].message.content);
}

main();

7. Connecting AI Coding Tools

When using AI-assisted development tools such as Claude Code or Codex, you only need to point their request address at the BytomDAO API to use the platform's models. You can either use the CC-Switch desktop app (recommended) or configure the native CLI environment directly.

CC-Switch is a cross-platform desktop app that brings multiple AI tools (Claude Code / Codex / Gemini) together. It greatly simplifies managing your model providers.

General steps

  1. Download and launch the CC-Switch client.
  2. Open the Providers page and click to add a custom provider.
  3. Name: enter BytomDAO.
  4. Base URL: enter https://token.bytomdao.com.
  5. API Key: paste the API key you created in the dashboard.
  6. Save, then select BytomDAO as the provider in each tool's tab.

Claude Code

  1. At the top of the CC-Switch main window, switch to the Claude Code tab.
  2. In the provider drop-down, select the BytomDAO provider you just created.
  3. In the model field, enter the exact model you want to call (for example Claude-Sonnet-4.6).
  4. Save and launch the tool; the configuration takes effect immediately.

Codex

  1. At the top of the main window, switch to the Codex tab.
  2. Select BytomDAO as the provider.
  3. Enter the model ID you want to use (see the Model Catalog for exact spelling).
  4. Save the configuration and launch the tool.

Gemini

  1. Switch to the Gemini CLI panel.
  2. Again select BytomDAO as the provider.
  3. Enter the model name you need and launch the client.

Using the CC-Switch CLI

Download and install (macOS shown as an example):

bash
# Download the universal binary (recommended; supports Apple Silicon and Intel)
curl -LO https://github.com/saladday/cc-switch-cli/releases/latest/download/cc-switch-cli-darwin-universal.tar.gz
# Extract
tar -xzf cc-switch-cli-darwin-universal.tar.gz
# Make it executable
chmod +x cc-switch
# Move it onto your PATH
sudo mv cc-switch /usr/local/bin/
# If macOS reports that the developer cannot be verified
xattr -cr /usr/local/bin/cc-switch

Common commands:

bash
cc-switch provider list              # List providers
cc-switch provider switch <id>       # Switch provider
cc-switch mcp sync                   # Sync MCP servers

# Use the global `--app` flag to target a specific app:
cc-switch --app claude provider list    # Manage Claude providers
cc-switch --app codex mcp sync          # Sync Codex MCP servers
cc-switch --app gemini prompts list     # List Gemini prompts

# Supported apps: `claude` (default), `codex`, `gemini`

After installing the CC-Switch CLI, run the following command in a terminal to open the TUI (Claude Code is used as the example here; Codex and Gemini work the same way):

bash
cc-switch

Press a when prompted to add a provider, choose the Custom template, then enter the URL, model and API key exactly as in the desktop app. Save when you are done.

If you prefer to stay on the keyboard in a Linux terminal, you can also apply the configuration quickly with CLI commands:

bash
# Set the default provider to BytomDAO
cc-switch set default-provider bytomdao
# Inject the environment variable mapping
cc-switch set bytomdao-token "YOUR_API_TOKEN"
cc-switch set bytomdao-base "https://token.bytomdao.com"

7.2 Standalone Native Environment Setup

If you do not use or have not installed CC-Switch, you can achieve the same request forwarding by exporting environment variables in the current terminal session.

Environment check

Before changing your environment, make sure that:

  1. Your network connection works and you can reach token.bytomdao.com.
  2. No hard-coded .env file in your project or system-level setting (such as a global ~/.anthropic cache) overrides the variables you are about to set. When troubleshooting, check for these leftovers first.

Claude Code

Claude Code sends requests through the Anthropic SDK, so setting the following variables automatically reroutes requests to BytomDAO.

bash
# macOS / Linux terminal
export ANTHROPIC_BASE_URL="https://token.bytomdao.com"
export ANTHROPIC_API_KEY="your_api_key_here"

# Applies to the current terminal session only; start the tool after setting them
claude

Codex

Most tools follow the standard OpenAI request path conventions.

bash
export OPENAI_BASE_URL="https://token.bytomdao.com"
# Some implementations use this alternative name instead:
export OPENAI_API_BASE="https://token.bytomdao.com/v1"

export OPENAI_API_KEY="your_api_key_here"

Gemini

For the Gemini CLI or plugins that call the SDK:

bash
export GEMINI_API_KEY="your_api_key_here"
# Note: if the tool does not support overriding the base URL, use LiteLLM as a forwarding proxy. Otherwise set the following variable directly:
export GOOGLE_GENAI_BASE_URL="https://token.bytomdao.com"

8. Request Logs

The Logs page shows the usage records generated by your API calls.

Open it here:

You can typically use it to check:

  • Usage within a given time range
  • The cost of individual requests, with the key name, model, input and output tokens
  • Total spending

9. Billing and Balance

Besides the request logs, you can review your overall balance and top-up history in the dashboard.

Open it here:

Information available there:

  • Current balance (USD)
  • Top-up history and payment status
  • Spending for the current month

10. Model Information

The model list always reflects the models actually provided by the platform. See the Model Catalog for details and live prices.

How to use it:

  • When calling the API, copy the model ID shown in the catalog and use it as the model value.

11. FAQ

401 Unauthorized

Possible causes:

  • The key is invalid
  • The key has been revoked
  • The Authorization header is missing
  • The key was not sent in the Bearer YOUR_API_TOKEN format

403 Forbidden

Possible causes:

  • The key does not have the required permission
  • The account is restricted

Insufficient balance

Possible cause:

  • Your account balance is too low

Suggested fix:

  • Add funds on the Billing page
  • Send the request again

Request cancelled or 429 Too Many Requests

Possible causes:

  • The number of concurrent requests exceeded the rate limit (RPM/QPS) set by the platform for that model
  • Your balance ran out and further requests were blocked (usually reported as a 429 indicating insufficient quota)

Suggested fix:

  • Add retry logic with exponential backoff to your code
  • Check your current balance on the Billing page

The request succeeds but the result is not what you expected

Check these first:

  • Is model spelled correctly?
  • Do the messages match what you intended?
  • Is the system prompt too restrictive?
  • Is temperature set too high?

12. Security Recommendations

  • Store keys in environment variables instead of hard-coding them
  • Never expose a key directly in front-end web pages
  • Never share production keys in plain text over chat tools
  • Split keys by project, environment or team so they are easier to manage
  • Revoke keys you no longer use