npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@askdb/ai

v0.1.0-beta.6

Published

AskDB AI provider registry and shared config helpers for AI SDK language and embedding models.

Readme

@askdb/ai

AskDB AI provider registry and shared config helpers. This package resolves AskDB config/env maps and dispatches to provider adapters such as @askdb/ai-openai.

@askdb/core stays BYO-model: it accepts a model and runs the NL-to-SQL pipeline. Use this package only when you want AskDB's shared provider selection and env-key precedence.

Most applications never import this package directly: createAskDb from @askdb/client accepts providers: [openaiProvider] and builds the registry internally. Import @askdb/ai yourself only to construct model objects outside the client or to share one registry across several clients.

Install

pnpm add @askdb/ai ai
# Plus the AskDB provider adapter you configure:
pnpm add @askdb/ai-openai

Install only the provider adapter packages your runtime uses.

Usage

import { bootstrapAskDbEnv, getAskDbRuntimeConfig } from "@askdb/config";
import { createAiRegistry } from "@askdb/ai";
import { openaiProvider } from "@askdb/ai-openai";
import { ask, loadSchema } from "@askdb/core";

const ai = createAiRegistry([openaiProvider]);

bootstrapAskDbEnv({ cwd: process.cwd() });

const runtime = getAskDbRuntimeConfig();
const model = await ai.createLanguageModelFromEnv(runtime.ai.aiEnv);

if (!model) throw new Error("No AI key configured.");

const schema = loadSchema("./askdb");

const result = await ask({
  question: "How many users signed up last week?",
  schema,
  dialect: "postgres",
  model,
});

Reasoning/latency effort

resolveProviderOptions maps a provider-portable reasoning effort ("minimal" | "low" | "medium" | "high") to each adapter's native generateText providerOptions — OpenAI/Azure reasoningEffort, Google thinkingConfig (thinkingLevel for Gemini 3.x, thinkingBudget for Gemini 2.5), Anthropic extended thinking. It returns undefined when the effort is unset or the model doesn't support reasoning tuning.

const config = ai.resolveAiConfig(runtime.ai.aiEnv)!;
const model = await ai.createLanguageModel(config);
const providerOptions = ai.resolveProviderOptions(config, { reasoningEffort: "low" });

await ask({ question, schema, dialect: "postgres", model, deps: { providerOptions } });

resolveReasoningEffort(env, purpose, override) resolves the effective effort from an explicit override, a call-site env var (ASKDB_AI_REASONING_EFFORT_NL_TO_SQL / _ENRICHMENT), then the global ASKDB_AI_REASONING_EFFORT — set from askdb.config.ts's ai.reasoning block by @askdb/config. See the config reference.

Exports

  • createAiRegistry
  • resolveBaseConfig
  • registry methods such as resolveAiConfig, resolveEmbeddingConfig, createLanguageModelFromEnv, createEmbeddingModelFromEnv, and resolveProviderOptions
  • aiKeyMissingMessage
  • aiProviderMissingMessage
  • resolveReasoningEffort, isReasoningEffort, REASONING_EFFORTS

License

Apache-2.0 © Yahya Gilany. See LICENSE and NOTICE.