API Reference

One gateway for every agent turn.

Chat Completions, Responses, Anthropic Messages and Batches on one endpoint, with per-key caps, deterministic routing and zero prompt storage.

Inference https://inference.noosfera.si/v1 Sandboxes cloud.noosfera.si Early Access Storage No prompts, counts only
01 · Getting Started

Overview

Point any OpenAI SDK, Anthropic SDK or coding CLI at Noosfera with your nsk_ key. Requests run only on paid commercial API keys and dedicated GPUs, never on consumer OAuth subscriptions, and no prompt is stored.

10-Second Setup

Download and inspect init.sh with TLS 1.2+, then run --dry-run or apply. Secrets are isolated in 0600 ~/.config/noosfera/env.sh (env.fish for fish), while your shell profile (~/.zshrc, ~/.bashrc, or ~/.config/fish/config.fish) receives only a non-secret noosfera source block. Pass --with-sandbox with NOOSFERA_CLOUD_KEY to include Early Access sandbox variables.

POSIX sh · zsh / bash / fish
curl -fsSL --proto '=https' --tlsv1.2 https://noosfera.si/init.sh -o init.sh && sh init.sh
SurfaceMethod & PathPurpose
Chat CompletionsPOST /v1/chat/completionsOpenAI-compatible chat, function tools, reasoning effort, SSE streaming
ResponsesPOST /v1/responsesOpenAI stateless Responses API with namespaced tools & reasoning items
Anthropic MessagesPOST /v1/messagesAnthropic Messages wire & Claude Code CLI with thinking & prompt caching
Token CounterPOST /v1/messages/count_tokensZero-cost local input token estimation matching /v1/messages
Batch APIPOST /v1/batchesAsynchronous bulk processing at 0.6× standard rate (40% off-peak discount)
Model CatalogGET /v1/modelsReturns all enabled models and context limits available to your key

Authentication & Headers

Authenticate OpenAI and Batch requests with Authorization: Bearer $NOOSFERA_KEY. Anthropic SDKs and Claude Code may send either Authorization: Bearer or x-api-key.

HeaderDirectionBehavior
Authorization / x-api-keyRequestRequired API key (Bearer nsk_... or x-api-key: nsk_...)
x-gateway-conversationRequestStable session ID (1–128 chars) for sticky prompt-cache pinning
x-gateway-no-traceRequestSet to 1 to explicitly refuse trace capture on any key tier
x-noosfera-request-idResponseUnique request ID matching your counts-only usage ledger row
x-noosfera-quota-ux-stateResponseSurfaces hidden, calm_notice, or mode_hemat when pace rules apply

Error Envelope

Every error is JSON with a stable code and a readable message, plus the top-level type the official OpenAI and Anthropic SDKs expect. Refusals (402, 429, 503) are sent as real HTTP statuses before any SSE stream opens, so SDK retry logic works unchanged.

Error Shape
{  "type": "error",  "error": {    "type": "rate_limit_error",    "code": "key_daily_limit_reached",    "message": "daily USD limit reached for this key; resets at 00:00 UTC"  }}
02 · OpenAI Wire

Chat Completions

POST /v1/chat/completions Streaming SSE & JSON

Drop-in OpenAI Chat Completions endpoint supporting system/developer messages, function calling (tools and tool_choice), reasoning_effort, max_tokens / max_completion_tokens, and usage.prompt_tokens_details.cached_tokens reporting.

FieldTypeNotes
modelstringConcrete model ID (e.g. deepseek-v4.1-flash, gemini-3.5-flash-lite) or policy (noosfera/auto, noosfera/speed, noosfera/eco)
messagesarrayRequired list of system, developer, user, assistant, and tool turns
streambooleanWhen true, emits chat.completion.chunk SSE frames ending in data: [DONE]
toolsarrayOpenAI function tool definitions ({ type: "function", function: ... })
reasoning_effortstringOptional: none, minimal, low, medium, high, or xhigh
POST /v1/chat/completions
curl https://inference.noosfera.si/v1/chat/completions \  -H "Authorization: Bearer $NOOSFERA_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "noosfera/auto",    "stream": true,    "messages": [      {"role": "system", "content": "Reply with concise diffs only."},      {"role": "user", "content": "Fix the null check in parseToken."}    ]  }'
03 · Stateless Agent Wire

Responses

POST /v1/responses Stateless Responses API

Implements the OpenAI Responses API (resp_* IDs) in strictly stateless mode so no conversation history is retained server-side. Send the full turn list in input on every turn; previous_response_id is rejected with 400 unsupported_previous_response.

FieldTypeBehavior
inputstring | arrayString prompt or items (message, function_call, function_call_output)
instructionsstringLeading system instructions for the model
toolsarrayFunction tools and namespaced function tools (type: "namespace")
reasoningobject{ "effort": "minimal" | "low" | "medium" | "high" | "xhigh" }
max_output_tokensintegerMaximum tokens to generate within the selected model's limit
POST /v1/responses
curl https://inference.noosfera.si/v1/responses \  -H "Authorization: Bearer $NOOSFERA_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "noosfera/auto",    "instructions": "Be terse and verify edge cases.",    "input": "Explain how atomic budget holds prevent overspend."  }'
04 · Anthropic Wire & Coding CLIs

Anthropic Messages & Claude Code

POST /v1/messages Messages + SSE
POST /v1/messages/count_tokens Local Estimator · $0

Full Anthropic Messages compatibility (msg_* IDs) with tool_use / tool_result, thinking (enabled with budget_tokens ≥ 1024, adaptive, or disabled), cache_control (ephemeral 5m / 1h TTL), stop_sequences, text/base64 document blocks, and in-conversation system reminder turns.

Claude Code CLI Base URL

Anthropic SDKs and Claude Code append /v1/messages automatically. Set ANTHROPIC_BASE_URL="https://inference.noosfera.si" (without a trailing /v1) and clear ANTHROPIC_API_KEY="" so Claude Code sends your ANTHROPIC_AUTH_TOKEN cleanly. Requested claude-sonnet-* and claude-haiku-* names resolve to enabled commercial API-key models.

Anthropic Wire
export ANTHROPIC_BASE_URL="https://inference.noosfera.si"export ANTHROPIC_AUTH_TOKEN="$NOOSFERA_KEY"export ANTHROPIC_API_KEY=""export ANTHROPIC_MODEL="noosfera/auto" claude
05 · Asynchronous Workloads

Batch API

POST /v1/batches 0.6× Rate · 40% Off-Peak Discount

Evals, migrations and overnight reviews at 0.6× list rate (40% off). Batches are tenant-isolated, and their prompts are not kept once a batch completes or expires.

Method & RouteDescription
POST /v1/batchesSubmit a JSON requests array or JSONL batch payload with endpoint and completion_window
GET /v1/batchesList batches owned by the authenticated tenant
GET /v1/batches/:idInspect batch status (validating, in_progress, completed, cancelled) and results; returns 404 across tenants
POST /v1/batches/:id/cancelCancel an active batch and immediately release remaining budget hold
/v1/batches
curl https://inference.noosfera.si/v1/batches \  -H "Authorization: Bearer $NOOSFERA_KEY" \  -H "Content-Type: application/json" \  -d '{    "endpoint": "/v1/chat/completions",    "completion_window": "24h",    "requests": [      {        "custom_id": "pr-412-a",        "method": "POST",        "url": "/v1/chat/completions",        "body": {"model": "noosfera/eco", "messages": [{"role": "user", "content": "Check SQL migrations"}]}      }    ]  }'
06 · Deterministic Smart Routing

Routing Policies

No LLM router sits in front of your turn. Noosfera reads deterministic request signals in under a millisecond (estimated input size, max_tokens, tool schemas, attachments) and walks a ladder of eligible commercial models.

With sticky: true and x-gateway-conversation, a multi-turn loop stays on the same model and upstream slot for 2 hours, so the provider’s prompt cache stays warm. If that rung throttles or fails before the first token, the request moves to the next rung.

Balanced Default

noosfera/auto

Routine tool turns go to flash-class models; the sticky cache stays intact.

Lowest Latency

noosfera/speed

Picks the rung with the lowest time to first token.

Minimum Cost

noosfera/eco

Cheapest hemat_ok models, for sweeps, triage and batches.

Commercial Supply Guarantee

noosfera/auto, noosfera/speed, and noosfera/eco (as well as legacy aliases auto:flash, auto:fast, and auto:hemat) never route buyer keys to consumer OAuth subscriptions or contributor training tiers. You can also pass any concrete model from GET /v1/models (such as deepseek-v4.1-flash, gemini-3.5-flash-lite, glm-5.3-flash, or claude-sonnet-5-5; requested claude-sonnet-*, claude-opus-*, and claude-haiku-* names also alias cleanly).

07 · Noosfera Cloud

Sandboxes Early Access

Firecracker microVMs on bare metal for coding agents, test runners and browser tasks. Existing E2B SDK code switches over with two environment variables.

Early Access

Sandboxes at cloud.noosfera.si are in Early Access and disabled by default in init.sh. Pass --with-sandbox with NOOSFERA_CLOUD_KEY set when you want E2B_DOMAIN and E2B_API_KEY configured.

MetricValueDetails
Active Compute Rate$0.028/hr4 vCPU / 8 GiB microVM ($0.0055/vCPU-hr + $0.00075/GiB-hr), billed per active second
Idle Auto-Pause$0.00/hrAutomatically snapshots memory/disk state after 5 minutes idle; zero charge while paused
Drop-in EnvironmentE2B_DOMAIN + E2B_API_KEYSet E2B_DOMAIN=cloud.noosfera.si and pass your sandbox API key

Sandbox Endpoints

ActionEndpoint
Create / ListPOST /v2/sandboxes, GET /v2/sandboxes (also /sandboxes)
Inspect / DeleteGET /sandboxes/:id, DELETE /sandboxes/:id
Pause / Resume / TimeoutPOST /sandboxes/:id/pause, POST /sandboxes/:id/resume, POST /sandboxes/:id/timeout
Run CommandsPOST /sandboxes/:id/commands (cmd, cwd, envs, timeoutMs)
Filesystem & PreviewsGET/PUT/POST/DELETE /sandboxes/:id/files, GET /sandboxes/:id/ports/:port
Usage Meter & HealthGET /v1/meters, GET /v1/health
cloud.noosfera.si
export E2B_DOMAIN="cloud.noosfera.si"
export E2B_API_KEY="$NOOSFERA_CLOUD_KEY" python3 -c 'from e2b_code_interpreter import Sandboxwith Sandbox.create() as sb:    print(sb.commands.run("bun --version").stdout)'
08 · Spend Protection

Rate Limits & Caps

Every turn takes a serialized pre-flight hold in integer micro-dollars (1 USD = 1,000,000 micro-USD), so a fleet of concurrent agents cannot overrun a key or the wallet.

ControlDefaultBehavior When Hit
Monthly Per-Key CapUp to $50/key (beta ceiling, configurable for orgs)Returns 429 key_limit_reached; refused turns cost $0
Daily UTC Key CapOptional per-key USD limitReturns 429 key_daily_limit_reached until 00:00 UTC
Wallet Balance HoldPre-flight worst-case boundReturns 402 insufficient_balance with available_usd & required_usd
Concurrent In-Flight4 turns per tenant (up to 16 ceiling)Prevents parallel fan-out storms; excess bursts return 429
Max Request Payload8 MiB on /v1/*Oversized payloads return 413 too_large
Rolling Pace WindowsOptional 5-hour / weekly plan capShifts routine turns to honest Eco Mode (x-noosfera-mode: hemat)
09 · Privacy & Governance

Data Retention

Standard buyer and organization keys store no prompt or completion. Request logs keep counts and billing fields only; any optional trace path runs a deterministic secret and Indonesian PII scrubber first.

Guarantee

Zero Prompt Storage & PII Scrubber

The ledger schema, the NIK/NPWP/card/secret rules, and OAuth isolation, field by field.

Read Data Retention →
Per-Call Opt-Out

x-gateway-no-trace: 1

Turns recording off for that request, whatever the key’s settings.

Scrubber rules →