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
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:
Simple text
{ text: "Summarize this." }
One-shot instructions
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
})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
JavaScript / TypeScript
Dart / Flutter
Error handling
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
Multi-model providers if you need a specific vendor / model
Chat-style messages for
messages[]and RAG flagsSessions when you need
sessionIdSession logging for dashboard logs (
logs: true)
Last updated