API Reference

Naga Bonar Mesh API

Stream tokens from the fastest healthy model provider over a single edge-native endpoint.

Overview

The mesh exposes one streaming endpoint. Send a prompt with route:"auto" and Naga Bonar scores providers by latency, cost and quality, then streams tokens back over SSE. Base URL:

BASE https://api.nagabonar.dev

Authentication

Every request needs a scoped key with its own budget. Pass it as a bearer token.

Authorization: Bearer nb-live-***
Keys carry a hard spend budget. When the budget is hit, the mesh returns 402 budget_exceeded instead of overspending.

Quickstart

# stream a completion, auto-routed
curl -N https://api.nagabonar.dev/v1/stream \
  -H "Authorization: Bearer nb-live-***" \
  -H "Content-Type: application/json" \
  -d '{ "route":"auto", "prompt":"explain the mesh", "budget":0.02 }'

POST /v1/stream

POST /v1/stream

Opens a server-sent event stream of tokens from the selected provider.

Body parameters

FieldTypeDescription
routestring"auto" or a pinned provider id. Auto picks the fastest healthy route.
promptstringThe input prompt. Use messages for chat format.
budgetnumberMax spend in USD for this request. Mesh stops before exceeding it.
regionstringOptional. Pin the edge region, e.g. "sea" or "eu".
cacheboolEnable semantic cache for repeat prompts. Default true.

Routing modes

ModeBehavior
autoScore latency + cost + quality, fail over on error.
cheapestLowest cost healthy provider.
fastestLowest p50 first-token latency.
pinnedForce a single provider id.

Stream events

event: route   // chosen provider + region
data:  {"provider":"provider-3","region":"sea","p50":38}

event: token
data:  {"token":"Naga"}

event: done
data:  {"tokens":128,"cost":0.004,"ms":410}

SDK install

# python
pip install nagabonar

# node
npm i @nagabonar/mesh

Errors

CodeMeaning
401invalid_key — missing or bad bearer token.
402budget_exceeded — request budget reached.
429rate_limited — per-key rate limit hit.
503no_healthy_route — all providers down for this route.
// Illustrative demo. Endpoints do not resolve.