### Start OpenClaw Onboarding Source: https://www.tokenrouter.com/docs/openclaw-setup Starts the OpenClaw onboarding wizard and installs the OpenClaw Gateway as a background service. ```bash openclaw onboard --install-daemon ``` -------------------------------- ### Get Account Wallet - Response Example Source: https://www.tokenrouter.com/docs/management-api-documentation Example JSON response for the Get Account Wallet endpoint, showing top-up and voucher balances. ```json { "success": true, "message": "", "data": { "topUpBalance": 120.50, "voucherEfficientAmount": 30.00, "toppedUpSpent": 80.25, "voucherSpent": 10.00 } } ``` -------------------------------- ### Start OpenClaw Onboarding Source: https://www.tokenrouter.com/docs/openclaw-setup Run this command to start the onboarding wizard and install the OpenClaw Gateway as a background service. ```bash openclaw onboard --install-daemon ``` -------------------------------- ### Install TokenRouter on macOS/Linux with curl Source: https://www.tokenrouter.com/docs/setup-tokenrouter-in-codex-chatgpt Run this command in Terminal. Replace with your own API key before executing. Installs Codex/ChatGPT normally after setup. ```bash curl -fsSL https://raw.githubusercontent.com/TokenRouter-Tools/codex-inject/main/install.sh | bash -s -- ``` -------------------------------- ### Install TokenRouter on Windows with PowerShell Source: https://www.tokenrouter.com/docs/setup-tokenrouter-in-codex-chatgpt Run this command in Windows PowerShell. Replace with your own API key before executing. Installs Codex/ChatGPT normally after setup. ```powershell irm https://raw.githubusercontent.com/TokenRouter-Tools/codex-inject/main/install.ps1 | iex; install ``` -------------------------------- ### Install OpenClaw with npm Source: https://www.tokenrouter.com/docs/openclaw-setup Alternative installation method using npm. Use only if you already manage Node.js. ```bash npm install -g openclaw@latest ``` -------------------------------- ### Install OpenClaw with npm Source: https://www.tokenrouter.com/docs/openclaw-setup Alternative installation method using npm. Use only when you already manage Node.js on your computer. ```bash npm install -g openclaw@latest ``` -------------------------------- ### Send a test message to Claude Code Source: https://www.tokenrouter.com/docs/claude-code-setup Send a simple message to Claude Code to verify the setup. The example asks for a project directory structure overview. ```plaintext 请介绍一下这个项目的目录结构。 ``` -------------------------------- ### List API Keys (GET /api/management/api-keys) - curl example Source: https://www.tokenrouter.com/docs/management-api-documentation Returns a paginated list of API keys for the current account. Use page and page_size query parameters. Responses mask key values and do not expose internal IDs. ```bash curl -s "$BASE_URL/api/management/api-keys?page=1&page_size=10" \ -H "Authorization: Bearer $MGMT_KEY" ``` ```json { "success": true, "message": "", "data": { "page": 1, "page_size": 10, "total": 2, "items": [ { "name": "my-app-key", "key": "sk-abcd**********wxyz", "status": 1, "status_tips": "status: 1->enable 2->disable", "unlimited_quota": false, "unlimited_tips": "unlimited_quota: true->No-Limit false->Limit by remain_quota", "remain_quota": 10.0, "used_quota": 2.5, "expired_time": -1, "expired_time_tips": "expired_time: -1->Never-Expires 1xxxxxxxx->Expiry date UTC timestamp", "created_time": 1716200000 } ] } } ``` -------------------------------- ### Text to Image Generation Examples Source: https://www.tokenrouter.com/docs/how-to-use-image-models Examples for text-to-image generation using the OpenAI-compatible endpoint. ```http POST /v1/images/generations ``` ```bash curl -X POST https://api.tokenrouter.com/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "model": "openai/gpt-5-image", "prompt": "Draw an orange cat playing guitar on the moon.", "n": 2, "size": "1024x1024", "quality": "high", "background": "transparent" }' ``` ```python import requests API_BASE = "https://api.tokenrouter.com" API_KEY = "sk-*******************************" HEADERS = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } def images_generate(): data = { "model": "openai/gpt-5-image", "prompt": "Draw an orange cat playing guitar on the moon.", "n": 1, "size": "1024x1024", "quality": "high" } try: response = requests.post(f'{API_BASE}/v1/images/generations', headers=HEADERS, json=data) response.raise_for_status() result = response.json() print("Generated image URL:", result["data"][0]["url"]) except Exception as e: print("Error:", str(e)) ``` -------------------------------- ### Verify OpenClaw Installation Source: https://www.tokenrouter.com/docs/openclaw-setup Verifies that OpenClaw was installed successfully by printing the installed version. ```bash openclaw --version ``` -------------------------------- ### Install OpenClaw on macOS, Linux, or WSL2 Source: https://www.tokenrouter.com/docs/openclaw-setup Run this command in Terminal to install OpenClaw using the official installer script. ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` -------------------------------- ### Authentication Response Example Source: https://www.tokenrouter.com/docs/management-api-documentation Example JSON response from an authentication or API key listing endpoint, showing user data with API keys and quota fields. ```json { "success": true, "message": "", "data": [ { "email": "alice@example.com", "api_keys": [ { "name": "alice-key", "key": "sk-1234**********6789", "status": 1, "status_tips": "status: 1->enable 2->disable", "unlimited_quota": true, "unlimited_tips": "unlimited_quota: true->No-Limit false->Limit by remain_quota", "remain_quota": 0.0, "used_quota": 12.34, "expired_time": -1, "expired_time_tips": "expired_time: -1->Never-Expires 1xxxxxxxx->Expiry date UTC timestamp", "created_time": 1716200000 } ] }, { "email": "bob@example.com", "api_keys": [] } ] } ``` -------------------------------- ### Verify OpenClaw Installation Source: https://www.tokenrouter.com/docs/openclaw-setup Check that OpenClaw was installed successfully by displaying its version. ```bash openclaw --version ``` -------------------------------- ### Install Claude Code CLI via WinGet Source: https://www.tokenrouter.com/docs/claude-code-setup Alternative installation method for Windows when the official default installer fails. Versions installed via WinGet usually require manual updates. ```powershell winget install --id Anthropic.ClaudeCode -e ``` -------------------------------- ### Install OpenClaw on macOS/Linux/WSL2 Source: https://www.tokenrouter.com/docs/openclaw-setup Installs OpenClaw on macOS, Linux, or WSL2 using the official installer script. The installer detects the OS, installs dependencies, and installs the latest OpenClaw CLI. ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` -------------------------------- ### Hailuo Text to Video curl example Source: https://www.tokenrouter.com/docs/how-to-use-video-models Creates a video generation task using the MiniMax-Hailuo-2.3 model. The response contains a task_id to poll for completion. ```bash curl -X POST "https://api.tokenrouter.com/v1/video/generations" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "MiniMax-Hailuo-2.3", "prompt": "A white fox running across a snowy field, cinematic motion and soft lighting", "duration": 6, "size": "768P" }' ``` -------------------------------- ### Install Claude Code on macOS, Linux, or WSL Source: https://www.tokenrouter.com/docs/claude-code-setup Run the official installation script in your terminal. ```bash curl -fsSL https://claude.ai/install.sh | bash ``` -------------------------------- ### Hailuo Image to Video curl example Source: https://www.tokenrouter.com/docs/how-to-use-video-models Creates a video generation task from a source image using the I2V-01 model. The first_frame_image parameter specifies the input image URL. ```bash curl -X POST "https://api.tokenrouter.com/v1/video/generations" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "I2V-01", "prompt": "A subtle blink, gentle head movement, and a slow push-in camera", "first_frame_image": "https://example.com/source.png", "duration": 6, "size": "768P" }' ``` -------------------------------- ### Kling Text to Video curl example Source: https://www.tokenrouter.com/docs/how-to-use-video-models Creates a video generation task using the kling-v3 model in pro mode. The metadata includes aspect ratio, sound, and negative prompt. ```bash curl -X POST "https://api.tokenrouter.com/v1/video/generations" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "kling-v3", "prompt": "A silver robot walking through a rainy neon alley", "mode": "pro", "duration": "5", "metadata": { "aspect_ratio": "16:9", "sound": "on", "negative_prompt": "blurry, low quality" } }' ``` -------------------------------- ### Kling Image to Video curl example Source: https://www.tokenrouter.com/docs/how-to-use-video-models Creates a video generation task from an image using the kling-v2-6 model. The image parameter specifies the input image URL. ```bash curl -X POST "https://api.tokenrouter.com/v1/video/generations" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "kling-v2-6", "prompt": "The girl smiles slightly and the camera slowly pushes in", "image": "https://example.com/portrait.png", "mode": "pro", "duration": "5", "metadata": { "sound": "off", "negative_prompt": "flicker, blur" } }' ``` -------------------------------- ### Universal Video Model Request Example Source: https://www.tokenrouter.com/docs/how-to-use-video-models A JSON request body for generating a video with the kling-v3 model. It includes a prompt, metadata with mode, duration, aspect ratio, and sound settings. This example appears twice in the source, once in a code block and once in a numbered list. ```json { "model": "kling-v3", "prompt": "A futuristic city street at night, cinematic camera movement", "metadata": { "mode": "pro", "duration": "5", "aspect_ratio": "16:9", "sound": "on" } } ``` ```json { "model": "kling-v3", "prompt": "A futuristic city street at night, cinematic camera movement", "metadata": { "mode": "pro", "duration": "5", "aspect_ratio": "16:9", "sound": "on" } } ``` -------------------------------- ### Query response example Source: https://www.tokenrouter.com/docs/how-to-use-video-models Example JSON response returned when querying a task. The status field shows SUCCESS, and the result_url contains the final video URL. The data object includes details like duration, ratio, resolution, and audio settings. ```json { "code": "success", "message": "", "data": { "id": 17, "created_at": 1776323800, "updated_at": 1776323943, "task_id": "task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "platform": "45", "quota": 500, "action": "generate", "status": "SUCCESS", "result_url": "https://example.com/video.mp4", "progress": "100%", "properties": { "upstream_model_name": "dreamina-seedance-2-0-fast-260128", "origin_model_name": "dreamina-seedance-2-0-fast-260128" }, "data": { "duration": 5, "ratio": "16:9", "resolution": "720p", "generate_audio": true, "status": "succeeded" } } } ``` -------------------------------- ### Seedance Multimodal Video Generation with Python Source: https://www.tokenrouter.com/docs/how-to-use-video-models Python example using the requests library to call the TokenRouter video generation API with the dreamina-seedance-2-0-260128 model. It sends a prompt with image, audio, and video references, and returns the task_id from the response. Requires a valid TokenRouter API key. ```python import requests API_BASE = "https://api.tokenrouter.com" API_KEY = "" HEADERS = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } def seedance_video_all_guide(): url = f"{API_BASE}/v1/video/generations" payload = { "model": "dreamina-seedance-2-0-260128", "prompt": "Use the first-person POV framing from [Video 1] throughout, and use [Audio 1] as the background music throughout. First-person POV fruit tea promotional ad, seedance limited-edition apple fruit tea; opening frame is [Image 1], your hand picks a dew-covered Aksu red apple, a light, crisp apple tapping sound; 2–4 seconds: fast cuts, your hand drops apple chunks into a shaker, adds ice and tea base, shakes forcefully, ice clinking and shaking sounds sync with upbeat rhythmic beats, background audio: {Fresh-cut, shaken fresh}; 4–6 seconds: first-person close-up of the finished drink, layered fruit tea is poured into a clear cup, your hand gently squeezes milk foam to spread across the top, a pink brand sticker is applied to the cup, the camera moves closer to show the layered textures of the foam and fruit tea; 6–8 seconds: first-person hand-held toast shot, you raise the fruit tea from [Image 2] toward the camera (simulating handing it to the viewer), the cup label is clearly visible, background audio {Take a sip of fresh refreshment}, the final frame freezes on Image 2. All background voice audio uses a female voice.", "images": [ "https://ark-doc.tos-ap-southeast-1.bytepluses.com/doc_image/r2v_tea_pic1.jpg", "https://ark-doc.tos-ap-southeast-1.bytepluses.com/doc_image/r2v_tea_pic2.jpg" ], "audios": [ "https://ark-doc.tos-ap-southeast-1.bytepluses.com/doc_audio/r2v_tea_audio1.mp3" ], "videos": [ "https://ark-doc.tos-ap-southeast-1.bytepluses.com/doc_video/r2v_tea_video1.mp4" ], "metadata": { "duration": 10, "resolution": "1080p" } } try: resp = requests.post(url, json=payload, headers=HEADERS, timeout=60) resp.raise_for_status() data = resp.json() return data["task_id"] except Exception as e: print(f"occur error: {e}") ``` -------------------------------- ### Seedance Text to Video curl example Source: https://www.tokenrouter.com/docs/how-to-use-video-models Creates a video generation task using the doubao-seedance-1-0-lite-t2v model. The metadata includes duration, resolution, ratio, and audio generation. ```bash curl -X POST "https://api.tokenrouter.com/v1/video/generations" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "doubao-seedance-1-0-lite-t2v", "prompt": "A vintage sports car driving along a coastal road at sunset", "metadata": { "duration": 5, "resolution": "1080p", "ratio": "16:9", "generate_audio": true } }' ``` -------------------------------- ### Seedance Image to Video curl example Source: https://www.tokenrouter.com/docs/how-to-use-video-models Creates a video generation task from an image using the doubao-seedance-1-0-lite-i2v model. The images parameter is an array of input image URLs. ```bash curl -X POST "https://api.tokenrouter.com/v1/video/generations" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{ "model": "doubao-seedance-1-0-lite-i2v", "prompt": "The subject looks up toward the camera while hair moves gently in the wind", "images": [ "https://example.com/input-image.png" ], "metadata": { "duration": 5, "resolution": "720p", "ratio": "9:16" } }' ``` -------------------------------- ### GET /v1/video/generations/{task_id} Source: https://www.tokenrouter.com/docs/how-to-use-video-models Queries the status of a video generation task. Poll every 2 to 5 seconds until the task succeeds, then read the final result_url. ```APIDOC ## GET /v1/video/generations/{task_id} ### Description Queries the status of a video generation task. Poll every 2 to 5 seconds until the task succeeds, then read the final `result_url`. ### Method GET ### Endpoint /v1/video/generations/{task_id} ### Parameters #### Path Parameters - **task_id** (string) - Required - The ID of the task to query. ### Response #### Success Response (200) - **status** (string) - The status of the task (e.g., pending, processing, succeeded, failed). - **result_url** (string) - The URL of the generated video, available after the task succeeds. #### Response Example ```json { "status": "succeeded", "result_url": "https://example.com/video.mp4" } ``` ``` -------------------------------- ### Get Member Wallet - Response (200) Source: https://www.tokenrouter.com/docs/management-api-documentation Example JSON response for the Get Member Wallet endpoint. Shows quotaTotal, quotaRemaining, and quotaSpent fields. ```json { "success": true, "message": "", "data": { "quotaTotal": 100.00, "quotaRemaining": 65.00, "quotaSpent": 35.00 } } ``` -------------------------------- ### GET /api/management/export/hour/usages Source: https://www.tokenrouter.com/docs/management-api-documentation Exports consumption usage logs as a CSV file. Supports optional start and end timestamps to define the query range, which is strictly limited to 1 hour. ```APIDOC ## GET /api/management/export/hour/usages ### Description Exports consumption usage logs as a CSV file. For enterprise accounts the query covers all members of the organization; for personal accounts it covers only the current user. The query time range is strictly limited to 1 hour (inclusive). ### Method GET ### Endpoint /api/management/export/hour/usages ### Parameters #### Query Parameters - **start_timestamp** (int) - Optional - Range start (Unix seconds). - **end_timestamp** (int) - Optional - Range end (Unix seconds). ### Request Example curl -s "$BASE_URL/api/management/export/hour/usages" \ -H "Authorization: Bearer $MGMT_KEY" \ -o usage_logs.csv ### Response #### Success Response (200) Returns a CSV file with the following columns: request_id, email, key_name, model_name, prompt_tokens, completion_tokens, cache_creation_tokens, cache_tokens, cost, created_at. #### Response Example request_id,email,key_name,model_name,prompt_tokens,completion_tokens,cache_creation_tokens,cache_tokens,cost,created_at req-abc123,alice@example.com,my-app-key,gpt-4o,1200,340,0,256,0.0124,1716250000 req-def456,bob@example.com,my-app-key,claude-3-5-sonnet,800,210,128,512,0.0089,1716251000 ### Errors Returned as JSON with HTTP 200 before the CSV stream begins. - `start_timestamp must not be later than end_timestamp` - Cause: `start > end`. - `time range must not exceed 1 hour` - Cause: Range wider than 1 hour. ``` -------------------------------- ### Callback URL configuration example Source: https://www.tokenrouter.com/docs/how-to-use-minimax-h3 Example JSON payload showing how to provide a callback_url when creating a task. The URL must be publicly accessible over HTTPS and must return the challenge value unchanged within 3 seconds during verification. ```json { "callback_url": "https://your-domain.example.com/callbacks/minimax-h3" } ``` -------------------------------- ### List Organization API Keys (GET /api/manage/org/api-keys) - curl example Source: https://www.tokenrouter.com/docs/management-api-documentation Lists API keys for the enterprise organization, grouped by member email. Requires the management key owner to belong to an organization. ```bash curl -s "$BASE_URL/api/management/org/api-keys" \ -H "Authorization: Bearer $MGMT_KEY" ```