You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: MIGRATION.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This package is a **small Vercel AI SDK extension** for MacPaw AI Gateway. Upstream **`ai`**, **`@ai-sdk/openai`**, **`@ai-sdk/react`** (or **`ai/react`**) stay the source for core APIs and hooks.
4
4
5
+
That also means upstream UI/hooks/version migrations stay upstream. If your installed `ai` / `@ai-sdk/react` version changes hook or schema APIs, follow the upstream versioned docs for those packages rather than expecting `@macpaw/ai-sdk` to redefine them.
Types for request/response bodies can come from your app, from OpenAI SDK types, or from gateway OpenAPI — they are not re-exported from this package today.
28
30
31
+
If you want the default production Gateway URL in fetch-only flows, use the public `resolveGatewayBaseURL()` helper and pass the resolved value into `createGatewayFetch()`.
32
+
29
33
## If you used `@macpaw/ai-sdk/runtime`
30
34
31
35
Internals (`executeRequestPipeline`, etc.) are not part of the public API. Prefer `createGatewayFetch` or provider options (`middleware`, `retry`, `timeout`, `fetch`).
32
36
37
+
The same applies to source-only error helpers: if a helper is not exported from `@macpaw/ai-sdk`, treat it as internal even if you see it in the repository source.
Copy file name to clipboardExpand all lines: README.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,8 @@ npm install @macpaw/ai-sdk
30
30
31
31
Also install upstream packages you call directly, for example `ai`, `@ai-sdk/openai`, `@ai-sdk/react`.
32
32
33
+
This package does not pin or wrap the upstream UI/hooks API from `ai` / `@ai-sdk/react`. Follow the versioned upstream docs for the exact major version you install there. If your chosen upstream version requires version-specific imports or patterns (for example schema helpers), use the upstream guidance for those APIs.
34
+
33
35
## Quick start (Vercel AI SDK)
34
36
35
37
```ts
@@ -88,9 +90,9 @@ Internal resolution: `resolveConfig()` in `gateway-config.ts`.
88
90
Same auth, retry, middleware, and error normalization as the provider path. Use **relative** URLs under the gateway root (e.g. `'/api/v1/images/edits'`) or absolute URLs that stay under the same gateway origin.
@@ -106,6 +108,8 @@ const res = await gatewayFetch('/api/v1/images/edits', { method: 'POST', body: f
106
108
107
109
Non-gateway absolute URLs are passed through without injecting Bearer auth (placeholder key is stripped). See `gateway-fetch.ts`.
108
110
111
+
`createGatewayFetch` requires a resolved `baseURL`. Use the exported `resolveGatewayBaseURL()` helper if you want the same `'production'` shortcut that provider factories support.
112
+
109
113
## `createGatewayProvider` — prefixed model IDs
110
114
111
115
Bare model IDs get a default Gateway prefix per provider constant; IDs that already contain `/` are unchanged.
-`createOpenAI` — optional override of `createOpenAI` from `@ai-sdk/openai` (tests/advanced)
149
153
154
+
Use `normalizeErrors: false` only when you intentionally want to inspect raw failed `Response` objects in provider-driven tests or adapters. Auth refresh and retry behavior still stay on; only typed non-OK error throwing is relaxed.
155
+
150
156
## Middleware
151
157
152
158
```ts
@@ -199,6 +205,8 @@ AIGatewayModule.forRoot({
199
205
});
200
206
```
201
207
208
+
If your Nest app uses TypeScript subpath exports strictly, make sure its `tsconfig` uses a modern resolver such as `moduleResolution: "Node16"`, `"NodeNext"`, or `"bundler"` so `@macpaw/ai-sdk/nestjs` resolves correctly.
209
+
202
210
Inject **`GatewayProviderSettings`** (not an HTTP client) and build providers in the service:
203
211
204
212
```ts
@@ -225,6 +233,8 @@ export class ChatService {
225
233
226
234
`AIGatewayExceptionFilter` maps `AIGatewayError` to JSON HTTP responses. See `examples/nestjs/` for a copy-paste skeleton.
227
235
236
+
Only documented root exports are public API. Source-level helpers such as `parseErrorResponseFromResponse` and `parseStreamErrorPayload` may exist internally, but they are not supported import targets unless exported from `@macpaw/ai-sdk`.
Copy file name to clipboardExpand all lines: templates/AGENTS.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ Apply these rules when integrating MacPaw AI Gateway.
9
9
-`@macpaw/ai-sdk/nestjs`: NestJS module and decorators.
10
10
- Install `@ai-sdk/openai` when using `createAIGatewayProvider` or `createGatewayProvider`.
11
11
- Never use `createAIGatewayClient`, `@macpaw/ai-sdk/client`, `runtime`, `types`, or `testing`.
12
+
- For UI hooks or schema helpers, follow the versioned upstream docs for the installed `ai` / `@ai-sdk/react` major version; this package does not redefine those APIs.
12
13
13
14
## Choose one integration path
14
15
@@ -22,7 +23,7 @@ Apply these rules when integrating MacPaw AI Gateway.
22
23
- Do not invent a token source. Ask once if unclear.
23
24
- Do not place gateway tokens in browser-only code.
24
25
-`env` supports only `'production'`; use `baseURL` for staging/custom hosts.
25
-
-`createGatewayFetch` requires `baseURL`.
26
+
-`createGatewayFetch` requires a resolved `baseURL`; prefer `resolveGatewayBaseURL()` when you want the default production host.
26
27
- Remove legacy imports and dependencies only after confirming all usages are migrated.
Copy file name to clipboardExpand all lines: templates/CLAUDE.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,14 @@ Use this guidance when integrating MacPaw AI Gateway into this project.
9
9
- Keep generation primitives on upstream `ai` / `@ai-sdk/*`.
10
10
- Install `@ai-sdk/openai` when using `createAIGatewayProvider` or `createGatewayProvider`; those paths depend on the OpenAI-compatible provider package.
11
11
- Do not use `createAIGatewayClient`, `@macpaw/ai-sdk/client`, `runtime`, `types`, or `testing`; those surfaces do not exist.
12
+
- For UI hooks or schema helpers, follow the versioned upstream docs for the installed `ai` / `@ai-sdk/react` major version; this package does not redefine those APIs.
12
13
13
14
## Guardrails
14
15
15
16
- Do not invent a token source. If server-side token retrieval is unclear, ask one concise question.
16
17
- Do not put real gateway tokens in browser-only code.
17
18
- Use `env: 'production'` only for the default MacPaw host. Use `baseURL` for staging or custom hosts.
18
-
-`createGatewayFetch` requires a resolved `baseURL`; do not pass only `env`.
19
+
-`createGatewayFetch` requires a resolved `baseURL`; do not pass only `env`. Prefer `resolveGatewayBaseURL()` when you want the default production host.
19
20
- Remove old provider dependencies only after verifying there are no remaining usages.
0 commit comments