toklens

TokLens Manual

TokLens charges per token. Top-ups go into your wallet, you allocate wallet balance to a key, and API calls only spend the key's balance.

Updated

Getting started

  1. Sign up

    Register with your email and verify.

  2. Top up

    Top up on the Pricing page — cards from $10, USDC from $1, up to $1,000.

  3. Create a key and allocate balance

    Create a key on the API Keys page and pick a service, then allocate balance to it from the wallet.

  4. Connect your client

    Open Connect tools in your account, pick a Key and a tool, and run the command in your terminal.

Wallet balance and key credit

Wallet balance can't be used to call the API directly. Calls only spend a key's credit, so when a key runs out, requests fail even if the wallet still has money.

Topping up
$1 to $1,000, one-time payment. Cards from $10, usually under a minute. USDC from $1 — Solana and Polygon in seconds; Base and Arbitrum usually credit in seconds while on-chain confirmation completes, and rare cases can take longer.
Allocating to a key
Pick a key, enter an amount, confirm. Balance allocated to a key can't be moved back.
Auto refill
Off by default. When a key drops to the threshold, it's refilled from the wallet — $5 at $1, up to $20/day by default. Takes a few seconds; requests may fail briefly. Plan credit is used first, in small refills, then the wallet; never cards, and only for 1:1 keys.

API keys

Each key belongs to one service and is charged at that service's prices. The service can't be changed later.

Creating a key
Create on the API Keys page and pick a service. Different services need different keys.
Finding your keys
On the API Keys page, click Show Key on a card under My Keys to see the full key.
Binding keys from an administrator
Bind them on the API Keys page, up to 20.
Unbinding vs. removing
The delete icon under Bind API Keys only unbinds — the key still works and keeps its credit. To delete a key you created, open Details under My Keys; it stops working right away and remaining credit isn't refunded. For an administrator's key, contact them.

Connecting Codex and Claude Code

Open Connect tools, pick a Key and a tool, run the generated command.

Install command
The Connect tools command doesn't contain your full key: it carries a one-time credential valid for 15 minutes when the key can be delivered, otherwise you paste the key in the terminal, and the browser never receives it. The command from Generate and copy command on an activity page already carries the activity key, so run it only on your own computer and don't share it.
Checking the connection
Send a request and check it in Usage Details.

Codex Fast

Fast mode responds more quickly and costs 2x the standard price.

For the current session
Type /fast on in Codex. /fast status shows the current state and /fast off turns it off.
Always on
Add the config below to config.toml and restart Codex. If you start Codex through TokLens, edit the profile's codex/config.toml and use toklens-agentic 0.1.3 or later; older versions overwrite the file on every run.
Confirming it works
Send a request and check its cost breakdown in Usage Details — Service tier should show Fast and Service tier multiplier 2x. Account/group rate is separate; 1x is normal.
config.toml
service_tier = "fast"

[features]
fast_mode = true

Multi-agent Skills

Install local Skills with one command so Codex, Claude, and OpenCode share one engineering workflow.

What it's for
Comparing approaches, executing blueprints, code research, architecture reviews, and migration planning, with long tasks split up and run in parallel.
Install
Run the command below in your terminal. The Skills live on your computer, contain no Key, and leave each tool's TokLens setup unchanged.
Install Skills
curl -fsSL https://toklens.ai/agentic/scripts/install-b3ehive-skills.sh | bash

Billing

Prices are in US dollars per million tokens. Each request is charged at the prices of the key's service and taken from the key's credit.

Service discounts
Discounted services show a tag next to the name, such as 80% off. Struck-through is the base price, bold is what you pay.
Peak and off-peak
Some models have separate peak and off-peak prices. The peak hours are listed under the model, with the time zone shown.
Fast and Flex
Pricing page shows standard prices. Fast is 2x, Flex is 0.5x; some models have a separate Fast price. Independent of service discounts.

Plans

A plan grants a USD credit every week. It is spent first, on any model with any of your keys, before your wallet balance.

Plan period
4 weeks (28 days), starting at payment with the first week's credit. A new credit follows every 7 days.
Weekly credit
Spent before your wallet balance, at the same prices as the wallet, service discounts included. Whatever is left at the end of the week expires; it does not roll over.
When the credit runs out
Your wallet balance pays by default. Turn off “Use wallet balance once this week's credit is gone” on the Subscriptions page to pause requests until the next credit instead.
Auto-renewal
When you pay by card you can keep “Renew automatically” on: the card is charged a day before each term ends. Turn it off any time on the Subscriptions page. Plans paid with Alipay, WeChat Pay or USDC renew by hand.

Usage Details

Every request's model, tokens, and charge. Filter and export.

Cost breakdown
Hover a cost to see the service tier and multiplier details.
Exports
CSV exports all records; receipt can be copied, downloaded, or printed.
Checking a key without signing in
Enter a key on the home page to see its credit and usage without an account.

Account and security

Manage your profile, password, and balance alerts under Account.

Password and sign-in email
Change your password or sign-in email under Account → Sign-in and security. Forgot your password? Sign in with an email code, then set a new one with a code. Every device signs in again afterwards.
Wallet balance notification
Set a threshold and you'll get an email when the balance drops below it.
Supported regions
Each model is offered only in the countries and regions its provider supports: GPT models follow OpenAI's list, Claude models follow Anthropic's, and so on. See Compliance.

Activities and gift cards

Redeem a gift card and create the activity's Key in one place under Activities.

Where to find activities
After you sign in, Activities sits under Wallet in the sidebar. Every running activity is listed there with its own page and link, so organisers can send the link straight to participants.
Redeem a gift card
Enter the code on the card on the activity page and click Redeem. The credit arrives at once, and the top of the page shows the amount and when it expires. Each account can redeem one card per activity.
Create the activity Key in one click
After redeeming, click Create a <group> group key under Create a key. It creates a Key with the name and service the activity sets and allocates the card's credit into it, so you don't name it, pick a service or allocate by hand. If the allocation didn't go through, click Retry allocation; it only allocates and never charges twice. You can see the Key and its balance on the API Key page afterwards.
How gift card credit works
It is spent before your wallet balance and can be allocated to Keys, including partner coding tools such as Zenwork and KCode. When it expires, what is left is cancelled, including what sits unused in your Keys. It can't be withdrawn, refunded or transferred.
Connect a client
With the Key in hand, follow Connect it on the activity page. Codex CLI: choose macOS / Linux or Windows, click Generate and copy command and run it in a terminal; it already carries the activity key, installs Node.js first if needed, and afterwards you start Codex by typing codex-toklens in any new terminal. Zenwork: choose TokLens as the sign-in method, then on the authorization page choose Use an existing key, pick the activity key and click Authorize. For other tools, use Connect tools under My.

Troubleshooting

If a request fails or a top-up hasn't arrived, look up what you're seeing below.

429 “API key 额度已用完” while the wallet has money

Calls only spend key credit. Allocate balance to this key, or turn on auto refill.

403 “Insufficient account balance”

This key charges your account balance directly (usually older or admin-created), and it's too low. Top up.

401, or 403 “API key 已过期”

401: key is invalid or disabled — check it's entered correctly. 403 expired: the key has expired, use a new one.

Requests rejected once the plan credit is used up

“Use wallet balance once this week's credit is gone” is off. Wait for next week's credit or turn it back on on the Subscriptions page.

Payment succeeded but the balance hasn't changed

Cards arrive in about a minute. USDC on Base or Arbitrum usually credits in seconds while on-chain confirmation completes; rare cases can take longer, and wallet success does not mean the platform balance is credited.

Keeping keys safe

Anyone with a full key can spend its credit. Keep keys out of screenshots, chats, and public repos; hide keys and emails before sharing. Only enter keys on toklens.ai.

Use a separate key per project or machine, keep only near-term credit on each, and cap risk with auto refill's daily limit. If a leak is suspected: your key — open Details on the API Keys page, delete it and create a new one (credit isn't refunded); admin key — contact the admin.

API reference

Getting connected

Every service is OpenAI-compatible: point your SDK's base URL at the service address and send your key in a header.

APIs each service serves
ServiceAPI addressServes
GPT / Codex APIhttps://lax.toklens.ai/v1Text: Chat Completions, Responses, Anthropic Messages; images: generate, edit
DeepSeek & GLM APIhttps://hkg.toklens.ai/v1Text: Chat Completions, Responses
Grok APIhttps://hkg.toklens.ai/v1Text: Chat Completions, Responses; images: generate; video: generate

Authentication

Send Authorization: Bearer <key>, or x-api-key. Where two services share an address, the key decides which one you reach. Replace $TOKLENS_KEY in the examples with your key.

Endpoints

Endpoint paths
APIPathServices
Chat CompletionsPOST /chat/completionsAll
ResponsesPOST /responsesAll
Anthropic MessagesPOST /messagesGPT / Codex
Generate imagesPOST /images/generationsGPT / Codex, Grok
Edit imagesPOST /images/editsGPT / Codex, Grok
Generate videoPOST /videos/generationsGrok
List modelsGET /modelsAll

Examples

Any OpenAI-compatible library works as is: the official OpenAI SDKs, LangChain, the Vercel AI SDK. For streaming, send stream: true. Use the Anthropic SDK only with the GPT / Codex service, with a base URL without /v1.

curl -sS https://hkg.toklens.ai/v1/chat/completions \
  -H "Authorization: Bearer $TOKLENS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4.1-flash","messages":[{"role":"user","content":"Hello"}]}'

Images and video

Images come back in the response; a video is an async job: submit, poll, download.

Generate images

POST /images/generations, with n from 1 to 4. The returned url works for 10 minutes; send response_format: "b64_json" to get the image data instead. Each image has an asset_id you can use as a video first frame.

Image parameters
ParameterGrok: grok-imagine-image, -2.0GPT: gpt-image-2 and others
Sizeaspect_ratio + resolution (1k or 2k); size also workssize, e.g. 1024x1024, 1536x1024, 2048x2048
Aspect ratio1:1 16:9 9:16 4:3 3:4 3:2 2:3 auto and moreSet by size
Quality2.0 only: low, medium (default), auto—
EditPOST /images/edits with image as a data URL or a multipart upload, up to 3 images; each input image is billedPOST /images/edits with a multipart image
PricePer image, 1K / 2KPer image, 1K / 2K / 4K
curl -sS https://hkg.toklens.ai/v1/images/generations \
  -H "Authorization: Bearer $TOKLENS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"grok-imagine-image-2.0","prompt":"a lighthouse at sunset, watercolor","aspect_ratio":"16:9","resolution":"2k","quality":"low"}'

Generate video

Submit to get a request_id, poll GET /videos/{request_id}, and when status is done, download video.url with your key. An Idempotency-Key header is required, a new value per new video; retrying with the same value never charges twice.

curl -sS https://hkg.toklens.ai/v1/videos/generations \
  -H "Authorization: Bearer $TOKLENS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"model":"grok-imagine-video-1.5-lite","prompt":"waves rolling onto a beach","duration":6,"resolution":"720p"}'
# {"request_id":"vidreq_xxx"}

Video models

duration is 1 to 15 seconds and required. aspect_ratio takes 1:1 16:9 9:16 4:3 3:4 3:2 2:3 21:9 5:2, default 16:9; resolution defaults to 480p.

Video models
ModelResolutionsNotes
grok-imagine-video480p, 720pText to video, image to video
grok-imagine-video-1.5480p, 720p, 1080pAlso reference_images: up to 7, at most 720p
grok-imagine-video-1.5-lite480p, 720p, 1080pCheapest; 1080p is upscaled from 720p

Image to video

Pass the first frame as image: {"url": "https://…"}, a data URL, or {"asset_id": "…"} for an image this key generated. JPEG, PNG or WebP up to 20 MB. First frames and reference images are billed per image.

curl
curl -sS https://hkg.toklens.ai/v1/videos/generations \
  -H "Authorization: Bearer $TOKLENS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"model":"grok-imagine-video-1.5","prompt":"the cat turns its head","image":{"url":"https://example.com/cat.png"},"duration":5,"resolution":"1080p"}'

Errors

Errors use the OpenAI shape {"error": {"type", "message", "param"}}; param names the field at fault. Failed requests are free.

Error codes
StatusMeaningWhat to do
400A bad parameterFix the field named by param as message says
401No key, or an invalid keyCheck the request header
403The key is expired or disabled, or the service does not serve that API or modelUse a key of the right service
429The key is out of credit (API_KEY_QUOTA_EXHAUSTED), requests are too fast, or 4 videos are already in progressAssign the key balance from your wallet, or retry later
5xxThe upstream is briefly unavailableRetry later; for video, keep the same Idempotency-Key