Getting started · Quickstart
Quickstart
Get from zero to your first optimised LLM call in under five minutes. This guide assumes you have a Node.js or Python environment and an API key from your Cosavu dashboard.
01Get an API key
Sign in to the dashboard, create a new project, and copy the API key from the keys page. We recommend storing it in your environment as COSAVU_API_KEY.
# add to .env COSAVU_API_KEY=cv_live_a1b2c3d4e5f6...
Note
API keys start with cv_live_ in production and cv_test_ in test mode. Never commit either to source control.
02Install the SDK
Cosavu ships official SDKs for TypeScript and Python. They expose every endpoint as a typed function and handle retries, telemetry, and connection pooling for you.
$ npm install @cosavu/sdk03Make your first call
The fastest way to feel ContextAPI is to optimise a bloated prompt. Drop this snippet into a file, set the environment variable, and run it.
import { Cosavu } from "@cosavu/sdk" const cosavu = new Cosavu({ apiKey: process.env.COSAVU_API_KEY }) const result = await cosavu.context.optimize({ prompt: "Could you please kindly explain in great detail what RAG is and how it works step by step if that makes sense at all", budget: 512, }) console.log(result.optimizedPrompt) console.log(`Saved ${result.tokensSaved} tokens (${(result.compressionPct * 100).toFixed(0)}%)`)
You should see something like this in your terminal:
$ npx ts-node quickstart.ts "Explain RAG pipeline. Step by step." Saved 493 tokens (58%)
04Understand the response
Every optimize call returns a structured payload. The shape is identical across SDKs:
{
"color:#3b82f6">"optimizedPrompt": "Explain RAG pipeline. Step by step.",
"color:#3b82f6">"originalTokens": 847,
"color:#3b82f6">"outputTokens": 354,
"color:#3b82f6">"tokensSaved": 493,
"color:#3b82f6">"compressionPct": 0.582,
"color:#3b82f6">"latencyMs": 14,
"color:#3b82f6">"ir": {
"color:#3b82f6">"blocks": [
{ "color:#3b82f6">"blockType": "IDENTITY", ">"tokens": 12 },
{ "color:#3b82f6">"blockType": "INSTRUCTION", ">"tokens": 18 }
]
}
}Response fields
| Field | Type | Description |
|---|---|---|
optimizedPrompt | string | The compressed prompt ready to send to your LLM. |
originalTokens | number | Token count of the input prompt. |
outputTokens | number | Token count after optimisation. |
tokensSaved | number | Difference between input and output tokens. |
compressionPct | number | Fraction of tokens removed (0 to 1). |
latencyMs | number | End-to-end optimisation time in milliseconds. |
ir | PromptIR | Typed block structure detected during parsing. |
Next steps
You've seen ContextAPI. Here's where to go from here:
ContextAPI reference
Full endpoint reference, parameters, and SDK methods.
Read →
DataAPI overview
Add grounded retrieval — three tiers, one endpoint.
Read →
Authentication
API keys, scopes, and security best practices.
Read →
Errors & rate limits
Status codes, error shapes, and quota handling.
Read →