OpenAI starter module
OpenAI library
Centralizes the OpenAI client, model settings, output checks, and retry rules.
- Files
- 7
- Lines
- 528
- Languages
- TypeScript
Included files
This page lists paths and purposes, not source contents.
src/lib/app-adapter.ts
Connects generic OpenAI handlers to your app's database, accounts, and limits.
TypeScript
167 lines
src/lib/approved-models.ts
The trusted catalog of models this app may call, with per-model limits.
TypeScript
72 lines
src/lib/env.ts
Reads OpenAI and notification settings from the environment and rejects missing values.
TypeScript
83 lines
src/lib/openai-client.ts
Creates the single server-side OpenAI client the whole starter shares.
TypeScript
22 lines
src/lib/request-account.ts
Resolves which app account is making an AI request.
TypeScript
12 lines
src/lib/types.ts
Shared types for the OpenAI starter: the adapter contract, usage records, and tool results.
TypeScript
122 lines
src/lib/with-retries.ts
Retries an OpenAI call on rate limits and transient server errors, nothing else.
TypeScript
50 lines