Site API Overview & Authentication

Welcome to the TokensByte Platform Feature API. In addition to calling major model providers through the unified AI router, the platform exposes endpoints for balance queries, available model lists, API token management, usage logs, and account/wallet operations.

1. Comparison of the Two API Types & Authentication Methods

Platform APIs use two authentication methods depending on the calling scenario:

API TypeApplicable PathsAuthenticationTypical Use Cases
Direct API Key Query Endpoints/v1/balance, /v1/user/balance, /v1/models, /v1beta/modelsDirectly use API Key (sk-xxx) (no login required)Runtime queries from client tools or scripts for remaining quota, account balance, and available models
Console Management Endpoints/api/v1/*Log in to obtain a JWT Token (Authorization: Bearer <JWT>)Secondary development or automated backend management of profile, wallet ledger, API token CRUD, and call logs

2. Console Management API Authentication Flow (JWT)

Except for public or registration endpoints, all site management APIs under /api/v1/* require JSON Web Token (JWT) authentication:

Step 1: Log In and Obtain a Temporary JWT Token

  • Request Path: /api/v1/auth/login
  • Request Method: POST
  • Request Body Example:
{
  "username": "Your username or email",
  "password": "Your login password",
  "login_type": "username"
}
  • login_type is optional and accepts "username", "email", or "mobile". Defaults to "username".

  • Response Body Example:

{
  "token": "eyJhbGciOi...",
  "user": {
    "id": "1",
    "username": "user1",
    "role": "user",
    "email": "user@example.com",
    "is_active": 1
  }
}

Step 2: Include the JWT Token in HTTP Request Headers

For all subsequent /api/v1/* management requests, include the standard Authorization header:

Authorization: Bearer your_JWT_token_string

[!IMPORTANT] The JWT token returned by login has an expiration time and is used only for /api/v1/* management endpoints. To query quotas, list models, or invoke LLMs from client tools or application code, use a long-lived static API Key (sk-xxx) directly.

Raw Markdown (.md) · llms.txt