Skip to main content
NIJA.

API Docs

Nija exposes an OpenAI-compatible API. Point any OpenAI SDK at https://nija.africa/v1 with your Nija key. The Chat Completions API is the surface that ports: a call your code already makes to chat.completions.create runs on Nija with the base URL and the key changed and nothing else.

Chat completions

curl https://nija.africa/v1/chat/completions \
  -H "Authorization: Bearer $NIJA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Habari"}]}'

Streaming, tool calls, and routing

These are ordinary request fields on the endpoint above, forwarded to the model as sent, so an existing OpenAI SDK reaches all three without a line of Nija-specific code. Send "stream": true to receive the reply as server-sent events, closed by the standard [DONE] sentinel. Send tools (or the older functions) to let a model call your own functions; the schemas you send count as input tokens and are priced like the rest of the prompt. Send models as a list of slugs to fall back through them in order, and provider to express a preference for who serves the request. Appending :nitro to a model slug asks for the highest-throughput provider and :floor for the cheapest.

Your account's sovereignty settings merge into every request and can only make it stricter, never looser: a per-request preference can narrow what a saved default allows, and cannot widen it.

Models

GET /v1/models lists every model with Nija pricing facets and African-language tags. Create keys under Keys; top up under Credits; control data residency under Data Sovereignty.

Presets

Save a model, system prompt, and generation parameters once under Presets, then reference it by slug on a completion instead of inlining the whole config: add "preset": "<slug>" to the request body. Any field you also send on the request overrides the matching preset field, and the response echoes preset_applied with the slug and version that actually ran. An unknown or deleted slug returns a 400.

You can also manage presets programmatically over the same api-key or session auth, so the whole lifecycle runs from CI or a deploy script: GET /v1/presets lists your presets (latest version per slug), POST /v1/presets creates one (re-saving a slug adds a new version), PUT /v1/presets/<id> updates it, and DELETE /v1/presets/<id> removes it. Every call is scoped to the presets you own.

Agents (MCP)

Nija also speaks the Model Context Protocol, so an agent host can call Nija models as tools using the same key and the same billed path. See the MCP quickstart for the endpoint, a copy-paste client configuration, a worked example per tool, and the refusal codes to branch on.

Partner vouchers (POS)

Selling Nija credit at a till? A partner key mints and activates prepaid vouchers straight from your POS over a separate voucher API. See the Partner voucher API quickstart for the mint and activate calls, the idempotency rule that makes a retried sale safe, and how period settlement is signed back to you.

Usage and credits

What a call cost comes back with the call. Every chat completion response carries a nija object holding price_local, what that call cost, and currency, the account currency it is charged in, alongside the request_id and the model and provider that actually served it. With stream: true the same object arrives as the last server-sent event before the [DONE] sentinel, so neither form needs a second request to price a call.

Nija also reports usage and cost through the API. GET /v1/credits returns account balance and total usage; GET /v1/generation?id= returns the model, tokens, and cost of a single completion; GET /v1/key returns the limit, usage, and reset window for a key.

API Docs · Nija