Skip to main content

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

ninjachat-0.1.2.tar.gz (10.3 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.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

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

Hashes for ninjachat-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3954e62a79b3e716cf390b489cafddf49d50cf2d15ab04d1b7f79b46bdc2b129
MD5 40d127502df8bc5a240ad7c13e9d55fc
BLAKE2b-256 f05ee3fe78556b3298510afa8992ceb80f79d5ed9a20bec22800b2a877e9b79e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ninjachat-0.1.2.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.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

Hashes for ninjachat-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c72d9b1b0d8547404f212625920d44cd7950c17adbb643a327af84427cec0cb4
MD5 804a8413142e87f8b04cfc36fdadce68
BLAKE2b-256 86f62eb1fdbe6406ac2b82b11e01722b5c3852fc0f49520478c6fda48c18ae32

See more details on using hashes here.

Provenance

The following attestation bundles were made for ninjachat-0.1.2-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

This release

0.1.2 This release

2 files

0.1.0

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