What you’ll learn
- Do I need an API key to use the TokenLab MCP server?
- Which MCP profile should I start with?
- Which model fields should an agent trust when choosing a model?
- Why did my agent get a 503 all_channels_failed error?
- Does the MCP server support Gemini Files or cachedContents?
A coding agent that picks a model ID from memory will eventually pick one that no longer exists. It finds out from a 404 or a surprising bill. TokenLab gives agents a live, public catalog to check first: the model API, an MCP server, and plain text files. With them an agent can verify the ID, the request format, and the price before it writes any integration code. This guide covers the MCP server, the model fields an agent can trust for routing, and one discover, check, and call flow.
Key Takeaways
- The TokenLab MCP server has three profiles:
catalog(no API key),core, andfull. Browsing models and prices needs no key in any profile. Paid calls incoreandfullneed one. - With a key and the
coreorfullprofile, the server can also send model requests, create media, handle files, and check async tasks. - Route on
tokenlab.accepted_request_formats,tokenlab.request_format_summary,tokenlab.pricing,tokenlab.lifecycle, andtokenlab.deliveryAvailability. Do not hard-code the order of recommendations. - Gemini Files, resumable uploads, and
cachedContentsare not in any MCP profile. - Never paste an API key into a prompt or a tool argument.
What the TokenLab MCP Server Gives a Coding Agent
The TokenLab MCP Server lets an MCP client browse current models and prices, send model requests, create media, work with files, and check async tasks. Its tools come in three layers:
| Layer | Needs a key | Tools |
|---|---|---|
| Discover | No | list_models, get_model, get_pricing, get_model_pricing, compare_models, get_api_overview |
| Create | Yes | create_chat_completion, create_response, create_anthropic_message, create_gemini_content, evaluate_decisions, create_image, edit_image, create_video, create_music, create_3d_model, create_speech, transcribe_audio, translate_audio |
| Operate | Yes | upload_file, list_files, retrieve_file, get_task_status, cancel_task, create_embedding, rerank_documents, translate_text |
Some tools are left out of the table, such as the file-based image variants. Which tools a client sees depends on the profile:
| Profile | API key | Includes |
|---|---|---|
catalog |
Not required | Model list, model details, prices, comparisons, API overview |
core |
Only for paid calls | Common chat, decision, media, audio, file, task, embedding, rerank, and translation tools |
full |
Only for paid calls | core plus additional developer APIs |
Start with catalog if you only want better model selection. Use core when the client should create content or call a model. The MCP model catalog guide shows the MCP messages behind the discover tools.
Install the TokenLab MCP Server in Your Client
The package needs Node.js 18.17 or newer and npx. It runs locally over stdio, so you need no global install. Back up your active configuration first, and add only the TokenLab entry. The commands below come from the MCP server docs. Version 0.6.45 is the latest on npm on 2026-11-11.
Claude Code:
claude mcp add \
--env TOKENLAB_MCP_TOOL_PROFILE=catalog \
--scope user \
tokenlab -- \
npx -y @tokenlabai/mcp-server@0.6.45
Codex:
codex mcp add \
--env TOKENLAB_MCP_TOOL_PROFILE=catalog \
tokenlab -- \
npx -y @tokenlabai/mcp-server@0.6.45
Cursor (~/.cursor/mcp.json or .cursor/mcp.json):
{
"mcpServers": {
"tokenlab": {
"command": "npx",
"args": ["-y", "@tokenlabai/mcp-server@0.6.45"],
"env": {
"TOKENLAB_MCP_TOOL_PROFILE": "catalog"
}
}
}
}
VS Code uses .vscode/mcp.json with a servers key and "type": "stdio". Claude Desktop uses the same shape as Cursor in claude_desktop_config.json. The docs page has both.
To enable paid tools, create a key in Console → API keys and set both variables in the server environment:
{
"env": {
"TOKENLAB_API_KEY": "<TOKENLAB_API_KEY>",
"TOKENLAB_MCP_TOOL_PROFILE": "core"
}
}
Restart the client and run claude mcp list or codex mcp list. Then ask the agent to call list_models. A non-empty list confirms that the package started and reached TokenLab. If a real key lands in a shared file, a log, or shell history, revoke it and create a new one.
One Agent Flow: Discover, Check, Call
Take an agent that must add image generation to a Node.js app. Every value below was read from the live model API on 2026-11-11.
1. Discover. Ask for the current shortlist. Call list_models with these arguments, or use plain HTTP:
{ "recommended_for": "image" }
curl "https://api.tokenlab.sh/v1/models?recommended_for=image"
The valid recommended_for values are image, video, music, 3d, tts, stt, embedding, rerank, translation, and decision. Say the agent picks nano-banana-pro.
2. Check the endpoint and the price. Call get_model, or GET /v1/models/nano-banana-pro (live model API). For this model it reports:
- status
active, with both Verified and Official delivery available - operations:
text-to-image,image-to-image, andimage-edit - request endpoint for each operation, in
tokenlab.request_format_summary.request_endpoint_by_operation:/v1/images/generationsfor all three - price: per image. The Verified price is $0.067 for the default 1k text-to-image request. Across resolutions and operations it ranges from $0.067 to $0.12. The Official range is $0.134 to $0.24.
The endpoint is specific to the model. gpt-image-2 sends text-to-image to /v1/images/generations but image-edit to /v1/images/edits, and it is priced per token, for example $3.50 per 1M text input tokens and $21.00 per 1M image output tokens (Verified). An agent that assumed one endpoint and one price shape for every image model would write wrong code. Read the fields per model.
3. Make the call. Send the chosen model ID explicitly. TokenLab does not silently replace it. The client should ask for approval before a paid call if the price or the model choice has not been confirmed. A request built from the fields above, following the Create Image reference:
curl https://api.tokenlab.sh/v1/images/generations \
-H "Authorization: Bearer $TOKENLAB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-pro",
"prompt": "A red bicycle leaning on a white wall",
"operation": "text-to-image",
"aspect_ratio": "1:1",
"resolution": "1k"
}'
Some image requests return the final image in the response and wait for generation, so set a client timeout of at least 120 seconds. If the response has task_id or poll_url, poll GET /v1/tasks/{id}.
For a chat model, the accepted format decides the endpoint. gpt-5.6-terra accepts openai_chat_completions and openai_responses (live model API), so the standard OpenAI SDK works:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TOKENLAB_API_KEY"],
base_url="https://api.tokenlab.sh/v1",
)
response = client.chat.completions.create(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Reply only with OK."}],
)
print(response.choices[0].message.content)
For a cost estimate, gpt-5.6-terra charges $0.60 per 1M input tokens (Verified) up to 272K input tokens. A 10,000-token prompt then costs about 10,000 / 1,000,000 × $0.60 = $0.006 for input, before output. Above 272K input tokens, the whole request moves to a higher tier at $1.20 input and $5.40 output per 1M tokens.
Which Model API Fields an Agent Should Trust for Routing
Read these from GET /v1/models/{model} (Get a Model):
| Field | What it means for routing |
|---|---|
tokenlab.accepted_request_formats |
Which endpoint family a chat model takes: openai_chat_completions is /v1/chat/completions, openai_responses is /v1/responses, anthropic_messages is /v1/messages, gemini_generate_content is /v1beta/models/{model}:generateContent |
tokenlab.request_format_summary |
For non-chat models: the endpoint for each operation, the supported parameters, accepted values, and limits. Read it before you build a request. |
tokenlab.pricing, official_pricing, pricing_unit |
The Verified price, the Official price, and the billing unit, such as per_token or per_image. Verified fields are null when the model has no Verified offer. |
tokenlab.max_input_tokens, max_output_tokens |
Context and output limits. For gpt-5.6-terra: 1,050,000 and 128,000 |
tokenlab.supported_operations |
Operations such as text-to-image or image-to-video |
tokenlab.lifecycle |
Availability, release date, deprecation date, replacement model |
tokenlab.deliveryAvailability |
Configured verified and official support. A missing field means unknown. |
Two cautions apply. First, an accepted format confirms the endpoint, but individual tools and fields can still vary by model. Second, deliveryAvailability is configured support, not a real-time guarantee. Treat recommended_for results as a shortlist, because TokenLab says not to depend on their order.
For prices alone, GET /v1/models/{model}/pricing is the pricing-only endpoint. Some models carry tiers. seedance-2.0, for example, has output prices that depend on resolution and on whether the request includes video input. They range from $2.28 to $7.315 per 1M tokens (Verified), and from $2.40 to $7.70 at the Official price. The pricing endpoint for seedance-2.0 lists every tier. Prices read 2026-11-11.
Error fields that guide recovery
On OpenAI-compatible Chat Completions and Responses errors, the error guide lists optional did_you_mean, suggestions, hint, retryable, and retry_after. Handle the HTTP status and code first. A 400 model_not_found may carry did_you_mean. Show it to the user instead of swapping models silently. A 503 all_channels_failed can have retryable: false, and repeating it will not help. Anthropic Messages and Gemini keep their native error formats.
What the MCP Server Does Not Do
- It does not change your client's main model provider. Use that client's own setup guide.
- It does not cover Gemini Files, resumable uploads, or
cachedContents. Those need HTTP calls. See Gemini Files and cache. - It is not the Skill. The TokenLab Agent Skills install instructions with
npx skills addand start no MCP server. - If a status check for an async task times out, do not create a second task. Check the first one again.
- It does not make a decision trustworthy by itself. A Noul answer from
evaluate_decisionsis a probability, not a Boolean. Validate it against your own labeled cases.
The catalog profile cannot make paid calls at all. Image tools return either a result or a task, depending on the model. Video, music, and 3D tools always return tasks.
Plain HTTP and File Surfaces
For agents that do not use MCP, TokenLab also publishes machine-readable files. https://api.tokenlab.sh/llms.txt is a compact API overview with a first request, common endpoints, model filters, and error guidance. https://tokenlab.sh/llms-full.txt lists the native endpoints and the discovery files in more detail. The Model Data Center documents the public catalog files catalog.json, latest.json, and summary.md. For live status and prices, see the Models catalog.
FAQ
Do I need an API key to use the TokenLab MCP server?
No, not for browsing. The catalog profile lists models, details, prices, and comparisons without a key. Paid model or media requests need TOKENLAB_API_KEY in the server environment, with the core or full profile.
Which MCP profile should I start with?
Start with catalog if you only want better model selection. Move to core when the client should call models or create media. Use full only if the agent needs the extra developer APIs.
Which model fields should an agent trust when choosing a model?
Trust accepted_request_formats or request_format_summary for the endpoint, pricing with its unit for cost, the token limits, supported_operations, and lifecycle. Treat deliveryAvailability as configured support, not live availability.
Why did my agent get a 503 all_channels_failed error?
The operation may have no supply in the selected Delivery tier. When retryable is false, do not repeat the request. Check availability with GET /v1/models and choose another model with the user's approval.
Does the MCP server support Gemini Files or cachedContents?
No. Gemini Files, resumable uploads, and cachedContents currently require HTTP calls. The MCP file tools use the OpenAI-compatible /v1/files API.
Create a key in Console → API keys, then add the catalog profile to your client with the commands above.
Sources
Prices checked 2026-11-11
- TokenLab docs: TokenLab MCP ServerSources checked 2026-11-11
- TokenLab MCP server on GitHubSources checked 2026-11-11
- TokenLab docs: Errors agents can act onSources checked 2026-11-11
- TokenLab docs: Get a ModelSources checked 2026-11-11
- TokenLab docs: Create ImageSources checked 2026-11-11
- TokenLab model API: nano-banana-proSources checked 2026-11-11
- TokenLab model API: gpt-image-2Sources checked 2026-11-11
- TokenLab model API: gpt-5.6-terraSources checked 2026-11-11



