Chat API

STREAM APIPro

Interface with the Relink RAG conversational engine via Server-Sent Events (SSE). Requires a Pro or Team plan.

POST/api/chat

Initiate a streaming conversation with the AI based on the user's saved bookmarks. The response is a standard W3C Server-Sent Event stream allowing for real-time text delivery. The first packet emitted will always contain the sources (array of links) used to generate the answer.

Parameters

NameTypeDescription
queryrequired
stringThe message or question from the user.
history
arrayArray of previous messages in the format { role: 'user'|'assistant', content: string }. Used to maintain conversational context across turns.
linkId
string (UUID)If provided, forces 'Scoped Mode' where the assistant focuses primarily on this specific bookmark (while silently attaching 3 related links for context). If omitted, runs in 'Global Mode' over the entire archive.

Request Example

Request
curl -X POST http://localhost:3000/api/chat \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{
    "query": "What are the tradeoffs of RSC?",
    "history": [{"role":"user","content":"Tell me about React"}]
  }'

Response Example

Response
# First packet: Metadata about retrieved sources
data: {"sources":[{"id":"uuid","url":"https://react.dev","title":"React Server Components","domain":"react.dev","tldr":"...","score":0.9}]}

# Subsequent packets: Streaming text tokens
data: {"content":"React Server "}

data: {"content":"Components (RSC) "}

data: {"content":"offer several tradeoffs..."}

# Final packet
data: [DONE]