TypeScript SDK
@rydhm/sdk is the TypeScript client for the Rydhm API. It is generated from the API’s OpenAPI document, so its types match what the API accepts and returns.
The SDK isn’t published to npm yet. Until it is, call the API over HTTP: every example in these docs has a curl version, and the API reference shows each request in TypeScript.
Install
The SDK uses the platform’s fetch. Run it on your server, never in a browser: it needs your API key.
Initialize
If you pass no apiKey, the client reads RYDHM_API_KEY from the environment.
How methods are named
Methods are grouped by resource: client.experts, client.knowledge, client.conversations, client.chat, client.voice, client.meetings, client.tools, client.analytics. Path parameters come first, in order. Query parameters and the body go together in one request object after them:
Every method needs a scope on your key. See Scopes.
Common tasks
List experts
Scope: experts:read.
Start a chat and send a message
chat.send stores your message. Read the expert’s reply from the stream. Scope: chat:write.
Stream the reply
Each frame is typed by its type: sources, delta, tool_call, tool_result, message, done or error. See Stream the reply.
To continue the conversation, call chat.send and chat.stream again with the same id.
Read a conversation
Scope: conversations:read.
Search knowledge
Scope: knowledge:read. mode (hybrid or vector) is optional.
Add a document
Scope: knowledge:write. For a PDF, Word, Markdown, text or CSV file, use client.knowledge.addFile(expertId, { filename, data }) with the file as base64.
Send an expert to a meeting
Scope: meetings:join. Always pass an idempotency key: a retry with the same key returns the first result instead of sending a second bot.
Errors
A non-2xx response throws. Each common status has its own class, and all of them extend RydhmError:
err.body is the API’s error body, with error (or code), message and requestId.
Retries
By default the SDK retries a request up to 2 times, with exponential backoff, when the response is 408, 429 or any 5xx. Change it for the whole client with maxRetries, or for one call:
Retries also apply to calls that start paid work. Always pass an Idempotency-Key to meetings.join, so a retried request can’t send a second bot.
Headers and request ids
.withRawResponse() gives you the response headers too, such as the request id and rate-limit state:
Every method also takes request options as its last argument: timeoutInSeconds, maxRetries, abortSignal and extra headers.