Official DocumentationEndpoint: /v1/chat/completions

Tanvelo Gateway & Official SDK Reference

Complete technical guide for integrating Tanvelo's unified LLM gateway and official TypeScript and Python client SDKs into production AI applications.

TS: npm install tanvelo
Python: pip install tanvelo
URL: https://tanvelo-backend-zgyc.onrender.com/v1
01

Architecture & Gateway Overview

Tanvelo sits between your application and upstream LLM providers, providing unified routing, automated failovers, distributed token-bucket rate limits, and an auditable request ledger with zero prompt retention.

Deterministic Failover

Upstream 429s and 5xx outages failover to secondary models in under 180ms without dropping the active stream.

Distributed Limits

Redis-backed atomic token buckets enforce requests-per-minute (RPM) and tokens-per-minute (TPM) per API key.

Zero Retention

Prompts and provider outputs stream in-flight and are never stored on disk. Only cryptographic telemetry is logged.

02

Quickstart

Connect your upstream providers in the Tanvelo Dashboard, generate an API key, and make your first completion with automatic failover.

import { Tanvelo } from "tanvelo";

const tanvelo = new Tanvelo({
  apiKey: process.env.TANVELO_API_KEY, // "tv_live_..."
});

async function main() {
  const response = await tanvelo.chat.completions.create({
    model: "provider/your-model-name",
    fallbacks: ["fallback-provider/your-fallback-model-name"],
    messages: [
      { role: "system", content: "You are a concise production AI engineer." },
      { role: "user", content: "Explain deterministic circuit breakers." }
    ],
    temperature: 0.7,
  });

  console.log(response.choices[0].message.content);
  console.log("Provider:", response._tanvelo?.provider);
  console.log("Latency:", response._tanvelo?.latencyMs, "ms");
}

main();
03

Official TypeScript & Node.js SDK

Published as tanvelo. Zero third-party runtime dependencies with complete typings for completions, SSE streaming, and telemetry.

Streaming Example
import { Tanvelo } from "tanvelo";

const tanvelo = new Tanvelo({ apiKey: process.env.TANVELO_API_KEY });

const stream = await tanvelo.chat.completions.create({
  model: "provider/your-model-name",
  fallbacks: ["fallback-provider/your-fallback-model-name"],
  messages: [{ role: "user", content: "Stream a high-availability checklist." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
04

Official Python SDK

Published as tanvelo on PyPI. Requires zero external packages, leveraging Python's standard library for fast microservice and container runtimes.

Streaming Example
from tanvelo import Tanvelo

client = Tanvelo()

stream = client.chat.completions.create(
    model="provider/your-model-name",
    fallbacks=["fallback-provider/your-fallback-model-name"],
    messages=[{"role": "user", "content": "Stream a high-availability checklist."}],
    stream=True
)

for chunk in stream:
    print(chunk.delta, end="", flush=True)
print()
05

Direct HTTP / REST API Reference

Connect from any HTTP client by sending a standard POST request:

POST/v1/chat/completions
Headers:
Content-Type: application/json
Authorization: Bearer tv_live_...
X-Tanvelo-Fallbacks: fallback-provider/your-fallback-model-name
FieldTypeRequiredDescription
modelstringYesPrimary model identifier in format "provider/your-model-name"
messagesarrayYesArray of message objects with role and content
fallbacksstring[]NoOrdered backup models to execute on failure (e.g. ["fallback-provider/your-fallback-model-name"])
streambooleanNoIf true, returns Server-Sent Events (SSE)
06

140+ AI Providers & Universal Custom Endpoints

Like LiteLLM, Tanvelo provides out-of-the-box routing and parameter translation across 140+ foundational providers and inference engines. You can invoke any provider using explicit prefix notation (<provider>/<your-model-name>) or configure automated routing rules.

Prefix Routing Examples
// Wafer-Scale Fast Silicon
model: "cerebras/your-model-name"

// Open-Weights Provider
model: "together/your-model-name"

// Frontier Reasoning Provider
model: "openai/your-model-name"

// Enterprise Managed Cloud
model: "azure/your-model-name"

// Self-Hosted / On-Prem vLLM
model: "vllm/your-model-name"
Any Custom API / On-Prem Ingress

Connect ANY private cluster, corporate proxy, or third-party service:

  • Supports any Base URL (e.g. https://llm.corp.net/v1)
  • Flexible auth: Bearer, Azure api-key, custom headers, or unauthenticated local runners
  • Automatic fallback to other providers upon timeouts or outages
07

Deterministic Fallbacks & Circuit Breakers

When upstream providers return rate limits (429) or server errors (500/502/503), Tanvelo immediately shifts in-flight execution to your secondary choices in under 180ms without interrupting active streaming connections.

08

Distributed Rate Limits & Spend Caps

Configure atomic Redis token-bucket limits per API key (RPM/TPM). Monthly budget caps automatically block requests with standard 429 errors when spend ceilings are hit.

09

Webhook Signature Verification (HMAC-SHA256)

Tanvelo delivers webhooks with a cryptographically verifiable Tanvelo-Signature header (t=TIMESTAMP,v1=SIGNATURE).

TypeScript Verification
import crypto from 'crypto';

// Verify Tanvelo webhook signatures: "t=TIMESTAMP,v1=SIGNATURE"
export function verifyTanveloWebhook(payloadRaw, signatureHeader, secret) {
  const parts = Object.fromEntries(
    signatureHeader.split(',').map((p) => p.split('='))
  );

  const timestamp = parts.t;
  const signature = parts.v1;

  // Protect against replay attacks (5 minute threshold)
  if (Math.abs(Math.floor(Date.now() / 1000) - parseInt(timestamp, 10)) > 300) {
    return false;
  }

  const expected = crypto
    .createHmac('sha256', secret)
    .update(`${timestamp}.${payloadRaw}`)
    .digest('hex');

  return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}
Python Verification
import hmac
import hashlib
import time

def verify_tanvelo_webhook(payload_raw: bytes, signature_header: str, secret: str) -> bool:
    parts = dict(item.split("=") for item in signature_header.split(","))
    timestamp = parts.get("t")
    signature = parts.get("v1")

    if not timestamp or not signature:
        return False

    if abs(time.time() - int(timestamp)) > 300:
        return False

    signed_payload = f"{timestamp}.".encode("utf-8") + payload_raw
    expected = hmac.new(secret.encode("utf-8"), signed_payload, hashlib.sha256).hexdigest()

    return hmac.compare_digest(signature, expected)
10

HTTP Status Codes & Error Payloads

Status CodeTypeDescription
400 Bad Requestinvalid_request_errorMissing required fields or invalid JSON payload
401 Unauthorizedauthentication_errorMissing or invalid Tanvelo API key (must begin with tv_live_)
429 Too Many Requestsrate_limit_exceededRate limit quota exceeded or hard monthly spending budget reached
502 Bad Gatewayupstream_provider_errorPrimary provider and all configured fallbacks failed or timed out
503 Service Unavailableprovider_unavailableNo provider credentials configured in dashboard for requested model