NinjaChat Python SDK
Typed client for the clean NinjaChat API v1.
[!IMPORTANT]
nj_sk_API keys are server-side secrets. Never ship one in browser, mobile, desktop, or other distributed client code. Load keys from a server-side secret manager or environment variable.
pip install ninjachat
import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
response = client.responses.create(
model="ninja/auto",
input="Write one sentence about clean APIs.",
max_output_tokens=64,
routing={"strategy": "balanced", "data_policy": "no_training"},
)
print(response["output_text"], response["cost_usd"], response["request_id"])
Ordered fallbacks and provider constraints are explicit:
completion = client.chat.completions.create(
models=["gpt-5", "claude-sonnet-4"],
messages=[{"role": "user", "content": "Hello"}],
max_completion_tokens=100,
routing={"strategy": "latency", "allow_fallbacks": True, "caching": "auto", "max_cost_usd": 0.10},
)
Streams return iterators of typed-shape dictionaries:
for event in client.responses.create(model="ninja/auto", input="Hello", stream=True):
if event.get("type") == "response.output_text.delta":
print(event.get("delta", ""), end="")
Models and prices come from client.models.list(). Images use client.images.generate(), videos use client.videos.generate() and client.videos.wait_for(), and account observability is available through client.usage(), client.balance(), and client.requests.get().
Signed webhooks replace video polling and fire spend alerts: client.webhooks.create(...) or the console. Verify deliveries with verify_webhook_signature.
The base URL is https://www.ninjachat.ai/api/v1. Chat and Responses are billed by actual token usage. See docs.ninjachat.ai.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 ninjachat-0.1.2.tar.gz.
File metadata
- Download URL: ninjachat-0.1.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3954e62a79b3e716cf390b489cafddf49d50cf2d15ab04d1b7f79b46bdc2b129
|
|
| MD5 |
40d127502df8bc5a240ad7c13e9d55fc
|
|
| BLAKE2b-256 |
f05ee3fe78556b3298510afa8992ceb80f79d5ed9a20bec22800b2a877e9b79e
|
Provenance
The following attestation bundles were made for ninjachat-0.1.2.tar.gz:
Publisher:
release.yml on bloon-ai/ninjachat-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ninjachat-0.1.2.tar.gz -
Subject digest:
3954e62a79b3e716cf390b489cafddf49d50cf2d15ab04d1b7f79b46bdc2b129 - Sigstore transparency entry: 2580027042
- Sigstore integration time:
-
Permalink:
bloon-ai/ninjachat-sdk@1b151757699cca8ae50a19a3f10e8c16a3a3d31d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/bloon-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b151757699cca8ae50a19a3f10e8c16a3a3d31d -
Trigger Event:
push
-
Statement type:
File details
Details for the file ninjachat-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ninjachat-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c72d9b1b0d8547404f212625920d44cd7950c17adbb643a327af84427cec0cb4
|
|
| MD5 |
804a8413142e87f8b04cfc36fdadce68
|
|
| BLAKE2b-256 |
86f62eb1fdbe6406ac2b82b11e01722b5c3852fc0f49520478c6fda48c18ae32
|
Provenance
The following attestation bundles were made for ninjachat-0.1.2-py3-none-any.whl:
Publisher:
release.yml on bloon-ai/ninjachat-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ninjachat-0.1.2-py3-none-any.whl -
Subject digest:
c72d9b1b0d8547404f212625920d44cd7950c17adbb643a327af84427cec0cb4 - Sigstore transparency entry: 2580027046
- Sigstore integration time:
-
Permalink:
bloon-ai/ninjachat-sdk@1b151757699cca8ae50a19a3f10e8c16a3a3d31d -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/bloon-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1b151757699cca8ae50a19a3f10e8c16a3a3d31d -
Trigger Event:
push
-
Statement type: