Rava SDK docs
This page reflects the current SDK implementation in this repository. It documents the exported client, method signatures, default values, and required fields as implemented in the rava-ai/sdk package.
1) Install
Terminal
pnpm add @rava-ai/sdk
2) Initialize once
The SDK uses a singleton. Call RavaClient.initialize() once at app startup, then use RavaClient.getInstance() wherever you need it.
TypeScript
import { RavaClient } from '@rava-ai/sdk'
RavaClient.initialize({
apiKey: process.env.RAVA_API_KEY!,
// Optional. Defaults to https://rava-ydvd.onrender.com
baseUrl: process.env.RAVA_BASE_URL ?? 'https://rava-ydvd.onrender.com',
})Calling getInstance() before initialize() throws an error.
3) Ingest data
Ingest accepts either inline content or a file path. Metadata is required and should include a type such as text, github, url, or file.
const client = RavaClient.getInstance()
await client.ingest({
name: 'kb-intro',
content: 'Rava uses your data to answer questions.',
metadata: { type: 'text' },
})
await client.ingest({
name: 'kb-file',
filePath: './data.txt',
metadata: { type: 'file' },
})IngestInput
- name: string (required)
- content?: string
- filePath?: string
- metadata: { type: 'text' | 'github' | 'url' | 'file'; ... } (required)
4) Query data
Query takes a question and optional chat history. If top_k is not provided, the SDK defaults it to 5.
const client = RavaClient.getInstance()
const response = await client.query({
question: 'What did I ingest?',
history: [
{ role: 'user', content: 'Answer in one sentence.' },
],
top_k: 5,
})
console.log(response.answer)QueryInput
- question: string (required)
- history?: Array<{ role: string; content: string }>
- top_k?: number (defaults to 5)
QueryResponse
- answer: string
Notes from the example app
- The example Nest app initializes RavaClient once during bootstrap.
- The ingest flow in the example uses filePath to read local data.txt.
- The query flow passes QueryInput directly to client.query().
5) Get API key flow
You can obtain your project API key directly from the UI. Follow this path in the app:
Steps in UI
- From the home page, click Get started.
- Sign up or sign in on the auth screen.
- You will be redirected to your dashboard.
- Click Create project and submit the form.
- Once created, use Show API key on that project.
- Copy the key and set it as RAVA_API_KEY in your app.