### Install and Configure Environment Source: https://docs.tokenlab.sh/integrations/coding-agent-skill Commands to install the required SDK and set the API key environment variable for the chat example. ```bash pip install openai export TOKENLAB_API_KEY="sk-your-api-key" python app.py ``` -------------------------------- ### Install OpenAI Go SDK Source: https://docs.tokenlab.sh/guides/sdks Command to install the OpenAI Go library. ```bash go get github.com/openai/openai-go/v3 ``` -------------------------------- ### Install OpenAI-Compatible Provider Source: https://docs.tokenlab.sh/integrations/vercel-ai-sdk Install the standard OpenAI-compatible provider package. ```bash npm install ai @ai-sdk/openai-compatible ``` -------------------------------- ### Install Anthropic SDK Source: https://docs.tokenlab.sh/integrations/anthropic-sdk Install the required SDK package for your environment. ```bash pip install anthropic ``` ```bash npm install @anthropic-ai/sdk ``` -------------------------------- ### Install TokenLab Provider Package Source: https://docs.tokenlab.sh/integrations/vercel-ai-sdk Install the lightweight provider wrapper for Vercel AI SDK. ```bash npm install ai @tokenlabai/ai-sdk-provider ``` -------------------------------- ### Install LiteLLM Proxy Source: https://docs.tokenlab.sh/integrations/litellm Install the LiteLLM package with proxy support. ```bash pip install 'litellm[proxy]' ``` -------------------------------- ### Install Client Libraries Source: https://docs.tokenlab.sh/quickstart Install the necessary SDKs for your preferred programming language to interact with the TokenLab API. ```bash pip install openai ``` ```bash npm install openai ``` ```bash go get github.com/openai/openai-go/v3 ``` ```bash composer require openai-php/client ``` -------------------------------- ### Install and Test TokenLab MCP Server Source: https://docs.tokenlab.sh/integrations/tokenlab-mcp-server Clone the repository and install dependencies to prepare the server for execution. ```bash git clone https://github.com/hedging8563/tokenlab-mcp-server.git cd tokenlab-mcp-server npm install npm test ``` -------------------------------- ### Install and onboard the TokenLab provider plugin Source: https://docs.tokenlab.sh/guides/tokenlab-provider Use these commands to install the plugin and authenticate with your TokenLab API key. ```bash openclaw plugins install @tokenlabai/openclaw-provider openclaw onboard --tokenlab-api-key "$TOKENLAB_API_KEY" ``` -------------------------------- ### Install Gemini CLI Source: https://docs.tokenlab.sh/integrations/gemini-cli Installs the Gemini CLI globally using npm. ```bash npm install -g @google/gemini-cli ``` -------------------------------- ### Install OpenCode Source: https://docs.tokenlab.sh/integrations/opencode Methods to install the OpenCode CLI tool via script, Homebrew, or Go. ```bash curl -fsSL https://opencode.ai/install | bash ``` ```bash brew install opencode-ai/tap/opencode ``` ```bash brew install anomalyco/tap/opencode ``` ```bash go install github.com/opencode-ai/opencode@latest ``` -------------------------------- ### Install OpenAI Provider for Native Behavior Source: https://docs.tokenlab.sh/integrations/vercel-ai-sdk Install the standard OpenAI provider for Responses-native behavior. ```bash npm install ai @ai-sdk/openai ``` -------------------------------- ### Install OpenAI Node SDK Source: https://docs.tokenlab.sh/guides/sdks Command to install the OpenAI Node.js library. ```bash npm install openai ``` -------------------------------- ### Install OpenLIT and OpenAI SDK Source: https://docs.tokenlab.sh/integrations/openlit Install the necessary packages via pip to enable OpenLIT instrumentation. ```bash pip install openlit openai ``` -------------------------------- ### Install Phoenix Dependencies Source: https://docs.tokenlab.sh/integrations/phoenix Install the necessary packages for Phoenix and OpenAI instrumentation. ```bash pip install arize-phoenix openinference-instrumentation-openai openai ``` -------------------------------- ### Install Opik and OpenAI SDK Source: https://docs.tokenlab.sh/integrations/opik Install the necessary Python packages to enable Opik tracing with the OpenAI SDK. ```bash pip install opik openai ``` -------------------------------- ### Verify OpenCode Installation Source: https://docs.tokenlab.sh/integrations/opencode Check the installed version of the OpenCode CLI. ```bash opencode --version ``` -------------------------------- ### Install LangChain dependencies Source: https://docs.tokenlab.sh/integrations/langchain Install the necessary LangChain packages and FAISS for vector storage. ```bash pip install langchain langchain-openai langchain-community faiss-cpu ``` -------------------------------- ### Install OpenAI Python SDK Source: https://docs.tokenlab.sh/guides/sdks Command to install the OpenAI Python library. ```bash pip install openai ``` -------------------------------- ### Start TokenLab MCP Server Source: https://docs.tokenlab.sh/integrations/tokenlab-mcp-server Launch the server process over stdio. ```bash npm start ``` -------------------------------- ### Start LiteLLM Proxy Source: https://docs.tokenlab.sh/integrations/litellm Launch the proxy server using the configuration file. ```bash export OPENAI_API_KEY="sk-your-tokenlab-key" litellm --config litellm-config.yaml --port 4000 ``` -------------------------------- ### Install OpenAI SDK dependencies Source: https://docs.tokenlab.sh/integrations/openai-sdk Install the necessary packages for Python, JavaScript, or Go to interact with the OpenAI-compatible API. ```bash pip install openai ``` ```bash npm install openai ``` ```bash go get github.com/openai/openai-go/v3 ``` -------------------------------- ### Install TokenLab API Integration Skill Source: https://docs.tokenlab.sh/integrations/coding-agent-skill Use this command to perform a non-interactive installation of the shared skill from the canonical repository. ```bash npx skills add https://github.com/hedging8563/tokenlab-skills --skill tokenlab-api-integration -y ``` -------------------------------- ### Install OpenLLMetry dependencies Source: https://docs.tokenlab.sh/integrations/openllmetry Install the required OpenTelemetry instrumentation and OpenAI SDK packages. ```bash pip install opentelemetry-instrumentation-openai openai ``` -------------------------------- ### Create Translation Request Examples Source: https://docs.tokenlab.sh/api-reference/audio/create-translation Examples of how to initiate an audio translation request using various programming languages and tools. ```bash curl -X POST "https://api.tokenlab.sh/v1/audio/translations" \ -H "Authorization: Bearer sk-your-api-key" \ -F "file=@german_audio.mp3" \ -F "model=whisper-1" ``` ```python from openai import OpenAI client = OpenAI( api_key="sk-your-api-key", base_url="https://api.tokenlab.sh/v1" ) with open("german_audio.mp3", "rb") as audio_file: response = client.audio.translations.create( model="whisper-1", file=audio_file ) print(response.text) ``` ```javascript import OpenAI from 'openai'; import fs from 'fs'; const client = new OpenAI({ apiKey: 'sk-your-api-key', baseURL: 'https://api.tokenlab.sh/v1' }); const response = await client.audio.translations.create({ model: 'whisper-1', file: fs.createReadStream('german_audio.mp3') }); console.log(response.text); ``` ```php true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer sk-your-api-key' ], CURLOPT_POSTFIELDS => [ 'file' => $file, 'model' => 'whisper-1' ] ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); echo $data['text']; ``` -------------------------------- ### Install LlamaIndex dependencies Source: https://docs.tokenlab.sh/integrations/llamaindex Install the required core and OpenAI-like integration packages for LlamaIndex. ```bash pip install llama-index-core \ llama-index-readers-file \ llama-index-llms-openai-like \ llama-index-embeddings-openai-like ``` -------------------------------- ### Verify Installation Source: https://docs.tokenlab.sh/integrations/claude-code Commands to check the version and run diagnostic checks for the CLI. ```bash claude --version claude doctor ``` -------------------------------- ### Verify Skill Installation Source: https://docs.tokenlab.sh/integrations/coding-agent-skill Query the coding agent to confirm that the tokenlab-api-integration skill is correctly installed and available. ```text What skills are available? ``` -------------------------------- ### Create Video Generation Task Examples Source: https://docs.tokenlab.sh/openapi.json Examples of request bodies for different video generation modes including text-to-video, image-to-video, and reference-to-video. ```json { "model": "veo3.1", "prompt": "A cinematic shot of a golden retriever running through a field of sunflowers", "duration": 5, "aspect_ratio": "16:9" } ``` ```json { "model": "hailuo-2.3-standard", "prompt": "Make this image come alive with gentle movement", "operation": "image-to-video", "image_url": "https://example.com/image.jpg", "duration": 6 } ``` ```json { "model": "veo3.1", "prompt": "Keep the same subject identity and palette while adding subtle motion", "operation": "reference-to-video", "reference_images": [ "https://example.com/ref-a.jpg" ], "duration": 8, "aspect_ratio": "9:16", "resolution": "720p" } ``` -------------------------------- ### Ask a Question Source: https://docs.tokenlab.sh/integrations/gemini-cli Example of a natural language query submitted to the CLI. ```text > What is the best way to structure a React app? ``` -------------------------------- ### Retrieve Material Assets Example Source: https://docs.tokenlab.sh/openapi.json Example JSON response for a successful material asset retrieval request. ```json { "assets": [ { "id": "seedance_asset_123", "object": "seedance.material_asset", "group_id": "seedance_group_virtual_123", "library_type": "aigc_avatar", "asset_name": "Front view", "asset_type": "Image", "status": "ACTIVE", "ready": true, "error_message": null, "metadata": null, "created_at": 1782998400000 } ], "next_page_token": null } ``` -------------------------------- ### Create Seedance Material Asset Request Examples Source: https://docs.tokenlab.sh/openapi.json Provides request body examples for creating virtual-avatar and real-person material assets. ```yaml "examples": { "virtual_avatar_asset": { "summary": "Create a virtual-avatar material asset", "value": { "asset_url": "https://example.com/reference.png", "asset_name": "Front view", "asset_type": "Image", "library_type": "aigc_avatar", "group_id": "seedance_group_virtual_123" } }, "real_person_asset": { "summary": "Create a real-person material asset", "value": { "asset_url": "https://example.com/verified-person-closeup.jpg", "asset_name": "Creator A close-up", "asset_type": "Image", "library_type": "liveness_face", "group_id": "seedance_group_real_123" } } } ``` -------------------------------- ### Initialize Gemini CLI Source: https://docs.tokenlab.sh/integrations/gemini-cli Navigate to the project directory and launch the CLI to begin the initial setup process. ```bash cd your-project gemini ``` -------------------------------- ### Get World Status API Examples Source: https://docs.tokenlab.sh/api-reference/worlds/get-world-status Examples for checking the status of a world generation task using cURL, Python, and JavaScript. ```bash curl "https://api.tokenlab.sh/v1/worlds/generations/ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ -H "Authorization: Bearer sk-your-api-key" ``` ```python import requests import time task_id = "ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" while True: response = requests.get( f"https://api.tokenlab.sh/v1/worlds/generations/{task_id}", headers={"Authorization": "Bearer sk-your-api-key"}, ) result = response.json() if result["status"] in ["completed", "failed", "timeout"]: print(result) break time.sleep(10) ``` ```javascript const taskId = 'ldtask_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'; const response = await fetch(`https://api.tokenlab.sh/v1/worlds/generations/${taskId}`, { headers: { Authorization: 'Bearer sk-your-api-key' } }); const result = await response.json(); console.log(result.status, result.world_marble_url); ``` -------------------------------- ### Initialize Agent with OpenAI-compatible Client Source: https://docs.tokenlab.sh/integrations/openai-agents-sdk Demonstrates setting up an AsyncOpenAI client and running an agent using the OpenAIChatCompletionsModel. ```python import asyncio import os from openai import AsyncOpenAI from agents import Agent, OpenAIChatCompletionsModel, Runner, set_tracing_disabled client = AsyncOpenAI( base_url=os.getenv("TOKENLAB_BASE_URL", "https://api.tokenlab.sh/v1"), api_key=os.environ["TOKENLAB_API_KEY"], ) set_tracing_disabled(disabled=True) async def main(): agent = Agent( name="Assistant", instructions="You are concise and practical.", model=OpenAIChatCompletionsModel( model=os.getenv("TOKENLAB_MODEL", "gpt-5.4-mini"), openai_client=client, ), ) result = await Runner.run(agent, "Explain custom model providers in one paragraph.") print(result.final_output) asyncio.run(main()) ``` -------------------------------- ### Initialize OpenHands Configuration Source: https://docs.tokenlab.sh/integrations/openhands Run the setup command to configure local defaults for CLI or headless usage. ```bash make setup-config ``` -------------------------------- ### Verify Gemini CLI Installation Source: https://docs.tokenlab.sh/integrations/gemini-cli Checks the installed version of the Gemini CLI. ```bash gemini --version ``` -------------------------------- ### Verify Codex CLI Installation Source: https://docs.tokenlab.sh/integrations/codex-cli Check the installed version of the Codex CLI. ```bash codex --version ``` -------------------------------- ### Prepare Media Asset Upload Requests Source: https://docs.tokenlab.sh/api-reference/worlds/prepare-media-asset-upload Examples for initiating a media asset upload using different programming environments. ```bash curl -X POST "https://api.tokenlab.sh/v1/worlds/media-assets/prepare-upload" \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "file_name": "reference.png", "kind": "image", "extension": "png" }' ``` ```python import requests response = requests.post( "https://api.tokenlab.sh/v1/worlds/media-assets/prepare-upload", headers={"Authorization": "Bearer sk-your-api-key"}, json={"file_name": "reference.png", "kind": "image", "extension": "png"}, ) print(response.json()["media_asset"]["media_asset_id"]) ``` ```javascript const response = await fetch('https://api.tokenlab.sh/v1/worlds/media-assets/prepare-upload', { method: 'POST', headers: { Authorization: 'Bearer sk-your-api-key', 'Content-Type': 'application/json' }, body: JSON.stringify({ file_name: 'reference.png', kind: 'image', extension: 'png' }) }); const prepared = await response.json(); console.log(prepared.media_asset.media_asset_id, prepared.upload_info.upload_url); ``` -------------------------------- ### Initialize OpenLIT and OpenAI Client Source: https://docs.tokenlab.sh/integrations/openlit Initialize OpenLIT and configure the OpenAI client to point to the TokenLab base URL. ```python import os import openlit from openai import OpenAI openlit.init() client = OpenAI( api_key=os.environ["TOKENLAB_API_KEY"], base_url="https://api.tokenlab.sh/v1", ) response = client.chat.completions.create( model="claude-sonnet-5", messages=[{"role": "user", "content": "Hello from OpenLIT"}], ) ``` -------------------------------- ### Install Codex CLI Source: https://docs.tokenlab.sh/integrations/codex-cli Global installation of the Codex CLI package via npm. ```bash npm install -g @openai/codex ``` -------------------------------- ### BadRequest Response Example Source: https://docs.tokenlab.sh/openapi.json Example JSON structure for a 400 Bad Request response. ```json "example": { "error": { "message": "model: Model is required", "type": "invalid_request_error", "param": "model" }, "validation_errors": [ { "field": "model", "message": "Model is required" } ] } ``` -------------------------------- ### Promptfoo Configuration Example Source: https://docs.tokenlab.sh/integrations/promptfoo Define providers and test cases in your promptfoo configuration file using TokenLab's API base URL. ```yaml description: TokenLab provider example prompts: - 'Answer in one concise paragraph: {{question}}' providers: - id: openai:chat:gpt-5.4-mini label: tokenlab-chat-gpt-5.4-mini config: apiBaseUrl: https://api.tokenlab.sh/v1 apiKey: '{{env.TOKENLAB_API_KEY}}' - id: openai:responses:gpt-5.5 label: tokenlab-responses-gpt-5.5 config: apiBaseUrl: https://api.tokenlab.sh/v1 apiKey: '{{env.TOKENLAB_API_KEY}}' tests: - vars: question: What are two practical ways to evaluate an LLM gateway? assert: - type: contains-any value: - latency - reliability - cost - quality ``` -------------------------------- ### Initialize OpenAI Go Client Source: https://docs.tokenlab.sh/guides/sdks Configures the OpenAI Go client with the TokenLab base URL. ```go package main import ( openai "github.com/openai/openai-go/v3" "github.com/openai/openai-go/v3/option" ) func main() { client := openai.NewClient( option.WithAPIKey("sk-your-api-key"), option.WithBaseURL("https://api.tokenlab.sh/v1"), ) _ = client } ``` -------------------------------- ### Basic OpenCode Usage Source: https://docs.tokenlab.sh/integrations/opencode Commands for starting interactive mode, running prompts, and specifying models. ```bash opencode ``` ```bash opencode "Explain this codebase" ``` ```bash opencode --model tokenlab/gpt-5.4 "Fix the bugs in main.py" ``` -------------------------------- ### Install AutoGen Dependencies Source: https://docs.tokenlab.sh/integrations/autogen Install the necessary AutoGen packages and extensions to support OpenAI-compatible clients. ```bash pip install -U autogen-agentchat "autogen-ext[openai]" pyyaml ``` -------------------------------- ### Verify Configuration Source: https://docs.tokenlab.sh/integrations/gemini-cli Check environment variables and test the connection to the Gemini service. ```bash # Check environment variables echo $GEMINI_API_KEY echo $GOOGLE_GEMINI_BASE_URL # Test connection gemini ``` -------------------------------- ### Define Multimodal Embedding Request Example Source: https://docs.tokenlab.sh/openapi.json Example configuration for text-based multimodal embedding requests. ```json "examples": { "text": { "summary": "Text input", "value": { "model": "jina-embeddings-v4", "input": { "text": "Describe this product for semantic search." } } } } ``` -------------------------------- ### Initialize multiple models Source: https://docs.tokenlab.sh/integrations/langchain Configure different model instances by specifying the model name and TokenLab base URL. ```python from langchain_openai import ChatOpenAI gpt = ChatOpenAI( model="gpt-5.4", api_key="sk-your-key", base_url="https://api.tokenlab.sh/v1", ) claude = ChatOpenAI( model="claude-sonnet-4-6", api_key="sk-your-key", base_url="https://api.tokenlab.sh/v1", ) gemini = ChatOpenAI( model="gemini-3.5-flash", api_key="sk-your-key", base_url="https://api.tokenlab.sh/v1", ) deepseek = ChatOpenAI( model="deepseek-r1", api_key="sk-your-key", base_url="https://api.tokenlab.sh/v1", ) ``` -------------------------------- ### Define Embedding Request Examples Source: https://docs.tokenlab.sh/openapi.json Examples for single and batch text inputs for the embeddings endpoint. ```json "examples": { "single": { "summary": "Single text embedding", "value": { "model": "text-embedding-3-small", "input": "The quick brown fox jumps over the lazy dog" } }, "batch": { "summary": "Batch embeddings", "value": { "model": "text-embedding-3-small", "input": [ "Hello world", "How are you?" ] } } } ``` -------------------------------- ### Initialize MCP Server Source: https://docs.tokenlab.sh/integrations/tokenlab-mcp-server Run this command in a terminal to verify the server installation and surface potential network or npm errors. ```bash npx -y @tokenlabai/mcp-server ``` -------------------------------- ### Define Audio Speech Request Examples Source: https://docs.tokenlab.sh/openapi.json Provides example payloads for basic and high-definition text-to-speech requests. ```json { "model": "tts-1", "input": "Hello, welcome to TokenLab!", "voice": "alloy" } ``` ```json { "model": "tts-1-hd", "input": "This is high quality speech synthesis.", "voice": "nova", "response_format": "mp3", "speed": 1 } ``` -------------------------------- ### Create Embedding Request Examples Source: https://docs.tokenlab.sh/api-reference/embeddings/create-embedding Examples of how to generate embeddings using various programming languages and tools. ```bash curl -X POST "https://api.tokenlab.sh/v1/embeddings" \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "The quick brown fox jumps over the lazy dog" }' ``` ```python from openai import OpenAI client = OpenAI( api_key="sk-your-api-key", base_url="https://api.tokenlab.sh/v1" ) response = client.embeddings.create( model="text-embedding-3-small", input="The quick brown fox jumps over the lazy dog" ) embedding = response.data[0].embedding print(f"Embedding dimension: {len(embedding)}") print(f"First 5 values: {embedding[:5]}") ``` ```javascript import OpenAI from 'openai'; const client = new OpenAI({ apiKey: 'sk-your-api-key', baseURL: 'https://api.tokenlab.sh/v1' }); const response = await client.embeddings.create({ model: 'text-embedding-3-small', input: 'The quick brown fox jumps over the lazy dog' }); console.log(response.data[0].embedding.slice(0, 5)); ``` ```php true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Authorization: Bearer sk-your-api-key' ], CURLOPT_POSTFIELDS => json_encode([ 'model' => 'text-embedding-3-small', 'input' => 'The quick brown fox jumps over the lazy dog' ]) ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); print_r(array_slice($data['data'][0]['embedding'], 0, 5)); ``` -------------------------------- ### Create Music Generation Request Source: https://docs.tokenlab.sh/api-reference/music/create-music Examples for initiating a music generation task across various programming languages. ```bash curl -X POST "https://api.tokenlab.sh/v1/music/generations" \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "model": "suno_music", "mv": "chirp-v4", "prompt": "An upbeat electronic dance track with heavy bass", "title": "Night Drive", "tags": "electronic, EDM, energetic" }' ``` ```python import requests response = requests.post( "https://api.tokenlab.sh/v1/music/generations", headers={"Authorization": "Bearer sk-your-api-key"}, json={ "model": "suno_music", "mv": "chirp-v4", "prompt": "An upbeat electronic dance track with heavy bass", "title": "Night Drive", "tags": "electronic, EDM, energetic" } ) task_id = response.json()["id"] print(f"Task ID: {task_id}") ``` ```javascript const response = await fetch('https://api.tokenlab.sh/v1/music/generations', { method: 'POST', headers: { 'Authorization': 'Bearer sk-your-api-key', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'suno_music', mv: 'chirp-v4', prompt: 'An upbeat electronic dance track with heavy bass', title: 'Night Drive', tags: 'electronic, EDM, energetic' }) }); const data = await response.json(); console.log(`Task ID: ${data.id}`); ``` ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { payload := map[string]interface{}{ "model": "suno_music", "mv": "chirp-v4", "prompt": "An upbeat electronic dance track with heavy bass", "title": "Night Drive", "tags": "electronic, EDM, energetic", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.tokenlab.sh/v1/music/generations", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer sk-your-api-key") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) fmt.Printf("Task ID: %s\n", result["id"]) } ``` ```php true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Authorization: Bearer sk-your-api-key' ], CURLOPT_POSTFIELDS => json_encode([ 'model' => 'suno_music', 'mv' => 'chirp-v4', 'prompt' => 'An upbeat electronic dance track with heavy bass', 'title' => 'Night Drive', 'tags' => 'electronic, EDM, energetic' ]) ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); echo "Task ID: " . $data['id']; ``` -------------------------------- ### Common OpenCode Commands Source: https://docs.tokenlab.sh/integrations/opencode Examples of using OpenCode for code analysis, generation, review, and error fixing. ```bash opencode "What does this function do?" < src/utils.ts ``` ```bash opencode "Create a REST API with Express" ``` ```bash git diff | opencode "Review these changes" ``` ```bash opencode "Fix the TypeScript errors in this project" ``` -------------------------------- ### Discover Video Models Source: https://docs.tokenlab.sh/guides/video-generation Retrieve a list of recommended models for video generation tasks. ```bash curl "https://api.tokenlab.sh/v1/models?recommended_for=video" \ -H "Authorization: Bearer sk-your-api-key" ``` -------------------------------- ### Initialize Python Client Source: https://docs.tokenlab.sh/integrations/autogen Initialize the OpenAIChatCompletionClient and AssistantAgent in Python. ```python import os from autogen_agentchat.agents import AssistantAgent from autogen_ext.models.openai import OpenAIChatCompletionClient model_client = OpenAIChatCompletionClient( model="claude-sonnet-5", base_url="https://api.tokenlab.sh/v1", api_key=os.environ["TOKENLAB_API_KEY"], model_info={ "function_calling": True, "json_output": True, "vision": False, "family": "claude", }, ) agent = AssistantAgent("assistant", model_client=model_client) ``` -------------------------------- ### Rerank API Request Examples Source: https://docs.tokenlab.sh/api-reference/rerank/create-rerank Examples of how to send a POST request to the rerank endpoint across various programming languages. ```bash curl -X POST "https://api.tokenlab.sh/v1/rerank" \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3-vl-rerank", "query": "What is machine learning?", "documents": [ "Machine learning is a subset of AI", "The weather is nice today", "Deep learning uses neural networks" ], "top_n": 2, "return_documents": true }' ``` ```python import requests response = requests.post( "https://api.tokenlab.sh/v1/rerank", headers={"Authorization": "Bearer sk-your-api-key"}, json={ "model": "qwen3-vl-rerank", "query": "What is machine learning?", "documents": [ "Machine learning is a subset of AI", "The weather is nice today", "Deep learning uses neural networks" ], "top_n": 2 } ) print(response.json()) ``` ```javascript const response = await fetch('https://api.tokenlab.sh/v1/rerank', { method: 'POST', headers: { 'Authorization': 'Bearer sk-your-api-key', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'qwen3-vl-rerank', query: 'What is machine learning?', documents: [ 'Machine learning is a subset of AI', 'The weather is nice today', 'Deep learning uses neural networks' ], top_n: 2 }) }); const data = await response.json(); console.log(data.results); ``` ```go package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { payload := map[string]interface{}{ "model": "qwen3-vl-rerank", "query": "What is machine learning?", "documents": []string{ "Machine learning is a subset of AI", "The weather is nice today", "Deep learning uses neural networks", }, "top_n": 2, } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.tokenlab.sh/v1/rerank", bytes.NewBuffer(body)) req.Header.Set("Authorization", "Bearer sk-your-api-key") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) fmt.Println(result["results"]) } ``` ```php true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Authorization: Bearer sk-your-api-key' ], CURLOPT_POSTFIELDS => json_encode([ 'model' => 'qwen3-vl-rerank', 'query' => 'What is machine learning?', 'documents' => [ 'Machine learning is a subset of AI', 'The weather is nice today', 'Deep learning uses neural networks' ], 'top_n' => 2 ]) ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); print_r($data['results']); ``` -------------------------------- ### Edit Image Request Examples Source: https://docs.tokenlab.sh/api-reference/images/edit-image Examples of how to perform an image edit request across various programming languages and tools. ```bash curl -X POST "https://api.tokenlab.sh/v1/images/edits" \ -H "Authorization: Bearer sk-your-api-key" \ -F "model=gpt-image-2" \ -F "image=@sunlit_lounge.png" \ -F "mask=@mask.png" \ -F "prompt=A sunlit indoor lounge area with a pool" \ -F "n=1" \ -F "size=1024x1024" ``` ```python from openai import OpenAI client = OpenAI( api_key="sk-your-api-key", base_url="https://api.tokenlab.sh/v1" ) response = client.images.edit( model="gpt-image-2", image=open("sunlit_lounge.png", "rb"), mask=open("mask.png", "rb"), prompt="A sunlit indoor lounge area with a pool", n=1, size="1024x1024" ) print(response.data[0].url) ``` ```javascript import OpenAI from 'openai'; import fs from 'fs'; const client = new OpenAI({ apiKey: 'sk-your-api-key', baseURL: 'https://api.tokenlab.sh/v1' }); const response = await client.images.edit({ model: 'gpt-image-2', image: fs.createReadStream('sunlit_lounge.png'), mask: fs.createReadStream('mask.png'), prompt: 'A sunlit indoor lounge area with a pool', n: 1, size: '1024x1024' }); console.log(response.data[0].url); ``` ```go package main import ( "bytes" "fmt" "io" "mime/multipart" "net/http" "os" ) func main() { body := &bytes.Buffer{} writer := multipart.NewWriter(body) writer.WriteField("model", "gpt-image-2") image, _ := os.Open("sunlit_lounge.png") defer image.Close() part, _ := writer.CreateFormFile("image", "sunlit_lounge.png") io.Copy(part, image) mask, _ := os.Open("mask.png") defer mask.Close() maskPart, _ := writer.CreateFormFile("mask", "mask.png") io.Copy(maskPart, mask) writer.WriteField("prompt", "A sunlit indoor lounge area with a pool") writer.WriteField("n", "1") writer.WriteField("size", "1024x1024") writer.Close() req, _ := http.NewRequest("POST", "https://api.tokenlab.sh/v1/images/edits", body) req.Header.Set("Authorization", "Bearer sk-your-api-key") req.Header.Set("Content-Type", writer.FormDataContentType()) client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() result, _ := io.ReadAll(resp.Body) fmt.Println(string(result)) } ``` ```php true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer sk-your-api-key' ], CURLOPT_POSTFIELDS => [ 'model' => 'gpt-image-2', 'image' => $image, 'mask' => $mask, 'prompt' => 'A sunlit indoor lounge area with a pool', 'n' => 1, 'size' => '1024x1024' ] ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); echo $data['data'][0]['url']; ``` -------------------------------- ### Anthropic Message Request Examples Source: https://docs.tokenlab.sh/openapi.json Examples of request payloads for the /v1/messages endpoint, demonstrating basic usage, system prompts, and streaming. ```json { "model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Hello, Claude!" } ] } ``` ```json { "model": "claude-sonnet-4-6", "max_tokens": 1024, "system": "You are a helpful assistant.", "messages": [ { "role": "user", "content": "What is 2+2?" } ] } ``` ```json { "model": "claude-sonnet-4-6", "max_tokens": 1024, "stream": true, "messages": [ { "role": "user", "content": "Tell me a story" } ] } ``` -------------------------------- ### Initialize API client Source: https://docs.tokenlab.sh/authentication Configure the OpenAI SDK to point to the TokenLab base URL using an environment variable for the API key. ```bash curl https://api.tokenlab.sh/v1/responses \ -H "Authorization: Bearer $TOKENLAB_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4", "input": "Hello!" }' ``` ```python import os from openai import OpenAI client = OpenAI( api_key=os.environ.get("TOKENLAB_API_KEY"), base_url="https://api.tokenlab.sh/v1" ) ``` ```javascript import OpenAI from 'openai'; const client = new OpenAI({ apiKey: process.env.TOKENLAB_API_KEY, baseURL: 'https://api.tokenlab.sh/v1' }); ``` -------------------------------- ### Configure and Run Aider Source: https://docs.tokenlab.sh/guides/ide-sdk-compatibility Set the OpenAI environment variables and launch Aider with a specific model. ```bash export OPENAI_API_KEY="sk-your-tokenlab-key" export OPENAI_BASE_URL="https://api.tokenlab.sh/v1" aider --model gpt-5.4 ``` -------------------------------- ### POST /v1/worlds/media-assets/prepare-upload Source: https://docs.tokenlab.sh/api-reference/worlds/prepare-media-asset-upload Creates a World Labs media asset record and returns an upload URL for the binary file. ```APIDOC ## POST /v1/worlds/media-assets/prepare-upload ### Description Create a World Labs media asset record and receive an upload URL for an image or video. Upload the binary file to the provided upload URL, then reference the returned media_asset_id in world generation. ### Method POST ### Endpoint https://api.tokenlab.sh/v1/worlds/media-assets/prepare-upload ### Parameters #### Request Body - **file_name** (string) - Required - Original file name, up to 64 characters. - **kind** (string) - Required - Media type: `image` or `video`. - **extension** (string) - Optional - Optional extension such as `png`, `jpg`, or `mp4`. - **metadata** (object) - Optional - Optional metadata object stored with the upstream media asset. ### Response #### Success Response (200) - **media_asset** (object) - Prepared World Labs media asset metadata. - **upload_info.upload_url** (string) - Signed upstream URL where the binary file should be uploaded. ``` -------------------------------- ### List Seedance material asset groups response example Source: https://docs.tokenlab.sh/openapi.json Example JSON response body returned when listing material asset groups. ```json { "groups": [ { "id": "seedance_group_virtual_123", "object": "seedance.material_asset_group", "library_type": "aigc_avatar", "group_name": "Product references", "description": "Reusable product shots", "status": "ACTIVE", "metadata": null, "created_at": 1782998400000 }, { "id": "seedance_group_real_123", "object": "seedance.material_asset_group", "library_type": "liveness_face", "group_name": "Creator A", "description": null, "status": "ACTIVE", "metadata": null, "created_at": 1782998400000 } ], "next_page_token": null } ``` -------------------------------- ### Generate Image Request Source: https://docs.tokenlab.sh/api-reference/images/create-image Examples of how to initiate an image generation request across different programming languages. ```bash curl -X POST "https://api.tokenlab.sh/v1/images/generations" \ -H "Authorization: Bearer sk-your-api-key" \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-3-pro-image", "prompt": "A cinematic portrait of a white cat sitting on a rainy windowsill", "aspect_ratio": "16:9", "resolution": "2k", "n": 1 }' ``` ```python from openai import OpenAI client = OpenAI( api_key="sk-your-api-key", base_url="https://api.tokenlab.sh/v1" ) response = client.images.generate( model="gemini-3-pro-image", prompt="A cinematic portrait of a white cat sitting on a rainy windowsill", aspect_ratio="16:9", resolution="2k", n=1 ) print(response.data[0].url) ``` ```javascript import OpenAI from 'openai'; const client = new OpenAI({ apiKey: 'sk-your-api-key', baseURL: 'https://api.tokenlab.sh/v1' }); const response = await client.images.generate({ model: 'gemini-3-pro-image', prompt: 'A cinematic portrait of a white cat sitting on a rainy windowsill', aspect_ratio: '16:9', resolution: '2k', n: 1 }); console.log(response.data[0].url); ``` ```php true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'Authorization: Bearer sk-your-api-key' ], CURLOPT_POSTFIELDS => json_encode([ 'model' => 'gemini-3-pro-image', 'prompt' => 'A cinematic portrait of a white cat sitting on a rainy windowsill', 'aspect_ratio' => '16:9', 'resolution' => '2k', 'n' => 1 ]) ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); echo $data['data'][0]['url']; ``` -------------------------------- ### Install Claude Code CLI Source: https://docs.tokenlab.sh/integrations/claude-code Commands to install the Claude Code CLI using either the recommended native script or the deprecated npm package. ```bash curl -fsSL https://claude.ai/install.sh | bash ``` ```bash npm install -g @anthropic-ai/claude-code ``` -------------------------------- ### Create Image Variation Request Examples Source: https://docs.tokenlab.sh/api-reference/images/create-variation Examples for sending a POST request to the image variations endpoint using various programming languages and tools. ```bash curl -X POST "https://api.tokenlab.sh/v1/images/variations" \ -H "Authorization: Bearer sk-your-api-key" \ -F "model=your-legacy-variation-model" \ -F "image=@cat.png" \ -F "n=2" \ -F "size=1024x1024" ``` ```python from openai import OpenAI client = OpenAI( api_key="sk-your-api-key", base_url="https://api.tokenlab.sh/v1" ) response = client.images.create_variation( model="your-legacy-variation-model", image=open("cat.png", "rb"), n=2, size="1024x1024" ) for image in response.data: print(image.url) ``` ```javascript import OpenAI from 'openai'; import fs from 'fs'; const client = new OpenAI({ apiKey: 'sk-your-api-key', baseURL: 'https://api.tokenlab.sh/v1' }); const response = await client.images.createVariation({ model: 'your-legacy-variation-model', image: fs.createReadStream('cat.png'), n: 2, size: '1024x1024' }); response.data.forEach(image => console.log(image.url)); ``` ```go package main import ( "bytes" "fmt" "io" "mime/multipart" "net/http" "os" ) func main() { body := &bytes.Buffer{} writer := multipart.NewWriter(body) writer.WriteField("model", "your-legacy-variation-model") file, _ := os.Open("cat.png") defer file.Close() part, _ := writer.CreateFormFile("image", "cat.png") io.Copy(part, file) writer.WriteField("n", "2") writer.WriteField("size", "1024x1024") writer.Close() req, _ := http.NewRequest("POST", "https://api.tokenlab.sh/v1/images/variations", body) req.Header.Set("Authorization", "Bearer sk-your-api-key") req.Header.Set("Content-Type", writer.FormDataContentType()) client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() result, _ := io.ReadAll(resp.Body) fmt.Println(string(result)) } ``` ```php true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer sk-your-api-key' ], CURLOPT_POSTFIELDS => [ 'model' => 'your-legacy-variation-model', 'image' => $image, 'n' => 2, 'size' => '1024x1024' ] ]); $response = curl_exec($ch); curl_close($ch); $data = json_decode($response, true); foreach ($data['data'] as $image) { echo $image['url'] . "\n"; } ``` -------------------------------- ### Configure Environment Variables Source: https://docs.tokenlab.sh/integrations/openai-agents-sdk Set the required API key, base URL, and model name as environment variables before initializing the client. ```bash export TOKENLAB_API_KEY="sk-your-tokenlab-key" export TOKENLAB_BASE_URL="https://api.tokenlab.sh/v1" export TOKENLAB_MODEL="gpt-5.4-mini" ``` -------------------------------- ### Install TokenLab MCP in Cline Source: https://docs.tokenlab.sh/integrations/tokenlab-mcp-server Command to register the TokenLab MCP server using the Cline CLI. ```bash cline mcp add tokenlab --yes -- npx -y @tokenlabai/mcp-server ``` -------------------------------- ### Seedance Task Creation Request Example Source: https://docs.tokenlab.sh/openapi.json Example JSON payload for creating a new Seedance task, including model selection, content configuration, and generation parameters. ```json "example": { "model": "doubao-seedance-2-0-260128", "content": [ { "type": "text", "text": "A cinematic forest at sunset" }, { "type": "image_url", "role": "reference_image", "image_url": { "url": "https://example.com/ref.png" } } ], "ratio": "16:9", "duration": 5, "resolution": "720p", "generate_audio": true } ``` -------------------------------- ### GET /v1beta/models Source: https://docs.tokenlab.sh/openapi.json List Gemini-native models. ```APIDOC ## GET /v1beta/models ### Description List Gemini-native models. ### Method GET ### Endpoint /v1beta/models ```