Client SDKs

TypeScript Client Guide

Resolve and invoke Datafuse tools with the @datafuse/sdk package.

@datafuse/sdk is a typed client generated from the Datafuse API. Each method maps to one v1 route. It uses the built-in fetch, has no runtime dependencies, and works from both ES modules and CommonJS.

bash
npm install @datafuse/sdk

The examples use top-level await: save them as an ES module, for example tools.mjs.


1. Create a Client

Pass the credential yourself: the SDK does not read environment variables. The client sends it as both Authorization: Bearer and x-api-key, so one client works with either credential type.

typescript
import { Datafuse } from '@datafuse/sdk'

const sdk = new Datafuse({ apiKey: process.env.DATAFUSE_API_KEY })
You pass as apiKeyThe client can
An API key (df_live_...)Resolve tools, list tools, export tool schemas, invoke tools, list connected accounts, browse providers
An access tokenEverything above except connected accounts, plus list, create, test and delete integrations

For a self-hosted deployment add baseUrl: 'https://your-datafuse-host'.


2. Find a Verified Integration

Listing integrations needs an access token. Do this once and keep the id.

typescript
const admin = new Datafuse({ apiKey: process.env.DF_TOKEN })

const page = await admin.integrations.listIntegrationsApiV1IntegrationsGet()
const integration = page.items.find((item) => item.verified)
if (!integration) throw new Error('No verified integration. Connect and verify one in the dashboard first.')

const integrationId = integration.id
console.log(integration.provider_key, integrationId)

To check an integration's credentials from code, call admin.integrations.testIntegrationApiV1IntegrationsIdTestPost({ id }) and read verified on the result.


3. Resolve Tools

typescript
const tools = await sdk.integrations.resolveToolsApiV1IntegrationsIdResolveToolsPost({ id: integrationId })

for (const tool of tools) {
  console.log(tool.slug, tool.input_schema?.required ?? [])
}

4. Invoke a Tool

Pass a tool's slug as tool_key. This example calls DeepSeek's read-only deepseek_list_models; use a slug and arguments from your own integration.

typescript
const result = await sdk.integrations.invokeToolApiV1IntegrationsIdInvokePost({
  id: integrationId,
  integrationInvokeRequest: { tool_key: 'deepseek_list_models', arguments: {} }
})

console.log(result.successful)
console.log(result.successful ? result.data : result.error)

Errors

A non-2xx response rejects with a ResponseError that carries the original Response:

typescript
try {
  await sdk.integrations.resolveToolsApiV1IntegrationsIdResolveToolsPost({ id: integrationId })
} catch (error) {
  if (error.response) console.error(error.response.status, await error.response.text())
  else throw error
}

401 means the credential is not accepted on that route. 403 with connection_verification_required means the integration's credentials are not verified.


Client Layout

PropertyRoutes
sdk.integrationsIntegrations, tool resolution, tool schemas, invoke
sdk.providersProvider catalog
sdk.connectedAccountsConnected accounts
sdk.apiKeys, sdk.authAPI keys, login and refresh
sdk.organizations, sdk.billing, sdk.auditLogsAccount, billing and audit

Method names follow the route they call. Use your editor's completion on each property to browse them.


Next Steps