Verification-first inference. One client.
The @turnstileai/sdk is a TypeScript SDK for TurnstileAI a verification-first AI gateway that adds trustable receipts, provider visibility, and optional Solana-backed checkpoints to every completion.
One package. Node, Bun, Deno.
Install the SDK and export your API key. Zero additional configuration the client connects to https://api.turnstileai.net/v1 by default.
Your first verified completion.
Initialize TurnstileAI, call client.chat(), and get back output, record, and verification in one response. Set anchor: "solana" to write the proof on-chain.
Client initialisation options.
apiKeystringbaseURLstringtimeoutnumberdefaultRouteModeRouteModedefaultLedgerModeLedgerModePer-request controls.
modelrequiredmessagesrequiredreceipttrueanchor"off-chain"routeMode"trust-first"provider maxSpendUsd temperature maxTokens Records, providers, usage, and CLI.
Sandboxed mock mode no network needed.
Use an API key starting with ts_test_, or set TURNSTILEAI_MOCK=true, and the SDK falls back to local mock mode. Iterate offline and write integration tests without hitting the live gateway.
A small, predictable method set.
client.chat(options)Run a verified inference completion. Returns output, record, and verification.
client.records.get(id)Fetch a run record by ID.
client.records.verify(id)Re-check a record's signature and Solana anchor.
client.providers.list()List all available inference providers and their current status.
client.usage.overview(period)Pull spend, token, and latency rollups. Pass "month", "week", or "day".