# @storyshelf/ai

> AI insights engine on the Vercel AI SDK — build triage and project health, providers supplied by you.

Source: https://storyshelf.js.org/packages/ai/

`@storyshelf/ai` implements the `Ai` surface that `ShelfOptions.ai` accepts. It owns the `ai` core and `@ai-sdk/otel` (pinned exactly) and never sees provider keys: you install a provider package and pass configured models in. See the [AI insights guide](https://storyshelf.js.org/ai/) and [ADR 0016](https://github.com/GuptaSiddhant/StoryShelf/blob/main/docs/adr/0016-ai-insights.md).

## Install

```sh
npm i @storyshelf/ai
```

[![JSR](https://jsr.io/badges/@storyshelf/ai)](https://jsr.io/@storyshelf/ai) [![JSR Score](https://jsr.io/badges/@storyshelf/ai/score)](https://jsr.io/@storyshelf/ai)

- [npm package](https://www.npmjs.com/package/@storyshelf/ai) — install tarballs and version history.
- [JSR package](https://jsr.io/@storyshelf/ai) — TypeScript-first registry page.
- [Source on GitHub](https://github.com/GuptaSiddhant/storyshelf/tree/main/packages/ai) — package directory on `main`.

## Usage

```ts
import { createAi } from "@storyshelf/ai";
import { createShelfApp } from "@storyshelf/app";
import { openai } from "@ai-sdk/openai";

const ai = createAi({
  profiles: { default: { defaultModel: openai("gpt-4o-mini") } },
  budget: { dailyTokens: 2_000_000 },
});

const app = createShelfApp({ database, storage, ai });
```

Passing `ai` turns AI on site-wide; a site admin then enables it per project by choosing a profile in project settings. One export, `createAi`, plus the option types. Everything else is internal.
