Dexby

SDK reference

Every option, method, and export of the Dexby TypeScript SDK.

terminal
bun add @dexby.ai/sdk
# or: npm install @dexby.ai/sdk

The SDK is ESM only. To use a framework provider, also install its framework; see providers.

dexby.ts
import { Dexby } from '@dexby.ai/sdk'

export const dexby = new Dexby({ userId: 'user_123' })

Options

new Dexby(config) takes one optional object.

OptionTypeDefaultWhat it does
apiKeystringenv DEXBY_API_KEYProject API key. Create one in the dashboard under Configure → API keys. The constructor throws if it is empty.
userIdstringnoneYour id for the end user. Used by every call that takes a userId and gets none.
baseURLstringenv DEXBY_API_URL, else Dexby Cloud (api.dexby.ai)API host. Set DEXBY_API_URL once instead of passing it.
mcpURLstringenv DEXBY_MCP_URL, else https://mcp.dexby.aiWhere MCP clients reach your MCP endpoints. Used by mcpUrl().
providerToolProvidernew 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.

result.ts
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).

MethodReturnsWhat it doesREST
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?)stringBuilds 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.

MemberTypeWhat it is
idstringSession id.
userIdstringThe end user.
mcpUrlstringThe session as an MCP server. See MCP.
stateSessionStateScope, 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.

ProviderFrameworkInstall alongside
OpenAiProviderOpenAI Chat Completions (default)nothing
OpenAiResponsesProviderOpenAI Responses APInothing
OpenAiAgentsProviderOpenAI Agents SDK@openai/agents (^0.18.0)
AnthropicProviderAnthropic Messages APInothing
GeminiProviderGoogle Gemininothing
GoogleAdkProviderGoogle Agent Development Kit@google/adk (^2.1.0)
BedrockProviderAmazon Bedrock Conversenothing
AiSdkProviderVercel AI SDKai (5, 6, or 7)
MastraProviderMastra@mastra/core (^1.71.0)
LangChainProviderLangChain@langchain/core (^1.2.13)
LlamaIndexProviderLlamaIndex@llamaindex/core (^0.6.23)
GenkitProviderGenkitgenkit (^1.42.0)
StrandsProviderStrands 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

PathExports
@dexby.ai/sdkDexby, Session, OpenAiProvider, dexbyConfigSchema, and types (SdkError, SessionState, ToolOutcome, ...)
@dexby.ai/sdk/contractsdexbyConfigSchema, toolInputSchema, types ToolProvider, ToolExecutor, SdkError
@dexby.ai/sdk/providers/openaiOpenAiProvider
@dexby.ai/sdk/providers/openai-responsesOpenAiResponsesProvider
@dexby.ai/sdk/providers/openai-agentsOpenAiAgentsProvider
@dexby.ai/sdk/providers/anthropicAnthropicProvider
@dexby.ai/sdk/providers/geminiGeminiProvider
@dexby.ai/sdk/providers/google-adkGoogleAdkProvider
@dexby.ai/sdk/providers/bedrockBedrockProvider
@dexby.ai/sdk/providers/ai-sdkAiSdkProvider
@dexby.ai/sdk/providers/mastraMastraProvider
@dexby.ai/sdk/providers/langchainLangChainProvider
@dexby.ai/sdk/providers/llamaindexLlamaIndexProvider
@dexby.ai/sdk/providers/genkitGenkitProvider
@dexby.ai/sdk/providers/strandsStrandsProvider

On this page