baseURL, which means you can point it at Portrix and gain access to all 400+ models through the same streamText, generateText, and useChat interface you already know. Streaming, tool calling, and structured output work without any additional configuration because Portrix normalises every model’s response to the OpenAI SSE format.
Installation
Configuration
UsecreateOpenAI to create a custom provider instance that routes all requests through Portrix. Define this once and import it wherever you need a model:
portrix("provider/model") anywhere the Vercel AI SDK accepts a LanguageModel.
API route
Create a Next.js App Router API route that streams a response usingstreamText:
Set
maxDuration to a value appropriate for your Vercel plan. Streaming responses from large models can take longer than the default 10-second function timeout on the Hobby plan.useChat hook
Create a client component that uses theuseChat hook from ai/react to stream responses from your API route:
Switching models
Create multiple provider instances or select a model dynamically at runtime. This lets you route different request types to the most appropriate model:modelForTask in your API route to route requests dynamically:
Streaming and UI
All Vercel AI SDK streaming features — real-time token delivery,useChat state management, and toDataStreamResponse() — work with Portrix responses without any extra configuration. Portrix normalises every model’s output to the OpenAI Server-Sent Events format, so the SDK’s stream parser handles responses from Anthropic, Google, Mistral, and every other provider identically to native OpenAI responses.