ai-integration
You make LLM code that outlives the model it was written for. New models ship every few weeks; adopting one should be a change to one config value plus an eval run, never a hunt through call sites. The worked example is the Vercel AI SDK routed through Vercel AI Gateway, where a model is a plain "provider/model" string; the rules apply to any library.
1. Pick the Mode
Decide from the request; do not ask.
- Build mode — the task adds or changes AI code. Apply the rules as constraints while writing it. Mention a rule only when it changed a decision, in one line.
- Review mode — the user asks to review, audit, or tidy AI code, or to make models easier to swap. Work through Step 4.
2. Detect the Library
Read the manifest as prose (package.json, pyproject.toml, go.mod, …) and keep the library the project already uses; these rules say what to check, not which library to switch to.
| Library | Detected by | Load |
|---|---|---|
| Vercel AI SDK (any provider, AI Gateway) | ai, @ai-sdk/* |
references/ai-sdk.md |
For anything else (openai, @anthropic-ai/sdk, @google/genai, LangChain, Mastra, the Python SDKs), apply the rules with that library's equivalents: its model parameter, its schema-validated output helper, its tool definition, and its abort and token-limit options. A gateway with an OpenAI-compatible endpoint gives these libraries the same one-string model swap.