Skip to main content
POST
/
:projectId
/
api
/
v7
/
search
/
ask
Ask Content
curl --request POST \
  --url https://api.sublay.io/api/v6/:projectId/api/v7/search/ask \
  --header 'Content-Type: application/json' \
  --data '
{
  "query": "<string>",
  "sourceTypes": [
    "<string>"
  ],
  "spaceId": "<string>",
  "conversationId": "<string>",
  "limit": 123
}
'
Answers a natural language question using content from your project as context. The endpoint first performs semantic retrieval to find relevant content, then sends the context to an LLM to generate a grounded answer. Responds via Server-Sent Events (SSE) for streaming output. Requires a paid plan with semantic search enabled.

Body Parameters

query
string
required
The question to answer. Typos and ambiguous phrasing are handled gracefully.
sourceTypes
string[]
default:"[\"entity\", \"comment\", \"message\"]"
Content types to use as context. Any combination of entity, comment, message.
spaceId
string
Restrict the context lookup to a specific space.
conversationId
string
Restrict message context lookup to a specific conversation.
limit
number
default:"20"
Maximum number of content chunks to retrieve for context. Maximum 50.

Query Parameters

Space-scoped reputation

This endpoint has a space in context, so it accepts the opt-in reputation params. They add a spaceReputation field to each source record’s populated user, alongside the always-present reputation total. Requires the reputation bundle. See the Reputation data model for the full contract.
spaceReputationId
string
Adds spaceReputation to each returned user. One of: a space <uuid> (that space’s bucket), none (the project-general bucket), or context (the space derived from this request’s context — per-row on lists). The empty string and the legacy general / null aliases are rejected (400). Missing buckets read as 0.
spaceReputationDescendants
boolean
Only honored with an explicit space <uuid>. When true, spaceReputation is the subtree sum — the space plus all of its descendants (the root space’s own bucket included). Ignored for none; not allowed with context.

Response

The response is a Server-Sent Events stream with Content-Type: text/event-stream. Three event types are emitted: token — streamed LLM answer tokens:
event: token
data: {"content": "Based on"}

event: token
data: {"content": " the discussion..."}
sources — the content records used as context, sent after the answer is complete:
event: sources
data: [{"sourceType": "entity", "similarity": 0.87, "record": {...}}, ...]
Each source object follows the same shape as the Search Content response — sourceType, similarity, and a fully populated record. An empty array is sent when no relevant context was found. done — signals the stream is finished:
event: done
data: {}
If no relevant content is found above the similarity threshold, the LLM response is skipped and the answer event immediately says “I couldn’t find any relevant content to answer your question.”

Error Responses

{ "error": "Semantic search requires a paid plan", "code": "project/plan-required" }
Only returned when headers have not yet been sent (i.e., before streaming starts).
If an error occurs after streaming starts:
event: error
data: {"error": "Internal server error"}