# Tokens > Tokens gives developers one API key for coding models behind OpenAI-compatible and Anthropic-compatible endpoints, with plans and a wallet payable in BDT or USD. - OpenAI-style base URL: https://tokens.bd/v1 - Anthropic-style base URL (no /v1): https://tokens.bd - Authentication: `Authorization: Bearer ` or `x-api-key: ` - Every page below is also available as Markdown: add .md to its address. - The whole documentation in one file: https://tokens.bd/llms-full.txt - OpenAPI description of the API: https://tokens.bd/openapi.json ## Getting Started Create a key, make your first request and pick a model. - [Platform overview](https://tokens.bd/docs/overview.md): What Tokens is, how a request travels from your tool to the model provider, what gets metered, and the handful of concepts you need before your first call. - [Quickstart](https://tokens.bd/docs/quickstart.md): 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. - [API keys](https://tokens.bd/docs/api-keys.md): Create, limit, store, rotate and revoke Tokens API keys, and understand the key-related errors: invalid_api_key, key_inactive, model_not_allowed_on_key and monthly_spend_cap_exceeded. - [Choosing a model](https://tokens.bd/docs/choosing-a-model.md): Pick a model by the job: long agentic coding sessions, cheap high-volume edits, big-context repo work, vision input or fast interactive use. Includes a comparison of representative models and how model ids work on Tokens. - [Tokens CLI (one-command agent setup)](https://tokens.bd/docs/tokens-cli.md): Use the Tokens CLI to sign in through your browser, pick a default model and configure OpenCode, Claude Code, Codex CLI and Crush in one command, with backups of every file it changes. - [Connect your tool](https://tokens.bd/docs/integrations.md): Find the guide for your tool: coding agents, editors, chat apps, automation tools, SDKs and agent frameworks that work with Tokens, and which protocol each one uses. ## Coding Agents Connect Claude Code, Codex CLI, OpenCode, OpenClaw, Hermes and other agents. - [Claude Code](https://tokens.bd/docs/claude-code.md): Connect Claude Code to Tokens through the Anthropic-compatible endpoint, map the opus, sonnet and haiku aliases to a Tokens model, and fix the usual gateway errors. - [Codex CLI](https://tokens.bd/docs/codex-cli.md): Add Tokens as a custom model provider in Codex CLI's config.toml, keep the key in an environment variable, and handle models whose upstream doesn't support the Responses API. - [OpenCode](https://tokens.bd/docs/opencode.md): Add Tokens to OpenCode as an OpenAI-compatible provider in opencode.json, keep the key in TOKENS_API_KEY, set context limits so compaction works, and switch models. - [OpenClaw](https://tokens.bd/docs/openclaw.md): Connect OpenClaw to Tokens as a custom provider, either with non-interactive onboarding or by editing ~/.openclaw/openclaw.json, then set real context limits and switch models. - [Hermes Agent](https://tokens.bd/docs/hermes-agent.md): Point Nous Research's Hermes Agent at Tokens as a custom chat completions endpoint, keep the key in ~/.hermes/.env, set a context length of at least 64K, and switch models. - [Crush](https://tokens.bd/docs/crush.md): Add Tokens to Charm's Crush as an openai-compat provider, using the new crushrc format or the older crush.json the Tokens CLI writes, then pick large and small models. - [Connect Cursor to Tokens](https://tokens.bd/docs/cursor.md): Point Cursor's chat at the Tokens OpenAI-compatible endpoint with a custom OpenAI base URL, and know which Cursor features will keep using Cursor's own models. - [Connect Cline to Tokens](https://tokens.bd/docs/cline.md): Set up the Cline coding agent in VS Code with the OpenAI Compatible provider, the Tokens base URL, your key and a model ID, plus the model settings that matter. - [Connect Roo Code to Tokens](https://tokens.bd/docs/roo-code.md): Configure Roo Code's OpenAI Compatible provider for Tokens. The Roo Code repository was archived in May 2026, so this page also points to maintained alternatives. - [Connect Kilo Code to Tokens](https://tokens.bd/docs/kilo-code.md): Add Tokens to Kilo Code as a custom OpenAI Compatible provider, from the settings UI or a kilo.json file, with model limits set so context management works. - [Connect Continue to Tokens](https://tokens.bd/docs/continue.md): Add Tokens models to Continue in VS Code or JetBrains with a config.yaml entry: provider openai, apiBase, key, roles, tool use and context length. - [Connect Zed to Tokens](https://tokens.bd/docs/zed.md): Use Tokens models in Zed's Agent Panel through an OpenAI-compatible provider in settings.json, with the API key kept out of the file. - [Connect GitHub Copilot to Tokens](https://tokens.bd/docs/github-copilot.md): Use Tokens models in GitHub Copilot Chat in VS Code with the bring-your-own-key Custom Endpoint provider and a chatLanguageModels.json entry. - [Aider](https://tokens.bd/docs/aider.md): Run Aider against Tokens with OPENAI_API_BASE and the openai/ model prefix, silence unknown-model warnings with a metadata file, and switch models per session. - [Goose](https://tokens.bd/docs/goose.md): Add Tokens to Goose as a custom OpenAI-compatible provider through goose configure or a JSON file in custom_providers, keep the key in TOKENS_API_KEY, and switch models. - [Qwen Code](https://tokens.bd/docs/qwen-code.md): Connect Qwen Code to Tokens through its OpenAI protocol in ~/.qwen/settings.json or with three environment variables, then switch between Tokens models with /model. - [Kimi Code CLI](https://tokens.bd/docs/kimi-code.md): Add Tokens to Moonshot's Kimi Code CLI as an openai provider in ~/.kimi-code/config.toml, read the key from TOKENS_API_KEY, and map local model aliases to Tokens model ids. - [Connect Factory Droid to Tokens](https://tokens.bd/docs/factory-droid.md): Add Tokens models to Factory's Droid CLI as custom models in ~/.factory/settings.json, using the Chat Completions or Anthropic Messages protocol. - [Connect Warp to Tokens](https://tokens.bd/docs/warp.md): Point Warp's agents at Tokens with a custom inference endpoint that speaks OpenAI Chat Completions, and know where Warp will not use it. - [Connect Amp to Tokens](https://tokens.bd/docs/amp.md): Route models in Amp's own catalog through Tokens with a Model Routing Custom URL connection. Amp cannot add arbitrary model IDs, so read the limits first. - [Other tools and compatibility](https://tokens.bd/docs/other-tools.md): Which coding agents and editors can use a custom OpenAI or Anthropic endpoint like Tokens, which cannot, and a generic recipe for connecting any OpenAI-compatible tool. - [Connect JetBrains AI Assistant to Tokens](https://tokens.bd/docs/jetbrains-ai-assistant.md): Add Tokens as an OpenAI-compatible provider in JetBrains AI Assistant for chat, and optionally for inline completion. Covers the URL field, tool calling and the known path bug. - [Connect Xcode to Tokens](https://tokens.bd/docs/xcode.md): Add Tokens as an internet-hosted chat provider in Xcode's Intelligence settings. Enter the URL without /v1, add your key and pick models in the chat model picker. - [GitHub Copilot CLI](https://tokens.bd/docs/github-copilot-cli.md): Run GitHub Copilot CLI on Tokens models with its bring-your-own-key environment variables: base URL, key, model, token limits, and what to check when it fails. - [OpenHands](https://tokens.bd/docs/openhands.md): Connect OpenHands to Tokens as an OpenAI-compatible endpoint, in the web UI or the CLI, with the right model string for ids that already contain a slash. ## Chat Apps & Automation Use Tokens in Open WebUI, LibreChat, n8n, Dify and other tools with an OpenAI-compatible provider setting. - [Open WebUI](https://tokens.bd/docs/open-webui.md): Add Tokens as an OpenAI connection in Open WebUI, list your models, move background tasks such as chat titles to a cheap model, and fix connection errors. - [LibreChat](https://tokens.bd/docs/librechat.md): Add Tokens to LibreChat as a custom endpoint in librechat.yaml: base URL, key from .env, model list, a cheap title model, Docker mounting and error fixes. - [Connect n8n to Tokens](https://tokens.bd/docs/n8n.md): Point n8n's OpenAI credential at Tokens by setting its Base URL, then use the OpenAI Chat Model with the AI Agent node: model IDs, the Responses API toggle, tool calling and spend limits. - [Connect Dify to Tokens](https://tokens.bd/docs/dify.md): Add Tokens models to Dify with the OpenAI-API-compatible provider plugin: the form fields, model IDs with a slash, the Function Call Type setting for agents, and Dify Cloud versus self-hosted. ## SDKs & Libraries Call Tokens from cURL, Python, Node.js and popular AI frameworks. - [cURL](https://tokens.bd/docs/curl.md): Call the Tokens API with cURL: chat completions, streaming, Anthropic Messages, listing models, checking usage and reading request IDs from error responses. - [Python (OpenAI SDK)](https://tokens.bd/docs/python.md): Use the official openai Python package with Tokens: client setup, sync and async calls, streaming, tool calls, timeouts, retries and error handling. - [Node.js and TypeScript (OpenAI SDK)](https://tokens.bd/docs/nodejs.md): Use the official openai npm package with Tokens from Node.js and TypeScript: client setup, streaming, error handling with APIError, and a Next.js route handler that keeps your key on the server. - [Anthropic SDK (Python and TypeScript)](https://tokens.bd/docs/anthropic-sdk.md): Point the official Anthropic Python and TypeScript SDKs at Tokens with base URL https://tokens.bd, then call messages.create and stream with any model in the Tokens catalog. - [Vercel AI SDK](https://tokens.bd/docs/vercel-ai-sdk.md): Use Tokens as a provider in the Vercel AI SDK with createOpenAICompatible from @ai-sdk/openai-compatible, then call generateText and streamText, including a Next.js route. - [LangChain and LiteLLM](https://tokens.bd/docs/langchain.md): Use Tokens from LangChain (Python and JavaScript) with ChatOpenAI and a custom base URL, and from LiteLLM as an SDK or proxy with the openai/ model prefix. - [OpenAI Agents SDK](https://tokens.bd/docs/openai-agents-sdk.md): Run agents built with the OpenAI Agents SDK (Python and TypeScript) on Tokens: Chat Completions model class, the slash-in-model-id problem, tracing, tools and streaming. - [Claude Agent SDK](https://tokens.bd/docs/claude-agent-sdk.md): Run agents built with the Claude Agent SDK (Python and TypeScript) on Tokens: set ANTHROPIC_BASE_URL and a Tokens key, choose a model id, handle the opus, sonnet and haiku aliases, stream and add tools. - [LlamaIndex](https://tokens.bd/docs/llamaindex.md): Use Tokens from LlamaIndex (Python) with the OpenAILike class: api_base, is_chat_model, context window, streaming, function-calling agents, and embeddings for RAG. - [CrewAI](https://tokens.bd/docs/crewai.md): Run CrewAI agents and crews on Tokens: the LLM class with a custom base URL and custom_openai, how to write the model id, streaming, tool calls, rate limits and troubleshooting. - [Laravel AI SDK](https://tokens.bd/docs/laravel-ai-sdk.md): Use Tokens from the official Laravel AI SDK (laravel/ai) with the openai-compatible provider: config/ai.php, .env, a first call, streaming, tools, timeouts and error handling for Laravel 12 and 13. - [PHP](https://tokens.bd/docs/php.md): Use Tokens from PHP and Laravel: the openai-php/client package, the openai-php/laravel package and plain cURL. Base URL, a first call, streaming, tool calls, timeouts and Tokens error codes. ## API Reference Endpoints, authentication, streaming, tool calling, errors and limits. - [Authentication](https://tokens.bd/docs/authentication.md): Base URLs, the two supported auth headers, the tok_live_ key format, and what the 401 and 403 error codes mean. - [Chat Completions](https://tokens.bd/docs/chat-completions.md): POST /v1/chat/completions: request fields, a full request and response, the usage object, and how the gateway treats max_tokens, n and streaming. - [Messages (Anthropic API)](https://tokens.bd/docs/messages.md): Call POST /v1/messages with Anthropic SDKs or curl: base URL, headers, a full example, streaming events, error shapes, and which headers are not forwarded. - [Responses API](https://tokens.bd/docs/responses.md): POST /v1/responses, the OpenAI Responses API: when to use it instead of chat completions, request and response examples, max_output_tokens and streaming events. - [Models and Usage Endpoints](https://tokens.bd/docs/models-and-usage.md): GET /v1/models lists the models your key can call. GET /v1/tokens/usage returns your plan, usage windows, wallet balance and key limits. Plus notes on embeddings and legacy completions. - [Streaming](https://tokens.bd/docs/streaming.md): How Server-Sent Events streaming works through the Tokens gateway for chat completions and messages: the event format, usage chunks, timeouts, and handling disconnects. - [Tool Calling](https://tokens.bd/docs/tool-calling.md): Use OpenAI-style function tools and Anthropic-style tools through the Tokens gateway, with a complete runnable tool loop in Python and tips on model support. - [Errors](https://tokens.bd/docs/errors.md): Every error code the Tokens API returns, what it means and what to do, plus the error JSON shape, request ids for support tickets, and which errors to retry. - [Rate Limits](https://tokens.bd/docs/rate-limits.md): Requests per minute, concurrency, plan usage windows and per-key monthly spend caps: how each limit works, the errors they return, and how to back off correctly. - [Embeddings](https://tokens.bd/docs/embeddings.md): POST /v1/embeddings turns text into vectors for search, retrieval and clustering. How to find an embedding model in the catalog, the request and response, how it is billed, and the errors you can hit. - [Legacy Completions](https://tokens.bd/docs/legacy-completions.md): POST /v1/completions is the old prompt-in, text-out endpoint. Request fields, streaming, billing, which models accept it, and how to move the same call to chat completions. - [Token Counting](https://tokens.bd/docs/token-counting.md): POST /v1/messages/count_tokens returns the input size of a request without running the model. How exact it is, what it costs, and how to count or estimate tokens for chat, completions, responses and embeddings. - [Vision: sending images to models](https://tokens.bd/docs/vision.md): Send images to a model on Chat Completions (image_url parts) or Messages (image blocks): URL and base64 forms, size limits, what the gateway translates, how image input is billed, and how to check a model accepts images. - [Structured output: JSON mode and JSON Schema](https://tokens.bd/docs/structured-output.md): Get machine-readable JSON from a model through Tokens: JSON mode, JSON Schema with response_format, forced tool calls, and Anthropic's output_config, with examples, validation advice and what the gateway drops. - [Reasoning and thinking models](https://tokens.bd/docs/reasoning.md): Use reasoning models through Tokens: reasoning_effort on Chat Completions, thinking and effort on Messages, how reasoning text is returned and streamed, how reasoning tokens are counted and billed, and what the gateway rewrites or drops. - [Prompt caching](https://tokens.bd/docs/prompt-caching.md): How prompt caching works through Tokens: what the provider does, what the gateway passes through, how cache reads and writes show up in usage, and how they are priced and billed. - [Browser and mobile apps](https://tokens.bd/docs/browser-and-mobile.md): Why a Tokens API key must never be in a web page or mobile app, and the pattern that works: your own backend in between. Working Next.js and Express examples with streaming, plus the mobile version. - [Production checklist](https://tokens.bd/docs/production-checklist.md): What to set up before real users depend on the Tokens API: retries and backoff, timeouts, Retry-After, request ids, a key per environment, spend caps, alerts, key rotation, and what to do on 402 and 429. - [Request ids and debugging](https://tokens.bd/docs/request-ids-and-debugging.md): The request id headers on every Tokens response, how to quote one to support, what to log, how to reproduce a failing call with curl, and how to read the usage page and the error body. ## Account & Billing Plans, wallet, paying in BDT, usage alerts, security and support. - [Plans, credits and wallet](https://tokens.bd/docs/plans-and-wallet.md): How subscription plans, credits, usage windows and the pay-as-you-go wallet work on Tokens, what happens when a window or your balance runs out, and how renewal, cancellation and coupons work. - [Paying in BDT](https://tokens.bd/docs/paying-in-bdt.md): Pay for Tokens plans and wallet top-ups in Bangladeshi taka: available payment methods, how the exchange rate is locked at checkout, the minimum top-up, receipts and refunds. - [Usage, limits and alerts](https://tokens.bd/docs/usage-and-alerts.md): Track spend and remaining allowance on Tokens from the dashboard, a CSV export, the GET /v1/tokens/usage endpoint or the CLI, set up usage alerts, and handle rate limits and Retry-After correctly. - [Security and data privacy](https://tokens.bd/docs/security-and-privacy.md): What Tokens stores and doesn't store about your requests, how your prompts reach model providers, and how to secure your account and API keys with MFA, session control and key hygiene. - [Getting help](https://tokens.bd/docs/support.md): How to get help with Tokens: check the status page, find the request id, and open a support ticket in the dashboard with the details that get it solved fast. ## Guides Move from another provider, keep costs down and run Tokens in production. - [Migrate from OpenAI](https://tokens.bd/docs/migrate-from-openai.md): Move an app that calls the OpenAI API to Tokens: the three settings that change, what stays the same, the endpoints and behaviours that differ, how to test the switch with a capped key and how to roll back. - [Migrate from OpenRouter](https://tokens.bd/docs/migrate-from-openrouter.md): Move an app from OpenRouter to Tokens: the base URL, key and model ids to change, what happens to OpenRouter routing fields, headers and model suffixes, how errors and limits differ, and how to test and roll back. - [Migrate from Anthropic](https://tokens.bd/docs/migrate-from-anthropic.md): Move an app that calls the Anthropic Messages API to Tokens: base URL without /v1, key header, model ids, which Anthropic-only features pass through and which do not, how errors and limits differ, testing and rollback. - [One key per customer or environment](https://tokens.bd/docs/one-key-per-customer.md): Building a product on Tokens: what a key can be limited by, how keys are created and revoked (dashboard only, no key-management API), how many you can have, how to track spend per customer, and what your own app must do. - [Cutting your spend](https://tokens.bd/docs/cutting-costs.md): Practical ways to spend less on Tokens, from the choices that change the bill most to the ones that prevent surprises: model choice, max_tokens, context size, caching, plan allowances, background models, cancelling streams, and spend caps. - [Working with Bengali text](https://tokens.bd/docs/bengali-text.md): How Bengali and other non-Latin text behaves through the API: why it takes more tokens, how to measure it from the usage field, what that means for max_tokens, context and cost, prompting tips, UTF-8 in streams, and a script to compare models on your own text. ## Troubleshooting Fix common errors and find answers to frequent questions. - [Troubleshooting](https://tokens.bd/docs/troubleshooting.md): Fix common Tokens API errors by symptom: 401 invalid key, 403 model not allowed, 402 insufficient credits, 429 limits, 404 model not found, 5xx, wrong base URL, stuck streams and Windows env vars. - [FAQ](https://tokens.bd/docs/faq.md): Short answers to common questions about Tokens: OpenAI and Anthropic compatibility, models, privacy, paying in BDT, balances, keys, receipts, account deletion and uptime. ## Dashboard A tour of the dashboard: keys, teams, the playground, referrals and notifications. - [Dashboard tour](https://tokens.bd/docs/dashboard-tour.md): A page-by-page tour of the Tokens dashboard: what each page is for, the one thing to do there, and where the details are documented. - [Teams and roles](https://tokens.bd/docs/teams-and-roles.md): Create a team organization on Tokens, invite members, give them a role and a monthly spending cap, switch between organizations, and remove a member. Includes what each role can do and what a team shares. - [Referrals](https://tokens.bd/docs/referrals.md): How the Tokens referral program works: get your link, what the person you invite gets, what you earn and when it is paid, the rules and limits, and where to track your referrals in the dashboard. - [Playground](https://tokens.bd/docs/playground.md): Send a prompt to any model you can use from the Tokens dashboard, see the answer and what the request cost, and copy the same request as cURL, Python or a coding-agent config. Covers billing, settings and limits. - [Notifications and email alerts](https://tokens.bd/docs/notifications.md): Every email Tokens sends about your account: which ones you can switch on or off on the Notifications page, what triggers each, the thresholds, the defaults, and how to read the delivery history. - [Reading the model catalog](https://tokens.bd/docs/model-catalog.md): How to read the public models list, a model's own page and the dashboard Model catalog: every column, badge and price field, what Available on means, and why the list your key sees can be shorter. - [Account settings](https://tokens.bd/docs/account-settings.md): What the Settings page and Account security page let you do: view your profile, pick a default currency, set up two-factor authentication, review sessions, and request account deletion, with what happens to your keys, balance and records.