Installation

npm install @beep-ai/sdk

Basic Usage

import { BeepClient } from '@beep-ai/sdk';

const client = new BeepClient({
    baseURL: 'http://localhost:5000',
    apiKey: 'YOUR_API_TOKEN'
});

// Chat completions
const response = await client.chat.completions.create({
    model: 'phi-2',
    messages: [{ role: 'user', content: 'Hello!' }]
});
console.log(response.choices[0].message.content);

// Streaming with SSE
for await (const chunk of client.chat.completions.createStream({
    model: 'phi-2',
    messages: [{ role: 'user', content: 'Tell me a story' }]
})) {
    process.stdout.write(chunk.choices[0].delta.content);
}

// Embeddings
const { data } = await client.embeddings.create({
    model: 'all-MiniLM-L6-v2',
    input: 'Hello world'
});

// RAG
const results = await client.rag.query({
    collectionId: 'my-docs',
    query: 'What is RAG?',
    topK: 5
});

Features

  • Full TypeScript declarations with strict types
  • Browser and Node.js support
  • SSE-based streaming with async iterators
  • Automatic /v1/* URL prefix handling
  • AbortController support for cancellation