Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Send a prompt

The simplest AI integration is a single prompt via sendAI. You pass a message object (usually { text: "..." }), and the SDK returns the AI response from the HTTP call.

Requirements

Requirement
Details

Transport

http β€” required for request/response AI

Connection

await connect() before sendAI

Plan

aiEnabled === true after connect

senderId

Must match your connecting userId (or explicit id for service accounts)

Message shapes

sendAI accepts a flexible message payload:

Shape
Example
Use case

Simple text

{ text: "Summarize this." }

One-shot instructions

Chat messages

{ messages: [{ role, content }] }

Multi-role prompts β€” see Chat-style messages

With RAG

{ useKnowledgeBase: true, messages: [...] }

Grounded answers

Method signature

sendAI({
  senderId: string,
  message: object | string,
  saveHistory?: boolean,   // default true
  sessionId?: string,      // omit on first turn; pass on follow-ups
  provider?: string,       // e.g. "open_ai" β€” optional override
  model?: string,          // e.g. "gpt-4o" β€” optional override
})
Option
Default
Description

senderId

β€”

User id for the AI call

message

β€”

Prompt payload (text, messages, RAG flags, …)

saveHistory

true

Persist turn to AI history

sessionId

new UUID

Continue an existing session

provider

project default

Merged into request data when set

model

project default

Merged into request data when set; also recorded in session logs / observability

When provider / model are omitted, you get the project default from auth (current_model). Agents can carry their own defaults via defineAgent({ provider, model }); a value on the sendAI call still wins.

Provider API keys and cloud endpoints are set in the portal, not in SDK code. Full list and walkthroughs: Multi-model providers.

Supported provider strings (and deeper pages): multi-models README.

Response handling

HTTP sendAI resolves with the server response object. Extract the assistant text from common fields:

Session id for continuation (first turn):

Language guides

Language
Guide

JavaScript / TypeScript

Dart / Flutter

Error handling

Error
Likely cause

Not connected

Call connect() first

senderId required

Pass senderId matching your user

AI is not enabled

Upgrade plan or enable AI in dashboard

null response (JS)

Network or server error β€” check logs

Next steps

Last updated