TokenSpend Python
Official Python client for the TokenSpend API. It has no runtime dependencies.
pip install tokenspend
export TOKENSPEND_API_KEY=tsr_...
from tokenspend import TokenSpend
client = TokenSpend()
response = client.chat.completions.create(
model="xai/grok-4.5",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
Set stream=True to iterate over server-sent chunks. client.messages.create(...)
uses the Anthropic-compatible Messages API. See https://tokenspend.dev/docs/router.
Every registry model uses the same method:
for model in (
"xai/grok-4.5",
"meta/muse-spark-1.2",
"thinking-machines/inkling",
"moonshot/kimi-k3",
):
response = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "Hello"}],
)
The SDK never accepts a serving-host selector.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tokenspend-0.1.1.tar.gz
(3.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tokenspend-0.1.1.tar.gz.
File metadata
- Download URL: tokenspend-0.1.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1d6fe9361a86bb416960fd600c52a49ee717ac317e528b46ac4c499590d56c8
|
|
| MD5 |
1121ca4183dc191d845684725492677f
|
|
| BLAKE2b-256 |
13dba430ee70be27ecba57f6335d0c0cc400552ff632855959e49700bef3bdea
|
File details
Details for the file tokenspend-0.1.1-py3-none-any.whl.
File metadata
- Download URL: tokenspend-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff5d1498539e621c8d6d640bea3378f7091681b6ff1cdb1143de5c730d2b4060
|
|
| MD5 |
ee226dde624f1aa5a93719736bb5849e
|
|
| BLAKE2b-256 |
15213f24620f23da23b068382238e470814fccb3cf5523fe79c91db6c114e380
|