DOCUMENTATION / QUICKSTART
Integrate in two minutes with zero SDK lock-in.
Point any OpenAI-compatible client at https://gateway.tensormesh.io/v1 and attach a routing policy header.
01 / CLIENT SETUP
Drop-in gateway client.
Streaming SSE, function calling, and structured outputs pass through natively without schema rewrites.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TENSORMESH_KEY,
baseURL: "https://gateway.tensormesh.io/v1",
defaultHeaders: {
"x-tm-policy": "prod-checkout-v2",
"x-tm-cache-ttl": "3600",
},
});
const response = await client.chat.completions.create({
model: "gpt-4.1",
messages: [{ role: "user", content: "Summarize invoice #8491." }],
}); 02 / ROUTING POLICY
Declarative fallback graph.
Version-control provider priorities, semantic cache thresholds, and timeout ceilings in JSON or Terraform.
{
"policy_id": "prod-checkout-v2",
"semantic_cache": {
"enabled": true,
"cosine_threshold": 0.96,
"ttl_seconds": 3600
},
"routes": [
{ "provider": "openai", "model": "gpt-4.1", "timeout_ms": 2200 },
{ "provider": "anthropic", "model": "claude-3-7-sonnet", "timeout_ms": 2800 },
{ "provider": "vertex", "model": "gemini-2.5-pro", "timeout_ms": 3000 }
],
"retry_on": [429, 500, 502, 503, 529]
} 03 / OBSERVABILITY HEADERS
Per-request routing telemetry in every response.
| Header | Example Value | Description |
|---|---|---|
| x-tm-provider | anthropic/us-east | Provider and region that fulfilled the inference call. |
| x-tm-cache | HIT_SEMANTIC (0.982) | Cache outcome: MISS, HIT_EXACT, or HIT_SEMANTIC with similarity score. |
| x-tm-fallback-depth | 1 | Number of upstream failovers executed before receiving a valid response. |
| x-tm-overhead-ms | 0.38 | Total gateway processing overhead excluding upstream inference time. |
| x-tm-cost-usd | 0.000412 | Exact settled token cost calculated from active provider rate card. |