Text from an OpenAI-compatible chat endpoint: retries, a rate limit, and answers checked
against the caller's zod schema. It throws AI_PROVIDER_ERROR; a project spreads
AI_ERRORS into defineErrors.
const text = createTextProvider({ baseUrl, apiKey, model });
temperature (0.2 by default) and reasoningEffort on TextAiConfig and on each request;
createEmbeddingProvider(config, { rateLimit }) embeds text and images, with retry and a turn
before each request; cosineSimilarity.
@haatlabs-core/ai/contracts (0.12.1): AI_ERRORS, AiErrorCode, createAiError and
the AiError type, with nothing of Node: a project's contracts, which its pages load, import from here and never the root, which is for Node.
Install
pnpm add @haatlabs-core/ai
It leaves one package to your app, so the app holds one copy: zod.