- Node.js 22+ for development (see
.nvmrc). The SDK itself supports Node >=18 at runtime. - pnpm (see
packageManagerinpackage.json)
git clone https://github.com/macpaw/ai-sdk-typescript.git
cd ai-sdk-typescript
pnpm installESLint, Prettier, and TypeScript are configured directly in this repository via eslint.config.js, .prettierrc, and tsconfig.json. Keep pnpm format:check and pnpm lint both green after edits.
pnpm dev # watch mode (rebuild on change)
pnpm typecheck # TypeScript type checking
pnpm lint # ESLint
pnpm lint:fix # ESLint with auto-fix
pnpm test # run tests
pnpm test:watch # run tests in watch mode
pnpm test:coverage # run tests with coverage
pnpm build # production buildThis project uses Conventional Commits enforced by semantic-release.
feat: add streaming support for audio API
fix: handle empty response body in SSE parser
perf: reduce bundle size by tree-shaking unused codecs
docs: update retry configuration examples
test: add coverage for rate-limit retry logic
chore(deps): update vitest to v3
refactor: extract middleware chain into separate module
For breaking changes, add ! after the type:
feat!: rename createClient to createAIGatewayClient
| Branch | Purpose | npm tag |
|---|---|---|
main |
Stable releases | latest |
Feature and fix branches use the pattern feat/<slug>, fix/<slug>, chore/<slug>, etc.
- Branch from
main - Make your changes
- Ensure all checks pass:
pnpm typecheck && pnpm lint && pnpm format:check && pnpm test && pnpm build - Open a PR against
main - Fill in the PR template
Place specs next to the feature they cover using a __tests__ directory (e.g. src/__tests__/gateway-fetch.spec.ts). vitest.config.ts picks up src/**/__tests__/**/*.spec.ts and src/**/__tests__/**/*.test.ts.
src/
├── gateway-config.ts # GatewayProviderSettings, resolveConfig, retry defaults
├── gateway-errors.ts # AIGatewayError family, ErrorCode, parsers
├── gateway-fetch.ts # createGatewayFetch (custom fetch for OpenAI SDK / raw HTTP)
├── gateway-provider.ts # createAIGatewayProvider, createGatewayProvider, GATEWAY_PROVIDERS
├── gateway-request.ts # executeRequestPipeline (internal; not re-exported from root)
├── gateway-retry.ts # withRetry
├── index.ts # Public API — @macpaw/ai-sdk
└── nestjs/ # @macpaw/ai-sdk/nestjs
Add behavior beside the smallest module that owns it; avoid new public entry points unless package.json exports and tests are updated together.