Skip to main content

Buyer Production Guide

Tenson is a 100% drop-in replacement for the OpenAI Chat Completions API. Point any existing OpenAI SDK, coding assistant (Cursor, Windsurf, Cline, Continue), or agent framework to https://api.tenson.app/v1 and start calling open-weights models at a fraction of centralized cloud prices.


1. Account Setup & Funding​

  1. Create a unified account at /signup/ (secured with Argon2id password hashing and 7-day HttpOnly JWT sessions).
  2. Purchase prepaid compute points in the Buyer Console under Billing & Ledger:
    • Pricing unit: 1,000 points = $1.00 USD
    • Available Stripe Checkout packs: $10 (10,000 pts), $50 (50,000 pts), $250 (250,000 pts), $1,000 (1,000,000 pts).
    • Points are credited atomically in PostgreSQL 16 via HMAC-verified checkout.session.completed Stripe webhooks (idempotent per session ID).
  3. Generate a SHA-256 API Key under API Keys:
    • Keys use the prefix sk_tenson_live_....
    • The full secret is revealed once on creation. Tenson stores only the SHA-256 digest in api_keys.

2. SDK Integration​

Python (openai>=1.0)​

python
from openai import OpenAI

client = OpenAI(
base_url="https://api.tenson.app/v1",
api_key="sk_tenson_live_...",
)

stream = client.chat.completions.create(
model="qwen3-30b",
messages=[
{"role": "system", "content": "You are a concise systems architect."},
{"role": "user", "content": "Compare vLLM and Ollama for multi-tenant serving."},
],
max_tokens=512,
temperature=0.2,
stream=True,
)

for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)

TypeScript / Node.js (openai>=4.0)​

TypeScript
import OpenAI from 'openai';

const client = new OpenAI({
baseURL: 'https://api.tenson.app/v1',
apiKey: process.env.TENSON_API_KEY,
});

const resp = await client.chat.completions.create({
model: 'llama-3.3-70b',
messages: [{role: 'user', content: 'Draft a PostgreSQL 16 double-entry migration.'}],
max_tokens: 1024,
});

console.log(resp.choices[0].message.content);
console.log('Usage:', resp.usage);

cURL​

Terminal
curl https://api.tenson.app/v1/chat/completions \
-H "Authorization: Bearer sk_tenson_live_..." \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-8b",
"stream": true,
"max_tokens": 256,
"messages": [{"role": "user", "content": "Hello Tenson Grid"}]
}'

3. Canonical Model Catalog & Pricing​

Query live availability and exact pricing programmatically via GET /v1/models.

Model IDHugging Face RepositoryMin VRAMInput / 1M TokensOutput / 1M Tokens
qwen3-8bQwen/Qwen3-8B12 GB45 pts ($0.045)90 pts ($0.090)
qwen3-30bQwen/Qwen3-30B-A3B24 GB120 pts ($0.120)280 pts ($0.280)
gpt-oss-20bopenai/gpt-oss-20b24 GB95 pts ($0.095)210 pts ($0.210)
deepseek-r1-32bdeepseek-ai/DeepSeek-R1-Distill-Qwen-32B24 GB150 pts ($0.150)320 pts ($0.320)
qwen2.5-coder-32bQwen/Qwen2.5-Coder-32B-Instruct24 GB130 pts ($0.130)260 pts ($0.260)
mistral-small-24bmistralai/Mistral-Small-24B-Instruct-250124 GB80 pts ($0.080)180 pts ($0.180)
gemma-3-27bgoogle/gemma-3-27b-it24 GB100 pts ($0.100)220 pts ($0.220)
llama-3.3-70bmeta-llama/Llama-3.3-70B-Instruct48 GB240 pts ($0.240)480 pts ($0.480)

4. Reliability, Escrow & Failover Guarantees​

Every request is protected by four built-in production safeguards:

  1. Pre-Flight Escrow Hold: Before routing, Tenson reserves ceil((prompt_tokens * in_rate + max_tokens * out_rate) / 1,000,000) points inside a serialized PostgreSQL transaction (SELECT ... FOR UPDATE). Unused escrow is released immediately upon stream completion.
  2. Silent 3,000ms TTFT Failover: If the selected GPU worker does not emit its first token within 3,000 ms, the Edge Gateway cancels the job, docks the worker -2.0 reputation, and transparently retries up to 2 additional nodes before your client ever sees an error.
  3. 100% Mid-Stream Drop Refund: If a P2P worker disconnects after streaming has begun, your entire escrow hold is refunded automatically (100%) and the worker receives a -5.0 reputation penalty.
  4. Invisible Centralized Overflow: When regional P2P concurrency slots are saturated, Tenson seamlessly overflows to dedicated upstream open-weights clusters (is_fallback = true) at the exact same API price.

5. Standard Error Codes​

HTTP Statuserror.codeCause & Recommended Handling
401invalid_api_keyMissing, malformed, or revoked sk_tenson_live_... Bearer token.
402payment_requiredAvailable point balance is lower than the requested max_tokens escrow hold. Top up in /buyer/.
429rate_limit_exceededPer-key 60-second RPM ceiling reached. Back off with exponential jitter.
502mid_stream_refundWorker dropped mid-stream (non-streaming request). Escrow is already 100% refunded; safe to retry.
503no_online_workersNo online P2P node and no overflow provider available for the requested model.

6. Zero-Log Privacy Guarantee​

Tenson never writes raw prompts or model completions to PostgreSQL, disk, or application logs. Your Request Logs table records strictly metadata: job_id, model_id, prompt_tokens, completion_tokens, ttft_ms, total_latency_ms, final_points_charged, and status. For the 3% of jobs sampled for Optimistic GPU Audits, the payload exists strictly in RAM-only Redis (--appendonly no) with a hard 300s TTL and is atomically deleted (GETDEL) upon verification.