JavaScript SDK: AI reference
Every method of the AI service and of sessions, with its signature.
6 min read·Level reference·Revised on Oct 12, 2026
This English text was generated automatically from the French original and has not been reviewed yet.
#
Class
AiService
| Method | Description |
|---|---|
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>> | Send a chat completion request. |
chatStream(messages: ChatMessage[], options?: { model?: string; temperature?: number; max_tokens?: number; 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. |
#
Class
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).
| Property | Description |
|---|---|
get budgetRemaining(): number | Remaining token budget, known at the last call (or at mint if no call has yet been made). |
| Method | Description |
|---|---|
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.
Last updated · Oct 12, 2026