Docs / Connect

Connect → Vercel AI SDK

Use AxForge with the Vercel AI SDK

The Vercel AI SDK (npm ai, Apache-2.0) is the de-facto standard TypeScript toolkit for building with models. Point it at AxForge with its OpenAI-compatible provider and the rest of your app — generateText, streamText, tools, UI hooks — is unchanged.

Install & configure

$ npm i ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const axforge = createOpenAICompatible({
  name: "axforge",
  baseURL: "https://api.axforge.ai/v1",
  apiKey: process.env.AXFORGE_API_KEY,
});

const { text } = await generateText({
  model: axforge("chat"),
  prompt: "Hello from Stockholm",
});

Streaming

import { streamText } from "ai";
const result = streamText({ model: axforge("chat"), prompt: "Count to five" });
for await (const delta of result.textStream) process.stdout.write(delta);

Embeddings

import { embed } from "ai";
const { embedding } = await embed({
  model: axforge.textEmbeddingModel("embeddings"),
  value: "a sentence to embed",
});   // 1024-dim

Prefer the OpenAI-compatible provider. @ai-sdk/openai-compatible always calls Chat Completions — the simplest, most portable path. If you use @ai-sdk/openai instead, its default openai('id') targets the Responses API (/v1/responses) — AxForge serves that too, but for the chat path call openai.chat('id').

Model names

Pass chat / embeddings (stable role names) or an exact version like qwen3.8-27b-nvfp4 — see Models & pricing. Everything runs in the EU with zero retention.

Check that it worked

Two things, and the second is the one that proves it end to end:

  1. generateText returns text, and result.usage has token counts.
  2. streamText yields chunks progressively rather than one final blob.
  3. The call appears in the console at Billing & usage within a minute or two. Nothing else confirms that your key reached our API — a reply alone could be a cache or another provider.

When it does not work

What you seeWhat it meansFix
401the key is not reaching the providerenvironment variables in Next.js are not automatically available server-side at runtime — check where you read it
404baseURL without /v1it must end /v1
Types complain about the providerthe OpenAI-compatible provider is a separate import from the OpenAI oneuse the compatible provider as shown above

Run the self-test first when you are unsure — it says in one click whether the problem is your key, your quota or us, so you know whether the tool is worth debugging at all.

Anything unclear on this page?

Ask on the forum — the answer helps the next person too.

Ask about this page
© 2026 AxForge · EU-hosted AI infrastructure Docs Models For AI axforge.ai Pricing Trust Acceptable use Community guidelines