Skip to main content

NinjaChat Python SDK

Typed client for the clean NinjaChat API v1.

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

ninjachat-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ninjachat-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file ninjachat-0.1.0.tar.gz.

File metadata

  • Download URL: ninjachat-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ninjachat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e8f7896e9758361903dcbf333b8254ac7f291831917396316365b6258ea280cd
MD5 b111ebf662199098804633b3097a8d97
BLAKE2b-256 5e6cd293869f5d2712c0fd289ca7ba420e62be052b8dba228b973df7fc7d3af2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ninjachat-0.1.0.tar.gz:

Publisher: release.yml on bloon-ai/ninjachat-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ninjachat-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ninjachat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for ninjachat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 733128b7d227505a96c01cd3fc79644019a5974ec33c0c8b6ada34ee5d5654b4
MD5 38f760050510fd094d8a48cad951d2d2
BLAKE2b-256 ac8178bb24275d63f64fd949590a6e2a2b092da353e1d8cb9946465dd26cc20c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ninjachat-0.1.0-py3-none-any.whl:

Publisher: release.yml on bloon-ai/ninjachat-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.3

2 files

0.1.2

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page