Skip to content

Package reference

Reference · Packages

AskDB is a workspace of focused packages. Install the ones your use case needs. This page is the index — purpose, install, and key exports for each.

AskDB package dependency graph: core and introspect at the top, engine and enrichment packages in the middle, and surfaces (CLI, Studio, TUI, HTTP API) at the bottom composing them

AI provider adapters (@askdb/ai-openai, @askdb/ai-azure, @askdb/ai-google, @askdb/ai-anthropic) plug into the surfaces shown above via @askdb/ai. @askdb/client sits above @askdb/core + @askdb/ai as the config-driven entry point.

The dialect-agnostic NL-to-SQL pipeline. Schema loading, prompt construction, validation, and tenant-scope handling all live here.

Terminal window
npm install @askdb/core

Key exports

SymbolPurpose
ask(options)The main pipeline. Returns validated SQL.
loadSchema(path)Load a schema artifact from a directory, bundle, or schema.json.
validateTenantScope / resolveTenantSqlTenant-scope enforcement primitives.
createAskDbLoggerStructured logger that emits AskDB log events.
POSTGRES_DIALECT and built-in dialect IDsDialect inputs accepted by ask().
AskDbLanguageModelAskDB’s public name for the AI SDK language model contract.

Config-aware facade over @askdb/core. createAskDb() resolves the schema, model, and dialect from your askdb.config.* (and a provider registry you supply), so call sites pass only a question. Install it when you want the shortest config-driven path; skip it when you construct the model and load the schema yourself and call ask() directly.

Terminal window
npm install @askdb/client @askdb/ai @askdb/ai-openai @askdb/config

Key exports

SymbolPurpose
createAskDb(options)Build a client bound to a config + AI registry. Returns { ask, reload }.
client.ask(question, overrides?)Resolve schema/model/dialect and run the pipeline. Overrides: schema, model, dialect, plus all ask() options.
AskDbClient / CreateAskDbOptions / AskOverridesTypes for the client, constructor options, and per-call overrides.

Optional AI provider registry and shared config helpers. Install this when you want AskDB to construct AI SDK language or embedding models from askdb.config.* / env maps. Pair it with a provider adapter package such as @askdb/ai-openai. Skip it when you already construct your own AI SDK model and pass it to ask().

Terminal window
npm install @askdb/ai

Key exports

SymbolPurpose
createAiRegistryRegister provider adapters and build language or embedding models.
registry.resolveAiConfig(env) / registry.resolveEmbeddingConfig(env)Resolve provider config from env without constructing a model. These are methods on the registry returned by createAiRegistry, not standalone exports.
resolveBaseConfigLow-level helper — resolves a provider’s base config object from an env map. Used internally by adapters.
withEmbeddingProviderOptionsWraps embedding provider options; shared across adapters.
aiKeyMissingMessageShared human-readable missing-key guidance.

Provider adapters own concrete AI SDK provider dependencies. Each adapter declares ai and @askdb/ai as peer dependencies — npm/pnpm install them automatically, but your app should depend on ai directly when you want to pin the version.

Terminal window
npm install @askdb/ai-openai
npm install @askdb/ai-azure
npm install @askdb/ai-google
npm install @askdb/ai-anthropic

Any provider that has a Vercel AI SDK package can be added as an adapter. Unknown ai.provider values require a registered adapter — first-party apps register openai, azure, foundry, google, and anthropic; for anything else, embed AskDB and register your own adapter, or use an OpenAI-compatible endpoint via the openai provider and a custom base URL.

Connector provider registry — mirrors the @askdb/ai pattern for introspection. Each engine adapter exports a ConnectorProviderAdapter constant; @askdb/connectors wires them into a unified registry used by the CLI and apps. Install directly only when you are building a custom introspection flow.

Terminal window
npm install @askdb/connectors

Key exports

SymbolPurpose
createConnectorRegistry(adapters)Build a registry from a set of provider adapters.
ConnectorRegistryRegistry type — createConnector(provider, config), getTemplates(provider).
ConnectorProviderAdapterThe adapter shape each engine package exports.

Optional config bootstrap: .env and askdb.config.* discovery, type-safe defineConfig, and a runtime snapshot accessor.

Terminal window
npm install @askdb/config

Key exports

SymbolPurpose
defineConfig(config)Type-safe config builder.
bootstrapAskDbEnv(options)Load .env + askdb.config.* and install the runtime snapshot.
getAskDbRuntimeConfig()Read the runtime snapshot (preferred over process.env).
discoverAskDbConfigPath()Programmatic config-file discovery.
env, requiredEnvTyped env-var accessors.

Each engine package ships the introspection connector for its engine, any catalog SQL templates, and a re-export of that engine’s dialect constant. The dialect specs themselves (SQL generation + validation rules) live in @askdb/coreask() needs only the dialect id, no engine package.

Terminal window
npm install @askdb/postgres

PostgreSQL dialect, connector, catalog SQL templates, and an optional pg-based catalog query runner for live introspection. Pass dialect: "postgres" to ask().

Terminal window
npm install @askdb/mysql

MySQL dialect and introspection. Pass dialect: "mysql" to ask().

Terminal window
npm install @askdb/sqlite

SQLite dialect and introspection. Works with embedded file-backed databases. Pass dialect: "sqlite" to ask().

Terminal window
npm install @askdb/sqlserver

SQL Server (T-SQL) dialect and introspection. Pass dialect: "sqlserver" to ask().

The engine-agnostic introspection contract and the schema-directory writer. Use directly only when you’re calling introspection from your own code — the CLI wraps this for you.

Terminal window
npm install @askdb/introspect

File-only connector that reads .prisma schema files and produces AskDB physical metadata — no live database needed. Pair with an engine adapter for SQL generation at runtime.

Terminal window
npm install @askdb/prisma @askdb/introspect

See the Prisma integration guide.

Browser-based schema-authoring UI. The CLI’s askdb studio command lazy-imports this package.

Terminal window
npm install @askdb/studio

Terminal-based schema-authoring UI. The CLI’s askdb enrich command lazy-imports this package.

Terminal window
npm install @askdb/tui

Headless schema-authoring helpers shared by Studio and TUI. Use directly when building a custom authoring surface.

Terminal window
npm install @askdb/enrich

Chunks the schema artifact, indexes it in a vector store, and retrieves relevant chunks per question. Use with ask()’s retriever option for large schemas.

Terminal window
npm install @askdb/rag

Key exports

SymbolPurpose
buildSchemaIndex({ schema, store, embedder, ... })Chunk + embed + upsert a schema artifact; returns { retriever, stats, chunks }.
createAiSdkEmbedder({ model }) / createOpenAiEmbedder(...)Wrap an AI SDK embedding model (or raw OpenAI) as the embedder.
createRetriever({ store, embedder })Build the retriever passed to ask().
createPgvectorStoreThe pgvector store factory.

Ships a small CLI binary askdb-rag (notably askdb-rag setup-store for pgvector provisioning). See RAG for large schemas.

Minimal HTTP server wrapping ask(). Two endpoints (/health, POST /ask), designed to sit behind your gateway.

Terminal window
npm install @askdb/http-api

Key exports

SymbolPurpose
createAskDbHttpServer(options)Build the server.
AskHttpRequest / AskHttpSuccessResponse / AskHttpErrorResponseRequest and response types.

See the HTTP API reference for endpoints and error codes.

The askdb binary. Ships as a normal npm package — install for local development, demos, and CI.

Terminal window
npm install askdb

See the CLI reference.

PackageDepends on
@askdb/postgres, @askdb/mysql, @askdb/sqlite, @askdb/sqlserver@askdb/core, @askdb/connectors
@askdb/prisma@askdb/introspect, @askdb/connectors
@askdb/connectors@askdb/introspect
@askdb/aiAI SDK core package (ai)
@askdb/ai-openai, @askdb/ai-azure, @askdb/ai-google, @askdb/ai-anthropic@askdb/ai + the matching AI SDK provider package
@askdb/enrich, @askdb/rag@askdb/core
@askdb/tui, @askdb/studio@askdb/enrich (+ @askdb/rag when used)
@askdb/http-api@askdb/core (+ engine adapter)
askdb (CLI)All of the above (lazy-imported per command)

Reusable packages stay small and layered. First-party surfaces (CLI, Studio, TUI, HTTP API) compose them.