@vibesjs/sdk.
Setup issues
Wrong registry: npm:@vibesjs/sdk
If you import from npm:@vibesjs/sdk instead of jsr:@vibesjs/sdk, the import resolves silently but produces no useful exports — the npm name is a placeholder stub.
Fix: Always use the JSR registry.
Zod version mismatch (v3 vs v4)
Vibes requires Zod v4. Installingzod without a version pin may give you Zod v3, which has a different API. Symptoms include TypeScript errors on z.object, z.string, and similar.
Fix:
Missing API key
Every provider requires an API key set as an environment variable. If the key is absent, the provider throws a401 or similar authentication error at runtime.
Fix: Export the key before running your script:
Never commit API keys to source control. Add
.env to your .gitignore and use your deployment platform’s secret management in production.Deno cache corruption
If Deno reports a missing export for a package that exists, a corrupted cache entry may be to blame. This can happen after a failed or partial download. Detect: The import resolves butz (or another export) is undefined at runtime.
Fix: Clear the affected entry and re-run:
<package> and <version> with the affected package (e.g. zod/4.0.0).
Provider errors
APICallError / connection refused
This usually means the provider’s API is unreachable or the model name is incorrect.
Check:
- Your API key is set and valid.
- The model string matches the provider’s naming (e.g.
"claude-sonnet-4-6"for Anthropic,"gpt-4o"for OpenAI). - You have network access from where the script runs.
Model not found
Passing an unrecognised model ID to a provider function causes the provider to reject the request.Understanding error classes
@vibesjs/sdk throws typed errors that you can catch and handle specifically. Import them from jsr:@vibesjs/sdk:
| Error class | When it is thrown |
|---|---|
MaxTurnsError | The agent exceeded maxTurns without producing a final result |
MaxRetriesError | Result validation failed after all configured retries |
UsageLimitError | A token or request limit set via usageLimits was exceeded |
ApprovalRequiredError | A tool with requiresApproval: true was called and needs human sign-off |
ModelRequestsDisabledError | A real model call was made while setAllowModelRequests(false) is active in tests |
Catching a specific error
UsageLimitError fields
When you catch a UsageLimitError, it carries three properties:
| Property | Type | Description |
|---|---|---|
limitKind | "requests" | "inputTokens" | "outputTokens" | "totalTokens" | Which limit was exceeded |
current | number | Usage at the point of failure |
limit | number | The configured cap |
Debugging failed tool calls
When a tool call fails, the SDK feeds the error back to the model so it can retry or adjust. If failures persist, add logging inside yourexecute function:
Common Zod schema mistakes
Using .optional() on required parameters
The model will not pass optional fields reliably. Prefer explicit defaults or separate tools.
Forgetting .describe() on fields
Without descriptions, the model has no guidance on what each field means. Always add .describe() to every parameter.
Overly deep or recursive schemas
Deeply nested or self-referential Zod schemas can cause providers to reject the generated JSON Schema. Keep tool parameters flat where possible.Next steps
Getting Help
Where to ask questions and report bugs
Installation
Back to the installation guide