Quickstart
Get up and running with CaesuraO in minutes. This guide will help you install the SDK and make your first injected language model call.
1. Choose your SDK
CaesuraO operates as a middleware that wraps your existing LLM client. Choose the SDK that matches your current stack:
- Vercel AI SDK:
@caesura-io/ai-sdk - Official OpenAI SDK:
@caesura-io/openai
2. Install the SDK
In this example, we'll use the Vercel AI SDK integration. Install the CaesuraO package alongside ai (and your preferred provider, such as @ai-sdk/anthropic):
npm install @caesura-io/ai-sdk ai @ai-sdk/anthropic
3. Set your Environment Variables
CaesuraO uses API keys for authentication. All integrations use the shared API base URL, https://api.caesurao.com. See Environments & Access for service URLs and access details.
export CAESURA_API_KEY="caesura_..."
export ANTHROPIC_API_KEY="your-provider-key"
4. Make your first call
Wrap your model with caesuraMiddleware and enable automatic conversation creation for your local session ID. CaesuraO observes the supplied dialogue and makes completed guidance available to later model calls.
import { wrapLanguageModel, generateText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { caesuraMiddleware } from '@caesura-io/ai-sdk';
// 1. Wrap your model with the CaesuraO middleware
const model = wrapLanguageModel({
model: anthropic('claude-sonnet-4-6'),
middleware: caesuraMiddleware({
autoCreateConversation: true,
// apiKey is auto-read from the CAESURA_API_KEY environment variable
}),
});
// 2. Provide the conversation history
const conversation = [
{ role: 'user' as const, content: 'I need help preparing for the next meeting.' }
];
const sessionId = "unique-conversation-123";
// 3. Generate text. CaesuraO analyzes the conversation asynchronously
// and will inject insights into future turns.
const result = await generateText({
model,
messages: conversation,
// Pass a conversationId so CaesuraO can track the context
providerOptions: { caesura: { conversationId: sessionId } },
});
console.log(result.text);
This example saves analyses automatically. Reuse the same sessionId and middleware instance for each turn, and use a different ID for each chat. See Conversations & Persistence to continue chats across restarts.
Analysis runs in the background by default. Add mode: 'sync' to use guidance on the current call. Include your dialogue history, with actual model replies, on subsequent calls.
Next Steps
- Review Conversations & Persistence.
- Learn more about Authentication.
- Explore the SDK details for advanced usage and credit metering.
- Check out the Examples to see fully functional applications.