Vercel AI SDK
Connect Praxis to the Vercel AI SDK: swap the baseURL in createOpenAI and generateText away.
Connect Praxis to the Vercel AI SDK—the de-facto standard library for AI apps in React/Vue/Svelte. A custom provider takes two parameters, and generateText / streamText plus the whole toolkit work as usual. This page is verified against Node.
Every step lists its expected result: follow along yourself, or hand this page to an AI assistant that can operate your computer and let it do the install, run, and verification for you.
What you'll accomplish
- Call Praxis models with the AI SDK's
generateText/streamText - Done when:
hello.mjsprints a reply withusage, andstream.mjsprints token by token - Time needed: 3–5 minutes (excluding the Node.js install)
- Protocol: OpenAI-compatible (
/openai/v1)
Prerequisites
Confirm each item before you start:
-
A Praxis API key (starting with
sk-praxis-). If you don't have one, create it at Console → API Keys: click "Create Key"—the name is required, validity defaults to 90 days (or pick permanent); the success dialog shows the full key with a "Copy Key" button, and after it closes the list shows only a masked value—re-copy the full key any time from the copy icon on its row. Expected: a "Create API Key" dialog appears, and after submitting, a dialog shows the full key with a "Copy Key" button. New accounts ship with $1 of free credit. See Quickstart for the full flow. -
Node.js 18 or newer (check
node --version; Bun works too). -
Install the SDK:
npm install ai @ai-sdk/openaiExpected: the install succeeds. An empty directory works—no
npm initneeded first.
First request
Put the key in an environment variable first (export PRAXIS_API_KEY=sk-praxis-…; PowerShell: $env:PRAXIS_API_KEY="…"), then create hello.mjs:
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";
const praxis = createOpenAI({
baseURL: "https://api.deepraxis.com/openai/v1",
apiKey: process.env.PRAXIS_API_KEY,
});
const { text, usage } = await generateText({
model: praxis("deepseek-flash"),
prompt: "Introduce yourself in one sentence",
});
console.log(text);
console.log(usage);Run it:
node hello.mjsExpected: a reply prints, followed by the usage object—camelCase, with inputTokens / outputTokens / totalTokens and a raw block; a reasoning model's reasoningTokens sits inside outputTokenDetails.

Streaming
Create stream.mjs:
import { createOpenAI } from "@ai-sdk/openai";
import { streamText } from "ai";
const praxis = createOpenAI({
baseURL: "https://api.deepraxis.com/openai/v1",
apiKey: process.env.PRAXIS_API_KEY,
});
const stream = streamText({
model: praxis("deepseek-flash"),
prompt: "Explain what an API is in two sentences",
});
for await (const chunk of stream.textStream) {
process.stdout.write(chunk);
}
console.log();Expected: the reply prints token by token, ending with a newline. Streaming support varies by model and its upstream channel; some aren't enabled yet reports STREAMING_UNPROVEN—drop streaming or switch models and retry.

FAQ
| Symptom | Cause | Fix |
|---|---|---|
| 401 / invalid token | Key copied incompletely or missing from the environment | Copy it again in full (mind the sk-praxis- prefix); check with echo $env:PRAXIS_API_KEY |
| 404 / path not found | baseURL is missing the /openai/v1 suffix | It must be https://api.deepraxis.com/openai/v1 (ending with /v1) |
400 STREAMING_UNPROVEN | That model route isn't streaming-enabled yet | Use generateText instead, or retry with another model |
| "Model not found" | Model ID doesn't match the catalog | Copy the exact ID from Console → Models → Model Catalog |
Advanced
- Chat components: the AI SDK's
useChatReact hooks pair naturally with server-sidestreamText(see the AI SDK docs); the provider setup is identical to this page - What did that call cost? The AI SDK's
usagecarries no price; the OpenAI SDK path returns it directly inusage.cost, or see Console → Usage & Billing - Switch models: change the model ID inside
praxis("…");deepseek-flashalways points at the latest Flash generation
Related recipes
- OpenAI SDK · Anthropic SDK · LangChain
- Rather not write code? See Cherry Studio · Codex