NEWTry the playground — no API key required
Skip to content
Developers

From zero to first request in minutes.

One OpenAI-compatible API for every model, with typed SDKs, streaming, routing metadata and errors you can act on.

01Quickstart

Three steps.

01

Create an API key

Sign in and create a key under API Keys. It’s shown once — store it as API_KEY.

terminal
export API_KEY="pv-live-…"
02

Install the SDK

Use the TypeScript or Python SDK, or skip this step and call the HTTP API directly.

terminal
npm install @pivotra/sdk# orpip install pivotra
03

Make your first request

Use a specific model ID, or auto to let routing decide. The response tells you which model served it and what it cost.

1import Pivotra from "@pivotra/sdk";2 3const client = new Pivotra({ apiKey: process.env.API_KEY });4 5const response = await client.chat.completions.create({6  model: "auto",7  messages: [8    { role: "user", content: "Summarize this support ticket in one sentence." },9  ],10});11 12console.log(response.choices[0].message.content);13console.log(response.routing.model, response.usage.cost);
response.json
1{2  "id": "req_8f2a91c04b7d",3  "object": "chat.completion",4  "model": "gpt-6-luna",5  "routing": {6    "strategy": "balanced",7    "model": "gpt-6-luna",8    "provider": "openai",9    "fallback_used": false,10    "decision_ms": 311  },12  "choices": [13    {14      "index": 0,15      "message": { "role": "assistant", "content": "Customer cannot reset their password after the latest update." },16      "finish_reason": "stop"17    }18  ],19  "usage": { "prompt_tokens": 182, "completion_tokens": 14, "total_tokens": 196, "cost": 0.0000357 }20}
02SDKs

Typed clients, or plain HTTP.

Official clients for TypeScript and Python. Anything that speaks the OpenAI chat completions format works too.

TypeScript
npm i @pivotra/sdk

Node 18+, Deno, Bun and edge runtimes. Full types for requests, responses and errors.

Python
pip install pivotra

Sync and async clients, Python 3.9+, typed with Pydantic models.

HTTP
curl / fetch / any client

OpenAI-compatible JSON over HTTPS. Works from any language.

03Streaming

Tokens as they’re generated.

stream.ts
1const stream = await client.chat.completions.create({2  model: "auto",3  stream: true,4  messages: [{ role: "user", content: "Write a haiku about latency." }],5});6 7for await (const chunk of stream) {8  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");9}
04Error handling

Errors you can act on.

errors.ts
1import Pivotra, { APIError, RateLimitError } from "@pivotra/sdk";2 3try {4  const res = await client.chat.completions.create({ model: "auto", messages });5} catch (err) {6  if (err instanceof RateLimitError) {7    // 429 — respect the Retry-After header8    await sleep(err.retryAfterMs);9  } else if (err instanceof APIError) {10    console.error(err.status, err.code, err.requestId);11  } else {12    throw err;13  }14}