Anthropic SDK
Connect Praxis to the Anthropic SDK: swap the baseURL, keep your Claude code.
Connect Praxis through the official Anthropic SDK—keep every line of your existing Anthropic code, change one baseURL. This page is verified against both Node and Python (other languages share the shape).
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 Anthropic SDK and get replies plus usage
- Done when:
hello.mjsprints a reply withusage, andstream.mjsprints token by token - Time needed: 3 minutes (excluding the Node.js install)
- Protocol: Anthropic-compatible (
/anthropic)
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. 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—note the package name is
@anthropic-ai/sdk(the bareanthropicon npm is an unrelated placeholder):npm install @anthropic-ai/sdkExpected: the install succeeds.
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 Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.deepraxis.com/anthropic",
apiKey: "sk-praxis-your-key",
});
const message = await client.messages.create({
model: "deepseek-flash",
max_tokens: 256,
messages: [{ role: "user", content: "Introduce yourself in one sentence" }],
});
console.log(message.content.find((b) => b.type === "text")?.text);
console.log(message.usage);Run it:
node hello.mjsExpected: a reply prints, followed by usage—at least input_tokens / output_tokens; the SDK adds caching and service-tier fields on top. Two notes: max_tokens is required (an Anthropic-protocol rule); content is an array of blocks—the one with type text is the reply, possibly after a thinking block on reasoning models.

Python version
pip install anthropicCreate hello.py:
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.deepraxis.com/anthropic",
api_key=os.environ["PRAXIS_API_KEY"],
)
message = client.messages.create(
model="deepseek-flash",
max_tokens=256,
messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(next(b.text for b in message.content if b.type == "text"))
print(message.usage)Run python3 hello.py. Expected: a reply prints, followed by Usage—max_tokens is likewise required, and content is an array of blocks. Streaming uses the client.messages.stream(...) context manager, mirroring Node.

Streaming
Create stream.mjs:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.deepraxis.com/anthropic",
apiKey: process.env.PRAXIS_API_KEY,
});
const stream = client.messages.stream({
model: "deepseek-flash",
max_tokens: 256,
messages: [{ role: "user", content: "Explain what an API is in two sentences" }],
});
for await (const event of stream) {
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
process.stdout.write(event.delta.text);
}
}
console.log();Expected: the reply prints token by token, ending with a newline. Streaming support varies per model route; a route that isn't enabled yet reports STREAMING_UNPROVEN—drop streaming or switch models and retry.

FAQ
| Symptom | Cause | Fix |
|---|---|---|
Importing a package named anthropic fails at runtime (error pointing at a missing node_modules/anthropic/index.js or an invalid main) | You installed the unrelated npm placeholder of that name | Remove it and install the real one: uninstall anthropic, then install @anthropic-ai/sdk |
| 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 |
400 complaining about a missing max_tokens | The Anthropic protocol requires it | Add max_tokens (e.g. 256) to the messages.create call |
400 STREAMING_UNPROVEN | That model route isn't streaming-enabled yet | Drop streaming for a plain call, or retry with another model |
| "Model not found" | Model ID doesn't match the catalog | Copy the exact ID from Console → Models |
Advanced
- What did that call cost? The Anthropic-protocol
usagecarries no price; see Console → Usage & Billing for per-call details, or use the OpenAI SDK—that path returns the cost directly inusage.cost - Switch models: change the
modelfield; fillclaude-opus-5for the Claude flagship, anddeepseek-flashalways points at the latest Flash generation - Read the chain of thought: on reasoning models, the
contentblocks withtypethinkingare the reasoning—read them if you need them
Related recipes
- OpenAI SDK (the OpenAI-protocol sibling) · LangChain · Vercel AI SDK
- Rather not write code? See Cherry Studio · Claude Code