SDKs
Topo works with the OpenAI SDKs you already use. The Topo SDKs for Python and TypeScript add typed topo fields, receipts, wallets and agents.
Install
pip install topolabsnpm install @topolabs/sdk# Nothing to install. cURL ships with macOS, Linux and Windows.curl --versionConfigure
Both SDKs read TOPO_API_KEY from the environment. Set TOPO_BASE_URL only if you route through a private gateway.
.env
bash
TOPO_API_KEY="tp_live_8f3a…c21e"TOPO_BASE_URL="https://api.topolabs.ai/v1" # optionalFirst request
from topolabs import Topo topo = Topo() # reads TOPO_API_KEY response = topo.chat.completions.create( model="claude-sonnet-5.5", messages=[{"role": "user", "content": "Explain zk proofs in 3 lines"}], pay_with="usdt",) print(response.choices[0].message.content)print(response.topo.receipt.amount) # 0.0041import { Topo } from "@topolabs/sdk"; const topo = new Topo(); // reads TOPO_API_KEY const response = await topo.chat.completions.create({ model: "claude-sonnet-5.5", messages: [{ role: "user", content: "Explain zk proofs in 3 lines" }], pay_with: "usdt",}); console.log(response.choices[0].message.content);console.log(response.topo.receipt.amount); // "0.0041"curl https://api.topolabs.ai/v1/chat/completions \ -H "Authorization: Bearer $TOPO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-5.5", "messages": [{ "role": "user", "content": "Explain zk proofs in 3 lines" }], "pay_with": "usdt" }'Keep the OpenAI SDK
Prefer the OpenAI client? Change the base URL. Topo fields arrive on the raw response, and you can send them with extra_body in Python or as extra fields in TypeScript.
response = client.chat.completions.create( model="claude-sonnet-5.5", messages=[{"role": "user", "content": "Explain zk proofs in 3 lines"}], extra_body={"pay_with": "topo", "topo": {"verification": "strict"}},)const body = { model: "claude-sonnet-5.5", messages: [{ role: "user" as const, content: "Explain zk proofs in 3 lines" }], pay_with: "topo", topo: { verification: "strict" },}; // Unknown fields are sent as-is, so Topo options pass straight throughconst response = await client.chat.completions.create(body);Versions
| Package | Language | Latest | Runs on |
|---|---|---|---|
topolabs | Python | 1.8.0 | Python 3.9+ |
@topolabs/sdk | TypeScript | 1.8.0 | Node 18+, Bun, Deno and edge runtimes |
topo | CLI | 0.9.4 | macOS and Linux |