Vercel AI SDK
Route the Vercel AI SDK through ToyGate as a custom provider.
Integrations
The Vercel AI SDK ships a configurable provider. Override baseURL to your gateway and pass a gw_ key. generateText and streamText work through this provider; structured-output helpers are not currently supported.
Config
ts
generateText
streamText
Structured output
generateObject and other structured-output paths send response_format. ToyGate does not support that field yet and returns HTTP 400 with error.code = "response_format_not_supported". Do not ship a generateObject integration through the gateway until that contract changes.
Tool calls
Troubleshooting
APICallError: Unauthorized— the SDK couldn't validate against the gateway. Make sureprocess.env.GATEWAY_KEYis set in the runtime (Node, edge, lambda).InvalidJSONResponseError— the upstream sent something the SDK couldn't parse as JSON; the gateway wraps this asupstream_invalid_response(502).- Edge runtimes — the gateway works fine over fetch; pass
globalThis.fetchexplicitly if your edge environment has an exotic global setup.
Gateway URL: https://api.toygate.store