DOCS
JS client
SvedaClient is the attach surface. Vue and web-component packages exist as optional UI — core does not require them.
Package
npm i @sveda-ai/core.
Main class
SvedaClient.
Session class
SvedaChatSession.
Product overview:
JS client.
SvedaClient options
endpoints.stream
is required. It is the
POST
target for a turn. Optional endpoints match the runtime:
message,
histories,
history(chatId),
documentsExtract.
-
protocolModedefaults to'sveda'. These docs cover that mode. -
headersis aRecord<string, string>or a getter() => Record<string, string>resolved on each request. -
toolsis aSvedaToolRegistry. If omitted, the client constructs one. -
contextis aSvedaContextRegistry. Snapshots merge into the stream bodycontextfield. -
autoSubmitFrontendToolResultsdefaults totrue. After atool.callwithtarget: "frontend", the session runs the handler and posts results on a follow-up stream turn.
import { SvedaClient, SvedaToolRegistry, SvedaContextRegistry } from '@sveda-ai/core'
const tools = new SvedaToolRegistry()
const context = new SvedaContextRegistry()
const client = new SvedaClient({
endpoints: {
stream: 'http://127.0.0.1:8787/sveda/stream',
message: 'http://127.0.0.1:8787/sveda/message',
histories: 'http://127.0.0.1:8787/sveda/chat-histories',
history: (chatId) => `http://127.0.0.1:8787/sveda/chat-histories/${chatId}`,
documentsExtract: 'http://127.0.0.1:8787/sveda/documents/extract',
},
protocolMode: 'sveda',
headers: {
'x-sveda-embed-token': token,
},
tools,
context,
autoSubmitFrontendToolResults: true,
}) Headers
Typical embed header:
x-sveda-embed-token.
The runtime also accepts
Authorization: Bearer sveda_embed_….
A getter is useful when the token rotates.
const client = new SvedaClient({
endpoints: { stream: '/sveda/stream' },
headers: () => ({
'x-sveda-embed-token': currentToken(),
}),
}) session.send and stop
client.session(chatId)
(or
createSession())
returns
SvedaChatSession.
send(text, options?)
POSTs JSON to
endpoints.stream
with
messages,
prompt,
chatId,
context,
clientTools,
and optional
model,
provider,
options.
stop()
aborts the in-flight request.
const session = client.session('chat_1')
await session.send('Summarize the last deploy.')
session.stop() Accept
In
protocolMode: 'sveda'
the client sets this Accept header. The server still responds with SSE
(text/event-stream).
See stream protocol.
Accept: application/vnd.sveda.stream+json Optional UI packages
@sveda-ai/vue
and
@sveda-ai/element
wrap the same core client. They are not required to stream a turn.
npm i @sveda-ai/vue
npm i @sveda-ai/element