ThAPI integration docs
Connect an app, send your first request or look up a protocol. Check the current model catalogue and pricing before integrating.
Quick start
Install the libraries used by the example, use a supported runtime and set STALI_API_KEY in the environment. Replace sample model names with an available model matching the protocol.
SDK setup and API key check
Install the library for your language. Enter the key privately in Bash or PowerShell, then call GET /v1/models to check authentication and obtain model IDs; this request does not generate AI content.
read -r -s -p "STALI_API_KEY: " STALI_API_KEY
export STALI_API_KEY
printf '\n'
curl -fsS https://thapi.cloud/v1/models -H "Authorization: Bearer ${STALI_API_KEY:?STALI_API_KEY}"cURL examples use Bash on macOS/Linux or WSL/Git Bash. Python prompts for a key when STALI_API_KEY is absent; Node.js reads the environment variable.
curl -N https://thapi.cloud/v1/messages \
-H "x-api-key: ${STALI_API_KEY:?STALI_API_KEY}" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-fable-5",
"max_tokens": 1024,
"stream": true,
"messages": [
{ "role": "user", "content": "Write a quicksort function in Python" }
]
}'Content-generation examples make real requests and may incur charges. Check billing units and per-request minimums before running them.
Authentication · View current pricingInstall API CLI
Requires Node.js 18 or later. Install API CLI, then run api-cli to enter the key in the wizard. Use api-cli doctor to inspect configuration; chat or ping requests may still be billable.
# Recommended for Windows, macOS and Linux; Node.js >= 18 required
npm install -g stali-cli@latest
# Alternative installer: npm, with GitHub + Bun fallback:
# curl -fsSL "https://thapi.cloud/install/stali-cli.sh" | bash
# Install without opening the setup wizard:
# curl -fsSL "https://thapi.cloud/install/stali-cli.sh" | STALI_CLI_NO_RUN=1 bash
staliConnect apps
Find instructions by tool and protocol.
Claude Code: configure the API key, model and provider in your terminal.
Codex CLI: configure the API key, model and provider in your terminal.
OpenClaw: configure the API key, model and provider in your terminal.
Hermes Agent: configure the API key, model and provider in your terminal.
Request lifecycle
From API request to settlement
Send the documented endpoint, model, and payload. Keep the API key in environment variables or server-side secret configuration.
Select a step for details. This diagram explains the flow; it does not show live request status.
Base URLs
Choose the URL for your SDK and protocol.
Anthropic https://thapi.cloud
OpenAI https://thapi.cloud/v1
Authentication
Protect keys and use the correct headers.
View the full guideEndpoints and protocols
Match endpoints to model capabilities.
View the full guideImages, audio and video
Check formats and job lifecycles.
View the full guideStreaming
Handle events, usage and terminal errors.
View the full guideBilling
Understand tokens, requests and minimum charges.
Some models have a minimum charge per call. Short requests can still incur this floor; low token usage does not imply no charge.
View the full guideErrors and retries
Diagnose failures with errors and request IDs.
Retain x-thapi-request-id when present and the failure time for investigation. Exclude API keys and sensitive payloads from reports.
View the full guideLimits and timeouts
Understand admission limits and timeouts.
View the full guideGenerate and edit images
JSON guides for image generation, references, results and pricing.
View the full guideCreate video
Create videos from text and images, track progress and download MP4 through the Videos API.
View the full guideVision
Check formats and job lifecycles.
View the full guideResponse headers
Retain x-thapi-request-id when present and the failure time for investigation. Exclude API keys and sensitive payloads from reports.
View the full guideTroubleshooting
Honor Retry-After and use bounded exponential backoff with jitter. Cap attempts and total time. For video jobs that may already exist, look up the job ID before submitting again.
View the full guideExamples receive source review and local checks; this does not establish compatibility with every app version. Check settings, send a small request and confirm usage before production use.