跳转到内容
EN

从 Anthropic 迁移

已经在用 Anthropic Managed Agents 的代码,把地址换成 /anthropic/v1、把模型换成 Praxis 模型目录里的模型,就能运行。本页列出这个兼容接口接受什么、拒绝什么、和 Anthropic 有哪些不同。新项目直接用原生接口,它多出绑定、环境、版本等能力。

地址与请求头

项目要求
地址https://api.deepraxis.com/anthropic/v1/agents,会话、环境、技能同理。官方 SDK 的 base_url 填 https://api.deepraxis.com/anthropic
鉴权x-api-key: <Key> 或 Authorization: Bearer <Key>,同一个 API Key 通用,见鉴权
anthropic-version必填,任意 YYYY-MM-DD 日期,不早于 2023-06-01。官方 SDK 默认发送的新日期(如 2026-10-21)同样可用;缺失、早于该日期或写成 latest 返回 400
anthropic-beta不需要。官方 SDK 会带上 managed-agents-2026-04-01,不带也能调用所有端点

被拒绝的原生字段

原生接口 /agent/v1 的扩展字段在兼容接口上一律返回 400 Unknown field: <名字>,不会被忽略:

kind、bindings、environment_id、vault_ids、avatar、apply、version_note、subagent_model。

这是有意的:兼容接口的请求体和 Anthropic 完全同形,多余的字段说明代码写错了接口。需要这些能力时改用原生接口;两个接口读写的是同一批智能体,可以混用,但在原生接口留下未生效草稿的智能体,通过兼容接口更新会返回 409,先在原生接口处理草稿(见管理智能体版本)。

和 Anthropic 的差异

方面差异
模型model 只接受 Praxis 模型目录里的 ID,例如 deepseek-flash。claude-… 之类不在目录里的 ID 返回 400 model … is not in the model catalog。model.settings.reasoning 可设思考档位,其他额外模型控制(例如 speed)返回 400
技能skills 可用,但只支持 { "type": "custom", "skill_id" },先到技能上传。type: "anthropic"(Anthropic 预置技能)返回 400;skill_id 必须是你组织里存在的技能
工具只接受和返回 Anthropic 官方的 8 个内置工具。codemode 不能在这个接口开关(返回 400 Unknown tool),但已有的 codemode 配置在通过此接口读写时会被保留
权限每个工具的 permission_policy(always_allow / always_ask)可用;工具集上的 permissions 允许/询问/拒绝规则不被接受(400 Unsupported field),也不会被读出来,要用时走原生接口
MCPmcp_servers[].headers 的值只写不读:响应里一律是 "[redacted]"。把读到的对象原样写回,会保留原来的值;要换值就传新值。会话运行时用的是真实值
环境可以创建、读取、更新和归档;DELETE 返回 501,提示改用归档。不支持 self_hosted 和 scope;内置环境只读,细节见运行环境

迁移示例

同样的调用,只换地址和模型。保存为 migrate.mjs,设置 PRAXIS_API_KEY 后执行 node migrate.mjs。

import assert from "node:assert/strict";
import { setTimeout as delay } from "node:timers/promises";
const { PRAXIS_API_KEY } = process.env;
assert(PRAXIS_API_KEY, "Set PRAXIS_API_KEY in the server process");
const base = "https://api.deepraxis.com/anthropic/v1";
async function request(path, body) {
const response = await fetch(`${base}${path}`, {
method: body === undefined ? "GET" : "POST",
headers: {
"x-api-key": PRAXIS_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
...(body === undefined ? {} : { body: JSON.stringify(body) }),
signal: AbortSignal.timeout(30_000),
});
const result = await response.json();
if (!response.ok) {
throw new Error(`HTTP ${response.status}; request=${response.headers.get("X-Request-Id")}; ${result.error?.message ?? ""}`);
}
return result;
}
// The same calls you send to Anthropic Managed Agents; only the host and the model id change.
const agent = await request("/agents", {
name: "Migrated agent",
model: "deepseek-flash",
system: "Answer in one short sentence.",
tools: [{ type: "agent_toolset_20260401" }],
});
const session = await request("/sessions", { agent: agent.id });
await request(`/sessions/${session.id}/events`, {
events: [{ type: "user.message", content: [{ type: "text", text: "What is 2 + 2?" }] }],
});
const deadline = Date.now() + 120_000;
let reply = "";
while (Date.now() < deadline && !reply) {
const { data } = await request(`/sessions/${session.id}/events?order=asc&limit=100`);
const last = data.findLastIndex((event) => event.type === "agent.message");
if (last >= 0 && data.slice(last).some((event) => event.type === "session.status_idle")) {
reply = data.filter((event) => event.type === "agent.message")
.flatMap((event) => event.content ?? []).map((block) => block.text ?? "").join("\n");
} else await delay(1500);
}
assert(reply.includes("4"), `Expected 4 in the reply, got: ${reply}`);
console.log({ agent: agent.id, session: session.id, reply });

预期结果: 输出智能体 ID、会话 ID,回复里包含 4。

失败时检查

现象处理
400 anthropic-version must be a YYYY-MM-DD date on or after 2023-06-01加上 anthropic-version: 2023-06-01,或使用官方 SDK 的默认值
400 Unknown field: <名字>这是原生字段,删掉,或改用原生接口
400 model … is not in the model catalog换成 Praxis 模型目录里的模型 ID
400 skills[0].type anthropic is not supported上传技能后以 custom 挂载
409 This agent has an unapplied version …在原生接口生效或覆盖那个草稿后再更新

完整字段见 Claude 托管智能体 API 参考。下一步:使用技能 · 运行第一个智能体