Getting started · Installation
Installation
Install the Cosavu SDK in your project. Official SDKs are available for TypeScript and Python. Both are typed end-to-end and handle retries, telemetry, and connection pooling automatically.
TypeScript / JavaScript
The TypeScript SDK ships with full type definitions. It works in Node.js 18+, Bun, Deno, Cloudflare Workers, and Vercel Edge Runtime.
$ npm install @cosavu/sdkVerify installation
import { Cosavu } from "@cosavu/sdk" const cosavu = new Cosavu({ apiKey: process.env.COSAVU_API_KEY }) const health = await cosavu.health() console.log(health.status) // "ok"
Runtime compatibility
| Runtime | Minimum version | Notes |
|---|---|---|
| Node.js | 18.0 | Native fetch required. |
| Bun | 1.0 | Full support including streaming. |
| Deno | 1.40 | Use npm:@cosavu/sdk specifier. |
| Cloudflare Workers | — | Edge runtime supported. |
| Vercel Edge | — | Edge runtime supported. |
| Browsers | — | Use a server proxy. Don't expose keys client-side. |
Python
The Python SDK requires 3.9 or later. It uses httpx under the hood and supports both sync and async modes.
$ pip install cosavuVerify installation
from cosavu import Cosavu import os cosavu = Cosavu(api_key=os.environ["COSAVU_API_KEY"]) health = cosavu.health() print(health.status) # "ok"
Async client
Every endpoint has an async equivalent. Import AsyncCosavu and await calls:
from cosavu import AsyncCosavu import asyncio async def main(): cosavu = AsyncCosavu(api_key=os.environ["COSAVU_API_KEY"]) result = await cosavu.context.optimize(prompt="...") print(result.optimized_prompt) asyncio.run(main())
Client configuration
Pass options to the constructor to customise the SDK's behaviour:
const cosavu = new Cosavu({ apiKey: process.env.COSAVU_API_KEY, baseUrl: "https://api.cosavu.com", // override for self-hosted timeout: 30_000, // ms, default 60s maxRetries: 3, // default 2 defaultHeaders: { "x-org": "acme" }, // custom headers })
Self-hosted deployments
If you're running Cosavu in your own VPC or on-prem, set baseUrl to your private endpoint. The SDK is identical otherwise.