Skip to content
Aurabase Logo
aurabase

JavaScript SDK: AI reference

Every method of the AI service and of sessions, with its signature.

Reference6 min readLevel reference

AiService#

MethodDescription
session(): Promise<AiSession>Mints an ephemeral ticket AI session (POST /v1/ai/{project_id}/session) and returns a ready-made AiSession for chat/chatStream/embed.
chat(messages: ChatMessage[], options?: { model?: string; temperature?: number; max_tokens?: number; system?: string; provider?: string; }): Promise<AuraResponse<ChatResponse>>Chat completion (not streamed).
chatStream(messages: ChatMessage[], options?: { model?: string; temperature?: number; max_tokens?: number; system?: string; signal?: AbortSignal; }): AsyncGenerator<ChatStreamChunk>Streamed chat completion (SSE).
embed(req: EmbedRequest): Promise<AuraResponse<EmbedResponse>>Generate embeddings for the given input(s).
rag(req: RagRequest): Promise<AuraResponse<RagResponse>>Retrieval-Augmented Generation: query a collection and get an answer.
ragIngest(req: RagIngestRequest): Promise<AuraResponse<RagIngestResponse>>Ingest a document into a RAG namespace.
listNamespaces(): Promise<AuraResponse<RagNamespace[]>>Lists the RAG namespaces of the project.
deleteNamespace(namespace: string): Promise<AuraResponse<RagDeleteResponse>>Deletes a RAG namespace (and its corpus).
reindexNamespace(namespace: string): Promise<AuraResponse<RagReindexResponse>>Re-indexes a RAG namespace with the current embedding model (remediation after a model/dimension change).
semanticSearch(query: string, namespace: string, options?: { top_k?: number; threshold?: number; }): Promise<AuraResponse<SemanticSearchResult[]>>Semantic search over an embedding namespace.
nl2sql(question: string, options?: { dialect?: 'postgresql' | 'postgres'; examples?: Array<{ question: string; sql: string; }>; limit?: number; }): Promise<AuraResponse<Nl2SqlResult>>Translates a question into SQL.

AiSession#

Ephemeral ticket AI session: mint a short-lived capability (POST /v1/ai/{project_id}/session, classic apikey auth) then use it for chat/chatStream/embed (Authorization: Bearer <ticket> ALONE — never apikey).

PropertyDescription
get budgetRemaining(): numberRemaining token budget, known at the last call (or at mint if no call has yet been made).
MethodDescription
static create(client: AuraClientLike): Promise<AiSession>Mint a new AI session.
chat(messages: ChatMessage[], options?: AiSessionChatOptions): Promise<AiSessionChatResult>Chat not streamed on this session.
chatStream(messages: ChatMessage[], options?: AiSessionChatStreamOptions): AsyncGenerator<ChatStreamChunk>Streamed chat (SSE) on this session.
embed(input: string): Promise<AiSessionEmbedResult>Embedding on this session ({input} → {embedding, budget_remaining}).
Generated page

This page is generated from the type declarations and comments of the SDK, so it cannot drift from the published code. For worked examples, read the guides.

@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Report a problem