macpaw/ai-sdk-typescript/integrate-ai-gateway
Claude Code and agent skill by macpaw/ai-sdk-typescript
- community
Checking that the SKILL.md file is still in the repository.
Integrate applications with AI Gateway using @macpaw/ai-sdk. Use for NestJS, Next.js, Vercel AI SDK, raw fetch migrations, video generation, voice listing, text-to-speech, credit balance queries, MacPaw AI, Setapp AI, createAIGatewayProvider, createGatewayFetch, createVideoClient, createVoiceClient, createSpeechClient, createCreditBalanceClient, and AI Gateway auth/error wiring.
Install
npx vskill@latest install macpaw/ai-sdk-typescript/integrate-ai-gatewaySKILL.md
AI Gateway Integration (@macpaw/ai-sdk)
Goal
Detect the app shape, choose one integration path, apply the smallest correct patch, add safe auth/error handling, run verification, and report exact changes.
Package surface
- Use
@macpaw/ai-sdkforcreateAIGatewayProvider,createGatewayProvider,createGatewayFetch,createVideoClient,createVoiceClient,createSpeechClient,createCreditBalanceClient,GATEWAY_PROVIDERS, errors, andGatewayProviderSettings. - Use
@macpaw/ai-sdk/provideronly as a compatibility alias. - Use
@macpaw/ai-sdk/nestjsforAIGatewayModule,@InjectAIGateway(), andAIGatewayExceptionFilter. - Do not use
createAIGatewayClient,@macpaw/ai-sdk/client,runtime,types, ortesting; they do not exist. - For UI hooks or schema helpers, follow the versioned upstream docs for the installed
ai/@ai-sdk/reactmajor version; this package does not redefine those APIs.
Guardrails
- Do not invent a token source. If server-side token retrieval is unclear, ask one question.
- Do not place real tokens in browser-only code. Frontend-only apps need a backend/BFF token source.
- Do not remove direct OpenAI/Anthropic paths unless all usages are migrated or the user asked for it.
- Use
baseURLfor staging/custom hosts.envsupports only'production'. createGatewayFetchrequires a resolvedbaseURL; do not pass onlyenv. PreferresolveGatewayBaseURL()when you want the default production host.
Choose one path
- NestJS markers:
@nestjs/common,*.module.ts, decorators -> use@macpaw/ai-sdk/nestjs+@macpaw/ai-sdk. - Next.js / Vercel markers:
next,ai,@ai-sdk/*-> keep generation onai, swap only the model provider. - Express/Fastify/Hono/server scripts -> use
createGatewayFetch, orai+ provider if already Vercel-shaped. - Video generation (create job, poll status, fetch content) -> use
createVideoClient. - Voice listing (paginated
GET /v1/voices) -> usecreateVoiceClient. - Speech generation (streaming text-to-speech,
POST /v1/audio/speech) -> usecreateSpeechClient. - Credit balance queries (active balances, totals) -> use
createCreditBalanceClient. - Existing
openai,@ai-sdk/openai, or@anthropic-ai/sdkusage -> treat as migration, not greenfield.
Canonical patterns
Error handling
- Prefer
isAIGatewayError(error)and switch onErrorCode. - Use
AIGatewayExceptionFilterin NestJS. - Treat
InsufficientCredits/SubscriptionExpiredas the billing states; there is noPaymentRequired.
Migration rules
- Keep
generateText,streamText,embed, React hooks, and upstream primitives onai/@ai-sdk/*. - Replace direct gateway-bound provider construction with
createAIGatewayProviderorcreateGatewayProvider. - Replace raw HTTP gateway calls with
createGatewayFetch. - Remove old dependencies only after verifying there are no remaining imports/usages.
Verification
- Read
package.jsonscripts before running commands. - Prefer
typecheck,lint,test, andbuildwhen available. - Add one focused smoke path: provider call, route handler, or
fetchstub. - Do not claim success without reporting which verification commands actually ran.
Output contract
- State the chosen path: NestJS, Vercel, or raw fetch.
- List files changed.
- State where the token now comes from.
- State verification run and any manual env step left.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtemplates/cursor/skills/integrate-ai-gateway/SKILL.md
Popularity
- Repository stars
- 58
- Repository forks
- 1
- Repository npm downloads, 7 days
- 114
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 14 Aug 2026, 2 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/macpaw/ai-sdk-typescript/integrate-ai-gateway)