Skip to main content
NinjaChat exposes an OpenAI-compatible /chat/completions endpoint. Point any OpenAI SDK at NinjaChat by setting two things:
  • Base URL: https://www.ninjachat.ai/api/v1
  • API key: your nj_sk_... key
Choose a NinjaChat model ID. Chat Completions supports OpenAI-style messages, streaming, tools and errors; available parameters depend on the model.
Starting a new integration? The official NinjaChat SDKs add typed routing, images, video polling, usage, request traces, and webhook helpers. Keep the OpenAI SDK when you want the smallest possible migration.

Env-var setup

The OpenAI SDKs also pick up OPENAI_API_KEY and OPENAI_BASE_URL from the environment, so you can skip the constructor arguments entirely:
Python
Use www.ninjachat.ai, not the bare ninjachat.ai apex domain. The apex redirects and strips the Authorization header along the way, so every request would arrive unauthenticated.

What works

  • Any model — pass any model ID, or ninja/auto to let NinjaChat pick.
  • Streaming — set stream: true for token-by-token server-sent events.
  • Tool calling — standard tools / tool_choice with function.parameters.
  • Samplingtemperature, top_p, max_tokens (or max_completion_tokens), stop, seed, frequency_penalty, presence_penalty.
/api/v1/chat/completions is the OpenAI-compatible message interface. For new native integrations, use /api/v1/responses; both share authentication, routing, and billing.

What’s rejected

The request schema is strict. Standard OpenAI SDK fields that have no effect on NinjaChat are dropped silently; anything that would change the meaning of the request fails with a 400 instead of being ignored:

NinjaChat extras

The native Responses API adds optional features OpenAI doesn’t have — smart routing, fallbacks, spend controls, explicit provider policy, and per-response cost_usd and request traces. Adopt the official NinjaChat SDK when you need those typed primitives.