Radondocs

Quickstart

Send your first message with Radon AI in about five minutes — one provider, one chat call, no branching decisions.

By the end of this page you'll have sent a real chat completion and read back the model's answer, token usage, and finish reason. We'll use OpenAI because it's free-tier in Radon and its keys work instantly, but every step maps onto any of the 10 providers.

Prerequisites

Node 18 or newer, and an OpenAI API key (sk-…) from the OpenAI dashboard.

Install the package

npm i @radonsdk/ai

Zero required dependencies — no openai SDK, no axios. Radon talks to every provider over fetch. (The official provider SDKs are optional peer deps, pulled in only if you use the native() escape hatch.)

Set your key

Radon reads provider credentials from environment variables named RADON_<PROVIDER>_API_KEY, so you never hard-code secrets.

.env
RADON_OPENAI_API_KEY=sk-...

Create the client

lib/ai.ts
import { RadonAI } from "@radonsdk/ai";

export const ai = new RadonAI({
  providers: { openai: {} },      // {} = read credentials from the env var
  defaultProvider: "openai",
});

With free-only providers (openai, anthropic, groq) you don't need to call ai.init(). init() is only required when you configure a Pro provider or use a Pro feature — it verifies your license.

Send a message

A conversation is an array of messages, each with a role and content. The result is the same normalized shape on every provider.

Send a chat
import { ai } from "@/lib/ai";

const res = await ai.chat({
  messages: [{ role: "user", content: "Say hello in one word." }],
});

console.log(res.content);   // "Hello"

You should see a one-word greeting in res.content.

Read usage and finish reason

Every result carries normalized token accounting and a normalized reason the model stopped — the same fields whatever the provider.

console.log(res.usage);         // { promptTokens: 12, completionTokens: 1, totalTokens: 13 }
console.log(res.finishReason);  // "stop"
console.log(res.provider);      // "openai"
console.log(res.model);         // "gpt-4o"

finishReason is one of "stop" | "length" | "tool_calls" | "content_filter" | "error" | "other".

🎉 That's it

You sent a chat completion through a unified API. The exact same code runs on Anthropic, Gemini, or Groq — you'd only change the providers config (and, for Pro providers, add a license key).

const ai = new RadonAI({ providers: { openai: {}, anthropic: {} } });

await ai.chat({ messages, provider: "openai" });
await ai.chat({ messages, provider: "anthropic" }); // same messages, same result shape

Next steps

On this page