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:
generateTextreturns text, andresult.usagehas token counts.streamTextyields chunks progressively rather than one final blob.- 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 see | What it means | Fix |
|---|---|---|
401 | the key is not reaching the provider | environment variables in Next.js are not automatically available server-side at runtime — check where you read it |
404 | baseURL without /v1 | it must end /v1 |
| Types complain about the provider | the OpenAI-compatible provider is a separate import from the OpenAI one | use 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.