SDK reference
Every option, method, and export of the Dexby TypeScript SDK.
bun add @dexby.ai/sdk
# or: npm install @dexby.ai/sdkThe SDK is ESM only. To use a framework provider, also install its framework; see providers.
import { Dexby } from '@dexby.ai/sdk'
export const dexby = new Dexby({ userId: 'user_123' })Options
new Dexby(config) takes one optional object.
| Option | Type | Default | What it does |
|---|---|---|---|
apiKey | string | env DEXBY_API_KEY | Project API key. Create one in the dashboard under Configure → API keys. The constructor throws if it is empty. |
userId | string | none | Your id for the end user. Used by every call that takes a userId and gets none. |
baseURL | string | env DEXBY_API_URL, else Dexby Cloud (api.dexby.ai) | API host. Set DEXBY_API_URL once instead of passing it. |
mcpURL | string | env DEXBY_MCP_URL, else https://mcp.dexby.ai | Where MCP clients reach your MCP endpoints. Used by mcpUrl(). |
provider | ToolProvider | new OpenAiProvider() | Format and type of session.tools(). See frameworks. |
Results
API request errors are returned through neverthrow results as SdkError. Methods returning
ResultAsync<T, SdkError> can be chained with .andThen(...) before awaiting; the first error
stops the chain. Constructor validation and exceptions in your callbacks can still throw.
import { Dexby } from '@dexby.ai/sdk'
const dexby = new Dexby({ userId: 'user_123' })
const tools = await dexby
.createSession({ connectors: ['slack'] })
.andThen((session) => session.tools())
if (tools.isErr()) throw new Error(tools.error.message)
console.log(tools.value)Dexby methods
Every method that returns a ResultAsync also accepts an AbortSignal (as signal in the
options object, or as the last argument).
| Method | Returns | What it does | REST |
|---|---|---|---|
createSession(options?) | ResultAsync<Session, SdkError> | Opens a session for one user. Options match the REST body: userId, connectors, actions, pinned, accounts, allowGlobalAccounts, policy, ttlMinutes. | Sessions |
execute({ toolId, input, userId?, connectionId?, allowGlobalAccounts? }) | ResultAsync<unknown, SdkError> | Runs one tool directly, outside a session. Without a userId, the API uses default. allowGlobalAccounts lets it choose a global account. | Tools |
createConnectLink(options?) | ResultAsync<ConnectLink, SdkError> | Single-use link to the hosted Connect page. Options: userId, connectors, authConfigs, redirectUrl, expiresInMinutes. | Connect links |
createTrigger({ connectionId, event, secret? }) | ResultAsync<Trigger, SdkError> | Subscribes to one event on one connection. | Triggers |
listTriggers(signal?) | ResultAsync<Trigger[], SdkError> | The project's triggers. | Triggers |
deleteTrigger(id, signal?) | ResultAsync<{ id: string }, SdkError> | Removes a trigger. | Triggers |
mcpUrl(slug, userId?) | string | Builds an MCP endpoint URL, <mcpURL>/<slug>/<userId>. Makes no request and takes no AbortSignal. | MCP |
searchTools(query?, signal?) | Promise<ToolDescriptor[]> | The project's tools, every page. Empty array on failure. | Tools |
searchConnectors({ query?, category? }) | Promise<ConnectorSummary[]> | Connectors the project can use, every page. Empty array on failure. | Connectors |
getConnector(id, signal?) | Promise<ConnectorDescriptor | undefined> | One connector with authMethods and toolIds. undefined when missing or on failure. | Connectors |
createSession and createConnectLink return a VALIDATION_ERROR without calling the API when
neither the call nor the client has a userId. mcpUrl takes the endpoint slug you chose in
Distribute → MCP endpoints.
Session
createSession() resolves to a Session.
| Member | Type | What it is |
|---|---|---|
id | string | Session id. |
userId | string | The end user. |
mcpUrl | string | The session as an MCP server. See MCP. |
state | SessionState | Scope, policy, expiry, and each connector's connection status at creation. |
definitions(format?, signal?) | ResultAsync<SessionTool[], SdkError> | Tool definitions, 'json-schema' (default) or 'openai-strict'. |
call(name, args, signal?) | ResultAsync<ToolOutcome, SdkError> | Runs one session tool with the model's arguments. |
tools(signal?) | ResultAsync<T, SdkError> | The tools in the client provider's format, each calling back into this session. |
A ToolOutcome is { ok: true, result } or { ok: false, error }. The second is a refusal the
model reads and acts on, not an SdkError. See Sessions.
Providers
A provider turns session tools into one framework's tool type. Pass it as provider.
Framework providers need that framework installed next to the SDK (an optional peer dependency).
Model API providers return plain definitions without a framework dependency. Install the model
client package if your application calls its API directly.
| Provider | Framework | Install alongside |
|---|---|---|
OpenAiProvider | OpenAI Chat Completions (default) | nothing |
OpenAiResponsesProvider | OpenAI Responses API | nothing |
OpenAiAgentsProvider | OpenAI Agents SDK | @openai/agents (^0.18.0) |
AnthropicProvider | Anthropic Messages API | nothing |
GeminiProvider | Google Gemini | nothing |
GoogleAdkProvider | Google Agent Development Kit | @google/adk (^2.1.0) |
BedrockProvider | Amazon Bedrock Converse | nothing |
AiSdkProvider | Vercel AI SDK | ai (5, 6, or 7) |
MastraProvider | Mastra | @mastra/core (^1.71.0) |
LangChainProvider | LangChain | @langchain/core (^1.2.13) |
LlamaIndexProvider | LlamaIndex | @llamaindex/core (^0.6.23) |
GenkitProvider | Genkit | genkit (^1.42.0) |
StrandsProvider | Strands Agents | @strands-agents/sdk (^1.19.0) |
Snippets for each are in frameworks.
Errors
An SdkError has code and message, plus issues on VALIDATION_ERROR and choices (the
user's accounts) on AMBIGUOUS_CONNECTION. Branch on code. Every code, with the fix, is in
errors.
Exports
| Path | Exports |
|---|---|
@dexby.ai/sdk | Dexby, Session, OpenAiProvider, dexbyConfigSchema, and types (SdkError, SessionState, ToolOutcome, ...) |
@dexby.ai/sdk/contracts | dexbyConfigSchema, toolInputSchema, types ToolProvider, ToolExecutor, SdkError |
@dexby.ai/sdk/providers/openai | OpenAiProvider |
@dexby.ai/sdk/providers/openai-responses | OpenAiResponsesProvider |
@dexby.ai/sdk/providers/openai-agents | OpenAiAgentsProvider |
@dexby.ai/sdk/providers/anthropic | AnthropicProvider |
@dexby.ai/sdk/providers/gemini | GeminiProvider |
@dexby.ai/sdk/providers/google-adk | GoogleAdkProvider |
@dexby.ai/sdk/providers/bedrock | BedrockProvider |
@dexby.ai/sdk/providers/ai-sdk | AiSdkProvider |
@dexby.ai/sdk/providers/mastra | MastraProvider |
@dexby.ai/sdk/providers/langchain | LangChainProvider |
@dexby.ai/sdk/providers/llamaindex | LlamaIndexProvider |
@dexby.ai/sdk/providers/genkit | GenkitProvider |
@dexby.ai/sdk/providers/strands | StrandsProvider |