Nexevo.aiNexevo.ai

资源管理

对话历史

可选模块,用于 chat UI 的后端持久化。每个 conversation 是一个有标题/元数据的容器,append message 不触发 LLM 仅做持久化(配合 chat completions 使用)。完整 CRUD + 消息追加。

python
conv = client.conversations.create(title="My Session")
client.conversations.append_message(
    conv["conversation_id"], role="user", content="Hello!",
)
all_convs = client.conversations.list(limit=20)
detail = client.conversations.get(conv["conversation_id"])
POST /conversations
titlestringOptional对话标题。可后续 update。
metadataobjectOptional任意 JSON,关联你自己的 user_id / session_id / topic 等。最大 4KB。
POST /conversations/{id}/messages
role"user" | "assistant" | "system" | "tool"Required消息角色。
contentstringRequired消息文本。注意:此 endpoint 只持久化,不触发 LLM。

账号管理

注册/登录/密码重置/2FA/资料编辑/GDPR 自助停用。多数 endpoint 面向 web 应用流程;后端集成只需 me() / change-password / 2FA。所有受保护 endpoint 走 Bearer token。

python
me = client.auth.me()
client.auth.update_profile(full_name="Jane Doe")
client.auth.change_password(
    current_password="old-pwd",
    new_password="new-pwd-123",
)
status = client.auth.two_fa_status()

API Key 管理

动态创建/吊销 API key,可设置月度消费上限(monthly_spend_cap_usd)、超阈值告警 webhook(HTTPS only)、地理路由策略(cn-only / overseas-only / any)。create() 返回 full_key 仅一次,务必保存。

full_key 只显示一次
create() 返回的 full_key 是 sk-xc-... 完整字符串,Nexevo 永不再次显示(只存哈希)。务必在创建时立即保存到密钥管理器或 .env 文件,丢失只能撤销并重建。
python
new = client.keys.create(name="prod-2026")
print(new["full_key"])  # 只此一次显示

client.keys.update_spend_cap(
    new["key"]["key_id"],
    monthly_spend_cap_usd="100",
)

client.keys.update_alert_webhook(
    new["key"]["key_id"],
    url="https://your-app.com/billing-alert",
)
POST /keys
namestringRequiredKey 显示名(用于在 dashboard 区分)。1-100 字符。
PATCH /keys/{id}/spend-cap
monthly_spend_cap_usdstringOptional月度上限 USD,字符串保留精度(如 "100.00")。超 cap 后该 key 该月所有请求被拒。
clearbooleanDefault: falsetrue = 清除当前 cap(无限额)。

账单 / 用量 / 充值

查询余额、按天用量、计费档拆分(by_tier:fast / balanced / passthrough / byok)、Stripe 充值。计费档由请求时的 model 决定 — 写 model=nexevo/fast 走 fast 扁平价,写真实模型名走 passthrough +5%。所有金额字符串保留原始精度,不要用 float 解析。

金额用字符串,别 parseFloat
所有金额(balance_usd / cost / amount_usd)都以字符串返回,保留原始精度(decimal)。直接 parseFloat 可能损失尾数,做加减改用 Decimal/BigNumber 库。
python
bal   = client.billing.balance()
usage = client.billing.usage(days=7)
plan  = client.billing.get_plan()

hint = client.billing.upgrade_hint()
if hint["hint"]:
    print(f"建议: {hint['hint']['recommend_plan']}, "
          f"可省 {hint['hint']['savings_pct']}%")

session = client.billing.checkout(
    amount_usd=20,
    idempotency_key="topup-2026-04-27-001",
)
print(session["checkout_url"])
POST /billing/topup · POST /billing/checkout
amount_usdnumberRequired充值金额 USD,> 0。
idempotency_keystringRequired幂等 key,同 key 重试不会重复扣款。建议格式:topup-YYYY-MM-DD-序号。

组织 / 多用户

企业账户的多用户管理。支持 owner / admin / developer 三种角色,成员邀请/移除/转让所有权。所有 key + billing 在组织名下共享,适合公司团队接入。

python
org = client.organizations.create("Acme Inc")

client.organizations.invite_member(
    org["organization"]["org_id"],
    email="dev@acme.com",
    role="developer",
)

members = client.organizations.list_members(org["organization"]["org_id"])

client.organizations.transfer_owner(
    org["organization"]["org_id"],
    new_owner_user_id="u_789",
)

RLHF 反馈

从 chat 响应头 X-Nexevo-Generation-Id 拿 generation_id,提交 thumbs up/down + 可选评论 + tag。反馈直接进数据飞轮,自学习路由会用它优化未来选模型。

python
resp = client.chat.completions.create(
    model="nexevo/balanced",
    messages=[{"role": "user", "content": "Hello!"}],
)
gen_id = resp["nexevo"]["generation_id"]

client.feedback.submit(
    generation_id=gen_id,
    rating=1,
    comment="Helpful!",
    tags=["accurate"],
)

summary = client.feedback.summary(days=7)
POST /feedback
generation_idstringRequired从 chat 响应头 X-Nexevo-Generation-Id 或 SDK resp.nexevo.generation_id 拿。
rating1 | -1Required1 = 👍, -1 = 👎。
commentstringOptional可选自由文本(最多 ~2K 字符)。
tagsstring[]Optional可选标签。常用: accurate / incorrect / too_verbose / irrelevant
反馈直接进自学习路由
提交的 thumbs up/down 不只是统计 — 自学习 router(bandit + ELO)会用它实时调整未来选模型。多接反馈 = 产品质量自动改善。

下一步

资源管理 — Nexevo Docs | Nexevo.ai