This page documents the maintained shared
tokenlab-api-integration skill. The canonical distribution lives in hedging8563/tokenlab-skills, where the public repository intentionally keeps only this skill.Use this page for skill installation and agent workflow guidance. For endpoint-specific setup, use the dedicated SDK, client, or API reference page for that tool.
What The Skill Does
- Generates minimal runnable examples for TokenLab chat, image, audio, video, translation, and other API families.
- Uses
https://api.tokenlab.sh/v1for OpenAI-compatible clients and explains when to switch to native Anthropic or Gemini routes. - Discovers models with
/v1/models,/llms.txt, andrecommended_forshortlists instead of guessing from stale lists. - Reads a model details before retrying non-chat requests, so unsupported fields are not silently dropped.
- Handles Agent-First error hints such as
did_you_mean,suggestions,retry_after, andrecommended_request.
Install
Use the canonical non-interactive install command:This installs the shared
tokenlab-api-integration skill from the TokenLab skills repository.If your tool does not support the installer, copy skills/tokenlab-api-integration/ from the repository into your tool’s shared skills or rules directory.Update Existing Installs
If you installed the skill earlier, rerun the same command to update to the current public package.Verify Installation
Ask your coding agent:tokenlab-api-integration, the installation succeeded.
Get Your API Key
Visit TokenLab
Go to tokenlab.sh
Get API Key
Open Dashboard → API Keys and create a new key
Recommended Agent Workflow
- Start with the smallest working example that matches the user’s requested language and API family.
- When model choice is open, call
/v1/modelsorhttps://api.tokenlab.sh/llms.txtbefore hardcoding a model. - For non-chat work, call
/v1/models?recommended_for=<scene>where<scene>isimage,video,music,3d,tts,stt,embedding,rerank, ortranslation. - Before changing a failed non-chat request, read
/v1/models/:modeland align withsupported_operations,supported_parameters,request_endpoint,request_endpoint_by_operation,request_shape_mode, andrecommended_request. - If the API returns an Agent-First error, use the structured fields to correct the request and retry only when the error is retryable.
Minimal Chat Example
This example uses the OpenAI Python SDK with the TokenLab base URL:Model Discovery
Prefer live discovery over stale bundled lists:Native Routing Hints
OpenAI-compatible/v1 is the default path for common chat, responses, image, embedding, audio, and rerank examples. Use native Anthropic or Gemini routes only when the request needs provider-specific behavior or TokenLab returns X-TokenLab-Native-Endpoint as an optimization hint.
Agent-First Error Recovery
Errors include fields that coding agents can parse without scraping docs:| Error | Useful fields | Agent action |
|---|---|---|
| Wrong model name | did_you_mean, suggestions, hint | Retry with the corrected model or one suggested alternative |
| Insufficient balance | balance_usd, estimated_cost_usd, suggestions | Ask for approval or switch to an affordable model |
| Rate limit or temporary unavailability | retryable, retry_after, alternatives | Wait, retry, or choose a listed alternative |
| Non-chat unsupported request | supported_operations, supported_parameters, request_endpoint, request_endpoint_by_operation, request_shape_mode, recommended_request | Rebuild the request from the model details and return a clear error on intent-changing fields |
Supported API Families
| Family | Primary path |
|---|---|
| Chat and Responses | /v1/chat/completions, /v1/responses |
| Claude-native messages | /v1/messages |
| Gemini-native requests | /v1beta/models/{model}:generateContent |
| Images | /v1/images/generations, /v1/images/edits |
| Video | /v1/videos/generations |
| Music | /v1/music/generations |
| Worlds | /v1/worlds/generations plus world status and media asset endpoints |
| 3D | /v1/3d/generations |
| Audio | /v1/audio/speech, /v1/audio/transcriptions, /v1/audio/translations |
| Realtime | /v1/realtime?model={model} |
| Embeddings and rerank | /v1/embeddings, /v1/rerank |
| Text translation | /v1/translations |
Best Practices
API Key Safety
Use environment variables and server-side calls. Never expose keys in frontend code.
Check Non-Chat Requests
Read
/v1/models?recommended_for=... and /v1/models/:model before retrying image, video, music, 3D, translation, audio, embedding, or rerank requests.Smallest Runnable Example
Generate one working call before adding abstractions, queues, or UI flows.
Use Structured Hints
Parse
did_you_mean, retry_after, alternatives, and recommended_request before changing the code.FAQ
Skill not triggering automatically?
Skill not triggering automatically?
Mention “TokenLab” or “TokenLab API” in the request, for example:
Use TokenLab to add image generation to my Node.js app.Which coding agents are supported?
Which coding agents are supported?
Any coding agent that supports shared skill or rules directories can use the folder. The
skills installer handles supported agents automatically.How do I update the skill?
How do I update the skill?
Rerun the install command. It refreshes the local copy from the canonical public repository.
Resources
Agent-First API
Structured error hints and recovery behavior
API Documentation
Endpoint-specific setup and API reference
Models
Browse available models
llms.txt
Machine-readable API overview for agents
Questions? Use GitHub Issues or contact support@tokenlab.sh.