Vercel AI SDK
Use Vercel’sai package together with Incredible’s OpenAI-compatible endpoint by creating a client with @ai-sdk/openai-compatible. The example below mirrors the basic_stream.ts sample bundled with the Incredible SDK tests and shows the minimal pieces you need to stream completions.
Requirements
- Node.js 18 or newer
- An Incredible API key (the API currently works without one, but plan for it)
- Packages:
ai,@ai-sdk/openai-compatible
Configure the Incredible client
At the top of your script, import both the OpenAI-compatible helper and Vercel’sstreamText runner. basic_stream.ts uses these lines to plug Incredible into any Vercel AI SDK project:
createOpenAICompatiblegives you a drop-in client for any OpenAI-style model ID (usesmall-2for public access).- The optional
User-Agentheader mirrors the sample script; keep it if your environment standardises outbound requests.
Stream a completion
The full sample streams tokens tostdout while keeping the rest of the script light:
- Pass any prompt as a CLI argument:
node basic_stream.mjs "Generate a haiku". streamTextyields an async iterator, so you can render the stream in a UI instead ofstdout.
Next steps
- Swap in other Incredible model IDs (check the Models page for current options).
- Handle retries and errors with your own policy by wrapping the
streamTextcall. - Pair this setup with Vercel AI SDK’s React hooks for server actions or edge streaming.