### Install OpenClaw External Tools (Interactive) Source: https://docs.commonstack.ai/integration-guides/openclaw/openclaw-external-tools-integration-mcp Run this command to start the interactive setup script for OpenClaw and its external tool integrations. Follow the on-screen prompts to configure the Testnet environment and API key. ```bash curl -fsSL https://download.commonstack.ai/install.sh | bash ``` -------------------------------- ### Querying Documentation with `ask` Parameter Source: https://docs.commonstack.ai/user-guide/reasoning An example of how to query the documentation dynamically using the `ask` query parameter in an HTTP GET request. ```http GET https://docs.commonstack.ai/user-guide/reasoning.md?ask= ``` -------------------------------- ### Dynamic Documentation Query Example Source: https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key/list-access-key Perform an HTTP GET request to the current page URL with the `ask` query parameter to ask a question about the documentation. The question should be specific and in natural language. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key/list-access-key.md?ask= ``` -------------------------------- ### Python SDK Installation Source: https://docs.commonstack.ai/user-guide/google-gemini-models-compatibility Install the official Google Python SDK for interacting with Gemini models. ```bash pip install google-genai ``` -------------------------------- ### Example Codex Prompt Source: https://docs.commonstack.ai/integration-guides/codex A simple prompt to send to Codex after setup to verify the connection. This prompt asks Codex to inspect and summarize the current repository's structure. ```text Please inspect the current repository and summarize its top-level structure. ``` -------------------------------- ### Install and Restart OpenClaw Source: https://docs.commonstack.ai/user-guide/smart-routing Commands to install the UncommonRoute plugin for OpenClaw and restart the gateway. ```bash openclaw plugins install @anjieyang/uncommon-route openclaw gateway restart ``` -------------------------------- ### Start Claude Code Session Source: https://docs.commonstack.ai/integration-guides/claude-code-terminal Navigate to your project directory and start Claude Code from the terminal. ```bash cd /path/to/your/project claude ``` -------------------------------- ### Python OpenAI SDK Client Example Source: https://docs.commonstack.ai/user-guide/smart-routing Example of initializing the OpenAI Python client to use the local UncommonRoute proxy. Configure the base_url and api_key as shown. ```python from openai import OpenAI client = OpenAI( base_url="http://127.0.0.1:8403/v1", api_key="not-needed", ) response = client.chat.completions.create( model="uncommon-route/auto", messages=[{"role": "user", "content": "hello"}], ) ``` -------------------------------- ### Install UncommonRoute Source: https://docs.commonstack.ai/user-guide/smart-routing Install the uncommon-route package using pip. This is the first step to setting up the local routing layer. ```bash pip install uncommon-route ``` -------------------------------- ### Querying Documentation via HTTP GET Source: https://docs.commonstack.ai/integration-guides/openclaw Perform an HTTP GET request to query the documentation dynamically. Include your question as the 'ask' query parameter. ```http GET https://docs.commonstack.ai/integration-guides/openclaw.md?ask= ``` -------------------------------- ### Query Documentation with GET Request Source: https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key To get more information not directly on the page, perform an HTTP GET request to the current URL with an 'ask' query parameter. The question should be specific and in natural language. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/platform/service-access-key Perform an HTTP GET request to the current page URL with the 'ask' query parameter to dynamically query the documentation. The question should be specific and self-contained. Use this when the answer is not explicitly present or for clarification. ```http GET https://docs.commonstack.ai/platform/service-access-key.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/getcloudmodel Perform an HTTP GET request to the current page URL with the 'ask' query parameter to dynamically query documentation. The question should be specific and self-contained. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/getcloudmodel.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/api-references/endpoint-specifications Perform an HTTP GET request on the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific, self-contained, and written in natural language. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key/access-key-usage Perform an HTTP GET request to the current page URL with the `ask` query parameter to ask questions about the documentation. The question should be specific and in natural language. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key/access-key-usage.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/user-guide/pdf Perform an HTTP GET request on a documentation URL with the 'ask' query parameter to ask a question. The question should be specific and self-contained. Use this when the answer is not explicitly present, for clarification, or to retrieve related documentation. ```http GET https://docs.commonstack.ai/user-guide/pdf.md?ask= ``` -------------------------------- ### Curl Example: Multi-turn Conversation Source: https://docs.commonstack.ai/user-guide/google-gemini-models-compatibility Shows how to conduct a multi-turn conversation with the Gemini gateway using curl. This example includes prior turns to maintain context. ```bash curl --location --request POST 'https://api.commonstack.ai/google/v1beta/models/google/gemini-2.5-pro:generateContent' \ --header 'x-goog-api-key: ' \ --header 'Content-Type: application/json' \ --data-raw '{ "contents": [ { "role": "user", "parts": [ { "text": "Hello." } ] }, { "role": "model", "parts": [ { "text": "Hello! How can I help you today?" } ] }, { "role": "user", "parts": [ { "text": "Please write a four-line poem about the ocean." } ] } ] }' ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.commonstack.ai/user-guide/structured-output To get information not explicitly present on a page, perform an HTTP GET request with an `ask` query parameter. The response will contain an answer and relevant excerpts. ```http GET https://docs.commonstack.ai/user-guide/structured-output.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/api-references/endpoint-specifications/anthropic-compatible-api/messages Perform an HTTP GET request to the current page URL with the `ask` query parameter to dynamically query the documentation. The question should be specific, self-contained, and in natural language. Use this when the answer is not explicitly present, for clarification, or to retrieve related documentation. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/anthropic-compatible-api/messages.md?ask= ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.commonstack.ai/user-guide/smart-routing To get information not explicitly on the page, make an HTTP GET request to the page URL with an 'ask' query parameter containing your question. The response will include the answer and relevant documentation excerpts. ```http GET https://docs.commonstack.ai/user-guide/smart-routing.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/api-references/endpoint-specifications/openai-compatible-api/responses Perform an HTTP GET request to a documentation URL, including the `ask` query parameter with a natural language question. The response will contain a direct answer and relevant documentation excerpts. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/openai-compatible-api/responses.md?ask= ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.commonstack.ai/api-references/endpoint-specifications/openai-compatible-api/getcloudmodels Perform an HTTP GET request to the current page URL with the 'ask' query parameter to dynamically query the documentation. The question should be specific, self-contained, and in natural language. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/openai-compatible-api/getcloudmodels.md?ask= ``` -------------------------------- ### Quick Start with OpenAI SDK Source: https://docs.commonstack.ai/user-guide/openai-responses-compatible Initialize the OpenAI SDK with your access key and base URL, then create a response. Ensure your IAAS_ACCESS_KEY environment variable is set. ```typescript import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.IAAS_ACCESS_KEY, baseURL: "https://api.commonstack.ai/v1", }); const response = await client.responses.create({ model: "YOUR_MODEL_ID", input: "Introduce the Responses API in three sentences.", }); console.log(response.output_text); ``` -------------------------------- ### Get Daily Access Key Statistics Source: https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key/access-key-stats Retrieve daily token usage statistics for your access key. This example shows data grouped by date for a specific period. ```json { "code": 0, "msg": "ok", "data": { "stats": { "2026-03-02": { "date": "2026-03-02", "input_tokens": 4332, "output_tokens": 8298, "cost": "0.080571477", "request_count": 457 }, "2026-03-04": { "date": "2026-03-04", "input_tokens": 11508, "output_tokens": 138783, "cost": "0.553735233", "request_count": 186 }, "2026-03-05": { "date": "2026-03-05", "input_tokens": 13992, "output_tokens": 283925, "cost": "2864.03173404", "request_count": 265 } } } } ``` -------------------------------- ### Example Streaming Response Events Source: https://docs.commonstack.ai/user-guide/anthropic-sdk-compatibility This block shows a typical sequence of Server-Sent Events (SSE) received from a streaming request. It includes message start, content block updates, pings, and message stop events. ```text event: message_start data: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "anthropic/claude-opus-4-6", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}} event: content_block_start data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}} event: ping data: {"type": "ping"} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "!"}} event: content_block_stop data: {"type": "content_block_stop", "index": 0} event: message_delta data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null}, "usage": {"output_tokens": 15}} event: message_stop data: {"type": "message_stop"} ``` -------------------------------- ### Streaming Tool Use SSE Output Source: https://docs.commonstack.ai/user-guide/anthropic-sdk-compatibility Example of the Server-Sent Events (SSE) stream output when using tool integration. This shows the sequence of events, including message starts, content blocks for text and tool use, and message stops. ```text event: message_start data: {"type": "message_start", "message": {"id": "msg_014p7gG3wDgGV9EUtLvnow3U", "type": "message", "role": "assistant", "model": "anthropic/claude-opus-4-6", "stop_sequence": null, "usage": {"input_tokens": 472, "output_tokens": 2}, "content": [], "stop_reason": null}} event: content_block_start data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Okay, let's check the weather for San Francisco, CA:"}} event: content_block_stop data: {"type": "content_block_stop", "index": 0} event: content_block_start data: {"type": "content_block_start", "index": 1, "content_block": {"type": "tool_use", "id": "toolu_01T1x1fJ34qAmk2tNTrN7Up6", "name": "get_weather", "input": {}}} event: content_block_delta data: {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "{\"location\": \"San Francisco, CA\"}"}} event: content_block_stop data: {"type": "content_block_stop", "index": 1} event: message_delta data: {"type": "message_delta", "delta": {"stop_reason": "tool_use", "stop_sequence": null}, "usage": {"output_tokens": 89}} event: message_stop data: {"type": "message_stop"} ``` -------------------------------- ### Setup Codex/Cursor/OpenAI SDK Client Source: https://docs.commonstack.ai/user-guide/smart-routing Use this command to automatically set up clients for Codex, Cursor, or OpenAI SDK. Alternatively, manually set OPENAI_BASE_URL and OPENAI_API_KEY environment variables. OPENAI_BASE_URL must end with /v1. ```bash uncommon-route setup codex ``` ```bash export OPENAI_BASE_URL="http://localhost:8403/v1" export OPENAI_API_KEY="not-needed" ``` -------------------------------- ### Create Video from Text and Image Prompt Source: https://docs.commonstack.ai/user-guide/video-generation Use this endpoint to create videos from text prompts, optionally including a reference image, video, audio, and specifying parameters like aspect ratio, duration, resolution, and size. Ensure 'generate_audio' is set to true if audio is desired. ```bash curl -X POST "https://api.commonstack.ai/v1/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "model": "kling/kling-video-o1", "messages": [ { "role": "user", "content": [ { "type": "image_url", "image_url": { "url": "https://images.pdimagearchive.org/essays/propagating-propaganda/aquaticlife219161917baus_0195-edit.jpg?width=1580&height=800" }, "role": "first_frame" }, { "type": "video_url", "video_url": { "url": "https://commonstack.ai/video/sample.mp4" }, "role": "reference_video" }, { "type": "audio_url", "audio_url": { "url": "https://commonstack.ai/video/sample.mp3" }, "role": "reference_audio" }, { "type": "text", "text": "A serene mountain landscape at sunset with a lake in the foreground" } ] } ], "aspect_ratio": "16:9", "duration": 5, "resolution": "720p", "size": "1280x720", "generate_audio": true, }' ``` -------------------------------- ### Query Documentation via GET Request Source: https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key/delete-access-key To get more information not directly on the page, make a GET request to the page URL with an 'ask' query parameter containing your question. ```http GET https://docs.commonstack.ai/api-references/endpoint-specifications/platform-api/service-key/delete-access-key.md?ask= ``` -------------------------------- ### Start UncommonRoute Proxy Source: https://docs.commonstack.ai/user-guide/smart-routing Launch the UncommonRoute proxy server. The startup banner will display the upstream host, local proxy URL, dashboard URL, and a health-check command. It also indicates if upstream variables need to be set. ```bash uncommon-route serve ``` -------------------------------- ### Example Gemini Gateway Request Path Source: https://docs.commonstack.ai/user-guide/google-gemini-models-compatibility An example of a complete URL for a non-streaming content generation request. ```text POST https://api.commonstack.ai/google/v1beta/models/google/gemini-2.5-flash:generateContent ``` -------------------------------- ### Text Generation with Instructions Source: https://docs.commonstack.ai/user-guide/openai-responses-compatible Use the `instructions` field to provide system-level guidance for the AI, such as defining its role or desired output language. This example also sets verbosity and token limits. ```bash curl "https://api.commonstack.ai/v1/responses" \ -H "Authorization: Bearer $ACCESS_KEY" \ -H "Content-Type: application/json" \ -d '{ \ "model": "YOUR_MODEL_ID", \ "instructions": "You are a concise technical documentation writer. Reply in English.", \ "input": "What is SSE?", \ "text": { \ "verbosity": "low" \ }, \ "max_output_tokens": 300 \ }' ``` -------------------------------- ### Streaming output Source: https://docs.commonstack.ai/user-guide/google-gemini-models-compatibility This example demonstrates how to receive content from a Gemini model in a streaming fashion, allowing for real-time output. ```APIDOC ## POST /v1beta/models/{model}:streamGenerateContent ### Description Generates content from a specified Gemini model and streams the output in real-time. ### Method POST ### Endpoint /v1beta/models/{model}:streamGenerateContent ### Parameters #### Path Parameters - **model** (string) - Required - The model to use for streaming generation (e.g., google/gemini-2.5-flash). #### Request Body - **contents** (array) - Required - An array of content parts for the prompt. - **role** (string) - Required - The role of the speaker ('user' or 'model'). - **parts** (array) - Required - An array of content parts. - **text** (string) - Required - The text content. ### Request Example ```json { "contents": [ { "role": "user", "parts": [ { "text": "Tell me a short story about the moon." } ] } ] } ``` ### Response #### Success Response (200) - **candidates** (array) - Description of the generated content candidates. - **content** (object) - The generated content. - **parts** (array) - Parts of the generated content. - **text** (string) - The text of the generated part. #### Response Example (Streaming responses will be received chunk by chunk. Each chunk is a JSON object similar to the non-streaming response, but may be partial.) ```json { "candidates": [ { "content": { "parts": [ { "text": "High above the world, the Moon" } ] } } ] } ``` ```json { "candidates": [ { "content": { "parts": [ { "text": "shines with a gentle, silvery light." } ] } } ] } ``` ``` -------------------------------- ### Install Claude Code (Windows PowerShell) Source: https://docs.commonstack.ai/integration-guides/claude-code-terminal Use this command to install Claude Code on Windows using PowerShell. ```powershell irm https://claude.ai/install.ps1 | iex ​ ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.commonstack.ai/api-references/endpoint-specifications/anthropic-compatible-api Perform an HTTP GET request to query the documentation. Use the `ask` query parameter with a specific, self-contained question in natural language. The response will include a direct answer and relevant excerpts. ```HTTP GET https://docs.commonstack.ai/api-references/endpoint-specifications/anthropic-compatible-api.md?ask= ``` -------------------------------- ### Prefilled Assistant Response Example Source: https://docs.commonstack.ai/user-guide/anthropic-sdk-compatibility Example JSON response from the Commonstack API when an assistant message is pre-filled in the request. ```json { "id": "msg_01Q8Faay6S7QPTvEUUQARt7h", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "C" } ], "model": "anthropic/claude-opus-4-6", "stop_reason": "max_tokens", "stop_sequence": null, "usage": { "input_tokens": 42, "output_tokens": 1 } } ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.commonstack.ai/integration-guides/claudecode-vscode Perform an HTTP GET request to the documentation URL with an `ask` query parameter to retrieve specific information or clarifications. ```http GET https://docs.commonstack.ai/integration-guides/claudecode-vscode.md?ask= ``` -------------------------------- ### Anthropic API Response Example Source: https://docs.commonstack.ai/user-guide/anthropic-sdk-compatibility Example JSON response structure from the Commonstack API for a messages endpoint request. ```json { "id": "msg_01XFDUDYJgAACzvnptvVoYEL", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "Hello!" } ], "model": "anthropic/claude-opus-4-6", "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 12, "output_tokens": 6 } } ``` -------------------------------- ### Install Claude Code (macOS/Linux/WSL) Source: https://docs.commonstack.ai/integration-guides/claude-code-terminal Use this command to install Claude Code on macOS, Linux, or Windows Subsystem for Linux. ```bash curl -fsSL https://claude.ai/install.sh | bash ``` -------------------------------- ### Install Claude Code via npm Source: https://docs.commonstack.ai/integration-guides/claude-code-terminal Install Claude Code globally using npm. Requires Node.js 18 or newer. ```bash npm install -g @anthropic-ai/claude-code ``` -------------------------------- ### Query Documentation Dynamically Source: https://docs.commonstack.ai/integration-guides/openclaw/openclaw-external-tools-integration-mcp Perform an HTTP GET request to query this documentation page dynamically. Include your question as the `ask` query parameter to receive a direct answer and relevant excerpts. ```http GET https://docs.commonstack.ai/integration-guides/openclaw/openclaw-external-tools-integration-mcp.md?ask= ``` -------------------------------- ### Streaming with Web Search Source: https://docs.commonstack.ai/user-guide/anthropic-sdk-compatibility This example demonstrates how to enable streaming responses and utilize the `web_search_20250305` tool for real-time information retrieval. ```APIDOC ## POST /v1/messages ### Description Sends a message to the model, with options for streaming and tool usage. ### Method POST ### Endpoint https://api.commonstack.ai/v1/messages ### Parameters #### Headers - **x-api-key** (string) - Required - Your API key. - **content-type** (string) - Required - Must be `application/json`. #### Request Body - **model** (string) - Required - The model to use (e.g., `anthropic/claude-opus-4-6`). - **max_tokens** (integer) - Required - The maximum number of tokens to generate. - **stream** (boolean) - Optional - If true, enables streaming responses. - **tools** (array) - Optional - A list of tools to make available to the model. - **type** (string) - Required - The type of the tool (e.g., `web_search_20250305`). - **name** (string) - Required - The name of the tool (e.g., `web_search`). - **max_uses** (integer) - Optional - The maximum number of times the tool can be used. - **messages** (array) - Required - A list of message objects representing the conversation history. - **role** (string) - Required - The role of the message sender (`user` or `assistant`). - **content** (string) - Required - The content of the message. ### Request Example ```json { "model": "anthropic/claude-opus-4-6", "max_tokens": 1024, "stream": true, "tools": [ { "type": "web_search_20250305", "name": "web_search", "max_uses": 5 } ], "messages": [ { "role": "user", "content": "What is the weather like in New York City today?" } ] } ``` ### Response #### Success Response (200) Responses are streamed as Server-Sent Events (SSE). Events include `message_start`, `content_block_start`, `content_block_delta`, `content_block_stop`, `message_delta`, and `message_stop`. #### Response Example (SSE Stream) ``` event: message_start data: {"type": "message_start", "message": {"id": "msg_01G...", "type": "message", "role": "assistant", "model": "anthropic/claude-opus-4-6", "content": [], "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 2679, "output_tokens": 3}}} event: content_block_start data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "I'll check the current weather in New York City for you."}} event: content_block_stop data: {"type": "content_block_stop", "index": 0} event: content_block_start data: {"type": "content_block_start", "index": 1, "content_block": {"type": "server_tool_use", "id": "srvtoolu_014hJH82Qum7Td6UV8gDXThB", "name": "web_search", "input": {}}} event: content_block_delta data: {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "{\"query\": \"weather NYC today\"}"}} event: content_block_stop data: {"type": "content_block_stop", "index": 1} event: content_block_start data: {"type": "content_block_start", "index": 2, "content_block": {"type": "web_search_tool_result", "tool_use_id": "srvtoolu_014hJH82Qum7Td6UV8gDXThB", "content": [...]}} event: content_block_stop data: {"type": "content_block_stop", "index": 2} event: content_block_start data: {"type": "content_block_start", "index": 3, "content_block": {"type": "text", "text": ""}} event: content_block_delta data: {"type": "content_block_delta", "index": 3, "delta": {"type": "text_delta", "text": "Here's the current weather information for New York City..."}} event: content_block_stop data: {"type": "content_block_stop", "index": 3} event: message_delta data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null}, "usage": {"output_tokens": 510, "server_tool_use": {"web_search_requests": 1}}} event: message_stop data: {"type": "message_stop"} ``` ```