@ai-sdk/openai-compatible provider.
Install
await, so set "type": "module" in your package.json. Run a file with npx tsx example.ts.
Create the provider
includeUsage: true asks for token usage at the end of every stream.
Generate and stream
Tool calling
Multi-step tool loops work the same as with any first-party provider:Web search
Lyceum can search the web while the model answers. Passweb_search_options in the provider options, and the provider adds it to the request:
The model cites results as [1], [2] and so on. To get the pages it found as sources, use the Responses API with the web_search tool from @ai-sdk/openai (npm i @ai-sdk/openai):
We run the searches, so they show in the result’s steps as tool calls marked providerExecuted, next to your own tools. store: false makes the SDK send earlier steps in full, which loops with your own tools need, because we don’t store responses. Give your own tools names other than web_search. See Web search for pricing, limits and the models that search best.
Notes
- Reasoning tokens are reported. In AI SDK 6 and later,
usage.outputTokenDetails.reasoningTokensseparates thinking from visible output on reasoning models likez-ai/glm-5.2. - Not the same as AI Gateway. Vercel’s AI Gateway serves its own model catalog; this provider talks to Lyceum directly, so your traffic and billing stay with us.
- Keep
LYCEUM_API_KEYserver-side. Never ship it to a browser bundle.