### Launch full interactive Claude Code session Source: https://kiosapi.mintlify.app/tutorials/claude-code Start a full interactive session with Claude Code after verifying the setup. ```bash claude ``` -------------------------------- ### Install asyncio and aiohttp Source: https://kiosapi.mintlify.app/getting-started/concurrency Install the required packages for high-concurrency workloads. Use aiohttp instead of httpx for better performance. ```bash pip install asyncio aiohttp ``` -------------------------------- ### Node.js: Install OpenAI SDK with npm Source: https://kiosapi.mintlify.app/getting-started/openai-sdk Installs the official OpenAI Node.js package using npm. ```bash npm install openai ``` -------------------------------- ### Response for GET /v1/models/{model} Source: https://kiosapi.mintlify.app/api-reference/models/list-single-model Example response for a successful GET /v1/models/{model} request. Returns the model's id, object type (always "model"), created timestamp, and owned_by provider. ```json { "id": "gemini-2.0-flash", "object": "model", "created": 1686935002, "owned_by": "google" } ``` -------------------------------- ### Install Codex CLI via npm Source: https://kiosapi.mintlify.app/tutorials/codex Install the Codex CLI globally using npm. ```bash npm i -g @openai/codex ``` -------------------------------- ### Install OpenClaw with npm or Bun Source: https://kiosapi.mintlify.app/tutorials/openclaw Install OpenClaw globally using either npm or Bun. Choose the tab that matches your package manager. ```bash npm install -g openclaw ``` ```bash bun install -g openclaw ``` -------------------------------- ### OpenClaw usage examples Source: https://kiosapi.mintlify.app/tutorials/openclaw Usage examples for OpenClaw: interactive mode, direct question, and specifying a model with the --model flag. ```bash openclaw ``` ```bash openclaw "Create a React component for a todo list" ``` ```bash openclaw --model claude-sonnet-4-6 "Refactor this function" ``` -------------------------------- ### Verify OpenClaw installation Source: https://kiosapi.mintlify.app/tutorials/openclaw Verify the OpenClaw installation by checking its version. ```bash openclaw --version ``` -------------------------------- ### Install Codex CLI via Homebrew Source: https://kiosapi.mintlify.app/tutorials/codex Install the Codex CLI on macOS or Linux using Homebrew. ```bash brew install codex ``` -------------------------------- ### Python: Install OpenAI SDK with pip Source: https://kiosapi.mintlify.app/getting-started/openai-sdk Installs the official OpenAI Python package. The base URL must include the /v1/ suffix with a trailing slash. ```bash pip install openai ``` -------------------------------- ### Verify CC Switch installation Source: https://kiosapi.mintlify.app/tutorials/cc-switch Checks the installed version of CC Switch to confirm installation. ```bash cc-switch --version ``` -------------------------------- ### Verify Codex CLI installation Source: https://kiosapi.mintlify.app/tutorials/codex Check the installed version of the Codex CLI. ```bash codex --version ``` -------------------------------- ### Verify OpenClaw setup Source: https://kiosapi.mintlify.app/tutorials/openclaw Run a quick test to confirm OpenClaw is connected to KiosAPI. If OpenClaw responds, the configuration is working. ```bash openclaw "Say hello" ``` -------------------------------- ### Python Request for o1-mini Source: https://kiosapi.mintlify.app/api-reference/chat/o1-o3 Example of using the OpenAI Python client to interact with the o1-mini model on KiosAPI. ```python import openai openai.api_key = "sk-xxx" openai.base_url = "https://kiosapi.com/v1/" response = openai.chat.completions.create( model="o1-mini", messages=[ {"role": "user", "content": "Explain quantum computing in simple terms"} ], max_completion_tokens=1688, stream=False ) print(response.choices[0].message.content) ``` -------------------------------- ### Response JSON for account details Source: https://kiosapi.mintlify.app/token-management/account Example response object containing account ID, username, balance, usage, and creation timestamp. ```json { "id": "user-xxx", "username": "your-email@example.com", "balance": 10.50, "used": 3.25, "created_at": 1686935002 } ``` -------------------------------- ### Install CC Switch globally via npm Source: https://kiosapi.mintlify.app/tutorials/cc-switch Installs CC Switch globally using npm. Requires Node.js 18+. ```bash npm install -g cc-switch ``` -------------------------------- ### Python Request for gpt-4o-all Source: https://kiosapi.mintlify.app/api-reference/chat/gpt-4o-all Example of using the OpenAI Python client to interact with the gpt-4o-all model for file analysis. ```python import openai openai.api_key = "sk-xxx" openai.base_url = "https://kiosapi.com/v1/" response = openai.chat.completions.create( model="gpt-4o-all", messages=[ { "role": "user", "content": "https://example.com/api-doc.pdf What is the API for adding a domain?" } ], max_tokens=1688, temperature=0.5, stream=False ) print(response.choices[0].message.content) ``` -------------------------------- ### Python Request for gpt-4-all Source: https://kiosapi.mintlify.app/api-reference/chat/gpt-4-all Example of using the OpenAI Python client to interact with the gpt-4-all model for file analysis. ```python import openai openai.api_key = "sk-xxx" openai.base_url = "https://kiosapi.com/v1/" response = openai.chat.completions.create( model="gpt-4-all", messages=[ { "role": "user", "content": "https://example.com/api-doc.pdf What is the API for adding a domain?" } ], max_tokens=1688, temperature=0.5, stream=False ) print(response.choices[0].message.content) ``` -------------------------------- ### cURL Request for Completions Source: https://kiosapi.mintlify.app/api-reference/chat/completions An example of how to send a POST request to the /v1/completions endpoint using cURL. ```bash curl https://kiosapi.com/v1/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-xxx" \ -d '{ "model": "gpt-3.5-turbo-instruct", "prompt": "The weather is very nice today", "temperature": 0.7, "max_tokens": 100, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0 }' ``` -------------------------------- ### Install Claude Code CLI globally via npm Source: https://kiosapi.mintlify.app/tutorials/claude-code Install the Claude Code CLI globally using npm. Requires Node.js 18+. ```bash npm install -g @anthropic-ai/claude-code ``` -------------------------------- ### Chat Completion Request with cURL Source: https://kiosapi.mintlify.app/api-reference/chat/general Example of making a chat completion request using the cURL command-line tool. ```bash curl https://kiosapi.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-xxx" \ -d '{ "model": "gpt-4o", "messages": [ { "role": "user", "content": "Hello world!" } ], "max_tokens": 1688, "temperature": 0.5, "stream": false }' ``` -------------------------------- ### Chat Completion Request with Python Source: https://kiosapi.mintlify.app/api-reference/chat/general Example of making a chat completion request using the OpenAI Python client library. ```python import openai openai.api_key = "sk-xxx" openai.base_url = "https://kiosapi.com/v1/" completion = openai.chat.completions.create( model="gpt-4o", messages=[ {"role": "user", "content": "Hello world!"} ], max_tokens=1688, temperature=0.5, stream=False ) print(completion.choices[0].message.content) ``` -------------------------------- ### Send chat completion request via KiosAPI Source: https://kiosapi.mintlify.app/ Creates a chat completion using the configured client with model gpt-4o-mini and prints the response content. This example follows the client setup and demonstrates a basic request. ```python response = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello!"}], ) print(response.choices[0].message.content) ``` -------------------------------- ### Verify Claude Code installation Source: https://kiosapi.mintlify.app/tutorials/claude-code Check the installed Claude Code version to confirm the installation succeeded. ```bash claude --version ``` -------------------------------- ### Full example: concurrent requests with asyncio and aiohttp Source: https://kiosapi.mintlify.app/getting-started/concurrency Recommended pattern for high concurrency: a shared ClientSession for connection pooling, a Semaphore to cap in-flight requests, and a while True loop that continuously drains your prompt source until exhausted. ```python import asyncio import aiohttp import json # ---- Configuration ---- API_KEY = "sk-xxx" BASE_URL = "https://kiosapi.com/v1/chat/completions" MODEL = "gpt-4o-mini" MAX_CONCURRENCY = 2000 # concurrent in-flight requests async def create_completion(session, prompt): """Send a single chat completion request.""" headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", } payload = { "model": MODEL, "messages": [ {"role": "user", "content": prompt}, ], } async with session.post(BASE_URL, headers=headers, json=payload) as resp: data = await resp.json() return data["choices"][0]["message"]["content"] async def main(): # Shared session — reuse across all requests for connection pooling connector = aiohttp.TCPConnector(limit=MAX_CONCURRENCY) timeout = aiohttp.ClientTimeout(total=120) async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session: semaphore = asyncio.Semaphore(MAX_CONCURRENCY) async def bounded_completion(prompt): async with semaphore: return await create_completion(session, prompt) # Example: continuously process a stream of prompts while True: # Replace this with your actual prompt source prompts = generate_prompts() # e.g. read from a queue or file if not prompts: break tasks = [bounded_completion(p) for p in prompts] results = await asyncio.gather(*tasks, return_exceptions=True) for result in results: if isinstance(result, Exception): print(f"Error: {result}") else: print(result) def generate_prompts(): """Yield the next batch of prompts. Replace with your logic.""" # Example: read from a file, message queue, or any iterable source return ["Summarize this article: ..."] if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Create ~/.codex/config.toml Source: https://kiosapi.mintlify.app/tutorials/codex Configure the KiosAPI provider and profile in the Codex configuration file. The wire_api setting must be set to responses and the base_url must include /v1. ```toml [model_providers.kiloapi] name = "KiloAPI" base_url = "https://kiosapi.com/v1" wire_api = "responses" env_key = "KILOAPI_KEY" [profiles.kiloapi] model = "o4-mini" model_provider = "kiloapi" ``` -------------------------------- ### Python example using openai library Source: https://kiosapi.mintlify.app/api-reference/embeddings/create Uses the 'openai' Python package to create embeddings. Requires setting the API key and base URL to the Kios API. The response prints the first 5 dimensions of the embedding. ```python import openai openai.api_key = "sk-xxx" openai.base_url = "https://kiosapi.com/v1/" response = openai.embeddings.create( model="text-embedding-3-large", input="The weather is beautiful today" ) print(response.data[0].embedding[:5]) # First 5 dimensions ``` -------------------------------- ### API Response Format Source: https://kiosapi.mintlify.app/api-reference/chat/gemini-native Example of the JSON response structure returned by the API. ```json { "id": "chatcmpl-xxx", "object": "chat.completion", "created": 1724972230, "choices": [ { "index": 0, "message": { "role": "assistant", "content": "I'm doing well, thank you for asking! How can I help you today?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 5, "completion_tokens": 15, "total_tokens": 20 } } ``` -------------------------------- ### Pre-approve file permissions in .claude/settings.json Source: https://kiosapi.mintlify.app/tutorials/claude-code Add this JSON to .claude/settings.json to pre-approve read and write permissions for specified directories, reducing permission prompts. ```json { "permissions": { "allow": ["Read(*)", "Write(src/**)", "Edit(src/**)"] } } ``` -------------------------------- ### Set environment variables for KiosAPI (macOS/Linux) Source: https://kiosapi.mintlify.app/tutorials/cc-switch Exports the base URL and auth token for KiosAPI in the shell profile. Replace 'sk-xxx' with your actual key. ```bash export ANTHROPIC_BASE_URL="https://kiosapi.com" export ANTHROPIC_AUTH_TOKEN="sk-xxx" ``` -------------------------------- ### Moderation Response Source: https://kiosapi.mintlify.app/api-reference/moderation/text Example response from the text moderation API, showing the structure of the returned JSON object. ```APIDOC ## Moderation Response ### Description Example response from the text moderation API, showing the structure of the returned JSON object. ### Response Example ```json { "id": "modr-970d409ef3bef3b70c73d8232df86e7d", "model": "text-moderation-latest", "results": [ { "flagged": true, "categories": { "sexual": false, "sexual/minors": false, "harassment": false, "harassment/threatening": false, "hate": false, "hate/threatening": false, "illicit": false, "illicit/violent": false, "self-harm": false, "self-harm/intent": false, "self-harm/instructions": false, "violence": true, "violence/graphic": false }, "category_scores": { "sexual": 0.0000002341, "violence": 0.8599265510, "violence/graphic": 0.3770173639 } } ] } ``` ### Response Fields - **id** (string) - A unique identifier for this moderation request. - **model** (string) - The moderation model that processed the request. - **results** (array) - An array of moderation result objects, one per input. - **results[].flagged** (boolean) - `true` if the input triggered one or more policy categories; `false` otherwise. Use this as your primary pass/fail signal. - **results[].categories** (object) - A map of each of the 13 category names to a boolean. `true` means that category was triggered for the input. - **results[].category_scores** (object) - A map of category names to floating-point confidence scores. Higher values indicate higher model confidence that the category applies. You can use these scores to implement custom severity thresholds beyond the default boolean flags. ``` -------------------------------- ### Moderation Request via cURL Source: https://kiosapi.mintlify.app/api-reference/moderation/text Example of how to perform a moderation check using the cURL command-line tool. ```bash curl https://kiosapi.com/v1/moderations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-xxx" \ -d '{ "model": "text-moderation-latest", "input": "She is very beautiful, I like..." }' ``` -------------------------------- ### Chat Completion Response Object Source: https://kiosapi.mintlify.app/api-reference/chat/general Example of a successful JSON response returned by the chat completion endpoint. ```json { "id": "chatcmpl-A1iMgDLzZtUJ9QDpfqDLxKH0zfUnp", "object": "chat.completion", "created": 1724972230, "model": "gpt-4o-2024-05-13", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello there! How can I assist you today?", "refusal": null }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 9, "completion_tokens": 10, "total_tokens": 19 }, "system_fingerprint": "fp_157b3831f5" } ``` -------------------------------- ### Verify Codex connection Source: https://kiosapi.mintlify.app/tutorials/codex Test the configuration by running a simple command or explicitly specifying the KiosAPI profile. ```bash codex "Say hello" ``` ```bash codex --profile kiloapi "Say hello" ``` -------------------------------- ### Claude API Response Object Source: https://kiosapi.mintlify.app/api-reference/chat/claude-native Example of the JSON response structure returned by the Claude native API. ```json { "id": "msg_014AoBefsejHUjbdRntn7euw", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "Hello! I'm Claude, an AI assistant. How can I help you today?" } ], "model": "claude-sonnet-4-6", "stop_reason": "end_turn", "stop_sequence": null, "usage": { "input_tokens": 12, "output_tokens": 38 } } ``` -------------------------------- ### Python Web Search Request Source: https://kiosapi.mintlify.app/api-reference/chat/gemini-openai Python example using the OpenAI SDK to make a chat completion request with the gemini-2.5-flash-search model, which enables web search via the -search suffix. ```python import openai openai.api_key = "sk-xxx" openai.base_url = "https://kiosapi.com/v1/" response = openai.chat.completions.create( model="gemini-2.5-flash-search", messages=[{"role": "user", "content": "What is today's date?"}], max_tokens=1688, temperature=0.5, stream=False ) print(response.choices[0].message.content) ``` -------------------------------- ### Node.js: Configure OpenAI client for KiosAPI Source: https://kiosapi.mintlify.app/getting-started/openai-sdk Creates an OpenAI client instance with the KiosAPI base URL and API key. The base URL must include the /v1/ suffix with a trailing slash. ```javascript import OpenAI from "openai"; const client = new OpenAI({ apiKey: "sk-xxx", baseURL: "https://kiosapi.com/v1/", }); ``` -------------------------------- ### Moderation Request via Python Source: https://kiosapi.mintlify.app/api-reference/moderation/text Example of how to perform a moderation check using the OpenAI Python client library. ```python import openai openai.api_key = "sk-xxx" openai.base_url = "https://kiosapi.com/v1/" response = openai.moderations.create( model="text-moderation-latest", input="She is very beautiful, I like..." ) print(response.results[0].flagged) ``` -------------------------------- ### Python Thinking Budget Configuration Source: https://kiosapi.mintlify.app/api-reference/chat/gemini-openai Python example showing how to configure a thinking budget for the gemini-2.5-flash model using the extra_body parameter with google.thinking_config. Sets include_thoughts to True and thinking_budget to 8192. ```python response = openai.chat.completions.create( model="gemini-2.5-flash", messages=[{"role": "user", "content": "Complex reasoning task..."}], max_tokens=8000, extra_body={ "google": { "thinking_config": { "include_thoughts": True, "thinking_budget": 8192 } } } ) ``` -------------------------------- ### Cache Control Configuration Source: https://kiosapi.mintlify.app/api-reference/chat/claude-native Example of adding a cache_control field to a document content object to enable server-side caching. ```json { "type": "document", "source": { "type": "base64", "data": "JVBERi0xLjQK...", "media_type": "application/pdf" }, "cache_control": { "type": "ephemeral" } } ``` -------------------------------- ### Store KiosAPI base URL and API key in .env file Source: https://kiosapi.mintlify.app/api-base-url Avoid hardcoding the base URL or API key in source code. Store them in a .env file and load them at runtime. The file defines KIOSAPI_BASE_URL and KIOSAPI_API_KEY. ```bash # .env KIOSAPI_BASE_URL=https://kiosapi.com/v1/ KIOSAPI_API_KEY=sk-kilo-xxxxxxxxxxxx ``` -------------------------------- ### cURL (Chat) Source: https://kiosapi.mintlify.app/api-reference/chat/claude-openai Example cURL request to the chat completions endpoint for a standard chat interaction with a Claude model. ```APIDOC ## POST /v1/chat/completions ### Description Sends a chat completion request to the KiosAPI endpoint using a Claude model. ### Method POST ### Endpoint https://kiosapi.com/v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The model identifier, e.g., "claude-sonnet-4-6". - **messages** (array) - Required - A list of message objects, each with a role and content. - **max_tokens** (integer) - Optional - Maximum number of tokens to generate. - **temperature** (number) - Optional - Sampling temperature. - **stream** (boolean) - Optional - Whether to stream the response. ### Request Example { "model": "claude-sonnet-4-6", "messages": [ { "role": "user", "content": "Hello, who are you?" } ], "max_tokens": 1688, "temperature": 0.5, "stream": false } ### Response #### Success Response (200) - **choices** (array) - The generated completion choices. - **choices[].message** (object) - The message object containing the generated content. #### Response Example { "choices": [ { "message": { "content": "I am Claude, an AI assistant." } } ] } ``` -------------------------------- ### cURL Request for gpt-4o-all Source: https://kiosapi.mintlify.app/api-reference/chat/gpt-4o-all Example of a POST request to the chat completions endpoint using cURL to analyze a PDF file. ```bash curl https://kiosapi.com/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-xxx" \ -d '{ "model": "gpt-4o-all", "messages": [ { "role": "user", "content": "https://example.com/api-doc.pdf What is the API for adding a domain?" } ], "max_tokens": 1688, "temperature": 0.5, "stream": false }' ``` -------------------------------- ### Example JSON response Source: https://kiosapi.mintlify.app/api-reference/models/list-models A successful response returns an object with object set to "list" and a data array containing model objects with id, object, created, and owned_by fields. ```json { "object": "list", "data": [ { "id": "gpt-4o", "object": "model", "created": 1686935002, "owned_by": "openai" }, { "id": "claude-sonnet-4-6", "object": "model", "created": 1686935002, "owned_by": "anthropic" } ] } ```