Model settings for AI SDK

Turn a Models selection into AI SDK 7 call options, with explicit mapping warnings.

The bridge constructs an AI SDK model and maps provider settings. This runnable example prints the mapping without sending a generation request. Check warnings before using the options: an unsupported mapping must stay visible. For generation, pass prepared.model and prepared.callOptions to generateText on your server with your own credentials.

Run it locally

Node.js 22.12 or newer. Download and extract the starter, then run these commands in its folder.

npm install
npm start

Download complete starter ↓ · All source files for agents

index.mjs

import { gateway } from "ai";
import { selectModel } from "@axelrock/models/core";
import { vercelGatewayAdapter } from "@axelrock/models/providers";
import { prepareAiSdkCall } from "@axelrock/models/ai-sdk";

const catalog = await vercelGatewayAdapter.discover({ signal: AbortSignal.timeout(10_000) });
const model = catalog.models.find((entry) => entry.kind === "language");
if (!model) throw new Error("No language models returned. Try again later.");
const selection = selectModel(model, {});
const prepared = prepareAiSdkCall(vercelGatewayAdapter, selection, gateway);
console.log(
  JSON.stringify(
    {
      model: selection.model.id,
      callOptions: prepared.callOptions,
      warnings: prepared.warnings,
    },
    null,
    2,
  ),
);

// Your server can pass prepared.model and prepared.callOptions to generateText.
// Check warnings first. This example does not call a model or need a gateway key.

Make it yours

Resolve the incoming model ID against your server catalog and validate its options. Do not trust model objects sent by the browser.

Try the Models playground →