Skip to main content

Vercel AI SDK

Use the AI SDK’s OpenAI-compatible provider to call Radium from Node.js or server-side code in a Next.js application.

Before you start

You need:
  • Node.js 22 or newer
  • npm
  • A Radium API key
Radium calls must run on the server. Never expose the key through browser code or a NEXT_PUBLIC_* environment variable.

1. Create a project and install the packages

2. Set your Radium credentials

3. Create main.mjs

The base URL must include /v1. The provider adds /chat/completions itself.

4. Run it

Expected output:

Choose a model

Migrate an existing AI SDK application

Create the provider once:
Then replace the model supplied to generateText, streamText, or your server route:
Your prompts and server-side AI SDK handlers can remain unchanged.

Streaming

Use streamText for token-by-token streaming:

Tool calling

The Vercel AI SDK supports tool calling with Radium via the same tools parameter:

Troubleshooting

Validation

These instructions were verified with Node.js 24.1.0, ai@7.0.71, and @ai-sdk/openai-compatible@3.0.33 on August 20, 2026. You do not need those exact package versions.
Text generation and multi-step tool calling passed cleanly with hal-1.0, clarke-1.0, and tycho-1.0.

Next steps

API quickstart

Call Radium directly

Tool calling

The tool_use and tool_result contract