Nexevo.aiNexevo.ai

quick start

Point the base_url of any OpenAI compatible SDK to our gateway and start calling. The first response usually comes back within a few seconds.

from openai import OpenAI

client = OpenAI(
    api_key="sk-xc-your-key-here",
    base_url="https://api.nexevo.ai/v1",
)

resp = client.chat.completions.create(
    model="nexevo/balanced",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)

Authentication

Create an API key on the Keys page and put it in the Authorization header in the form of Bearer token. Every request requires a legitimate key; revoked or expired keys are immediately rejected.

http
GET /v1/billing/balance HTTP/1.1
Host: api.nexevo.ai
Authorization: Bearer sk-xc-abc123...

Single key settings (sub-limit/IP whitelist/model restrictions/expiration) can be configured on the Keys page. Used to issue restricted-scope keys to different applications or environments.

Do not hardcode keys on the front end
API key is equivalent to password and can only be used on the backend server. Front-end/mobile apps should be called through your own middle layer to avoid directly exposing sk-xc-* in the browser/client.

dialogue completions

POST to /v1/chat/completions, using OpenAI standard message format. Use model=nexevo/balanced and we will automatically route to the most appropriate upstream based on your question. Standard parameters such as temperature / max_tokens / top_p / stop are also supported.

python
resp = client.chat.completions.create(
    model="nexevo/balanced",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user",   "content": "Explain quantum entanglement"},
    ],
    temperature=0.7,
    max_tokens=500,
)
print(resp.choices[0].message.content)
Parameters
modelstringRequiredModel ID to call, e.g. gpt-4o / claude-opus-4-7.<br/>Smart-routing aliases: nexevo/fast / nexevo/balanced / nexevo/auto.Browse all 121 models →
messagesMessage[]RequiredOpenAI 标准对话历史。{role, content} 数组,role ∈ system/user/assistant/tool。
streambooleanDefault: false开启 SSE 流式;返回 ChatCompletionChunk 序列,需用 SSE 解析器消费。
temperaturenumberDefault: 1采样温度,0-2。低 = 确定性 / 代码;高 = 创意。
max_tokensintegerOptional单次响应最大 token。不设则用模型默认。
top_pnumberDefault: 1核采样阈值。一般 temperature OR top_p 二选一。
toolsTool[]OptionalOpenAI function calling 标准 tools 数组。详见 Function calling 节。
tool_choice"auto" | "none" | objectOptional工具选择策略;指定具体 tool 名可强制调用。
response_formatobjectOptionalJSON 模式或 Schema 严格模式: {type: "json_object"}{type: "json_schema", json_schema: {...}}
modelsstring[]OptionalNexevo 扩展:多模型 fallback 列表。主 model 失败按顺序尝试,大幅提升可用性。
providerProviderPreferenceOptionalNexevo 扩展:路由偏好,如 {order: ["groq"], allow_fallbacks: true}
max_priceMaxPriceOptionalNexevo 扩展:成本上限 USD,如 {prompt: 0.01, completion: 0.05}。超价直接拒绝。

Streaming response

Assuming stream=true, we will forward the upstream SSE token by token with minimal additional delay. The stream ends with `data: [DONE]`. Tool calls are returned via tool_calls delta - exactly the same as the OpenAI format.

python
stream = client.chat.completions.create(
    model="nexevo/balanced",
    messages=[{"role": "user", "content": "Write a haiku."}],
    stream=True,
)
for chunk in stream:
    delta = chunk.choices[0].delta.content or ""
    print(delta, end="", flush=True)

Function calling

Pass in the `tools` array (JSON Schema description function). If the model decides to call the tool, return `tool_calls`. You execute the function locally, append the result as a tool role message, and call the API again - the same as the OpenAI standard process.

python
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the weather for a city",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]

resp = client.chat.completions.create(
    model="nexevo/balanced",
    messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
    tools=tools,
)
tool_call = resp.choices[0].message.tool_calls[0]
print(tool_call.function.name, tool_call.function.arguments)

Image / Video / 3D generation

Nexevo's generation gateway unifies 22 models across 8 providers — image, video, 3D. Image is sync (returns URL or base64); video / 3D is async via job_id polling (SDK provides generate_and_wait helpers). Sora 2 / Veo 3 / Runway videos are auto-mirrored to OSS for 24h signed URLs. See /cookbook's Generation category for runnable examples.

python
# 1) 文生图(同步)— DALL-E 3 / Imagen 4 / FLUX
img = client.images.generate(
    model="nexevo/image-balanced",       # or "dall-e-3" / "imagen-4-ultra" / "flux-pro"
    prompt="a serene Japanese garden in cyberpunk style",
    n=1, size="1024x1024",
)
print(img["data"][0]["url"])

# 2) 文生视频(异步)— Sora 2 / Veo 3 / Wan 2.6
job = client.videos.generate_and_wait(
    model="sora-2",                          # or "veo-3" / "wan-2.6"
    prompt="a cat skating in neon Tokyo",
    duration_sec=5, aspect_ratio="16:9",
    poll_interval_sec=5, timeout_sec=600,
)
print(job["results"][0]["url"])              # OSS 24h signed URL

# 3) 3D 资产 — Hunyuan 3D 直连
asset = client.models3d.generate_and_wait(
    model="hunyuan-3d-2", prompt="a low-poly viking longboat",
    output_format="glb",
)
print(asset["results"][0]["url"])

# 4) 图生视频 — Runway Gen-4 需先上传参考图
with open("char.png", "rb") as f:
    up = client.generation.uploads.upload(
        f.read(), filename="char.png", content_type="image/png",
    )
job = client.videos.generate_and_wait(
    model="runway-gen4",
    prompt="zoom in slowly while waves crash",
    duration_sec=5,
    reference_image_url=up["url"],
)
POST /v1/images/generations · 同步
modelstringRequired模型 id,如 nexevo/image-balanced / dall-e-3 / imagen-4-ultra / flux-pro。完整 22 模型见 GET /generation/models
promptstringRequired文本描述,最多 4000 字符。
nintegerDefault: 1生成数量,1-10。Imagen 上限 4,DALL-E 3 仅 1。
sizestringDefault: 1024x1024尺寸,常见 1024x1024 / 1792x1024 / 1024x1792;Imagen 自动映射到 aspectRatio。
quality"standard" | "hd"Optional仅 DALL-E 3 / gpt-image-1 用。hd 价格×2,细节更好。
reference_image_b64stringOptional图生图用,base64 PNG / JPG。OpenAI gpt-image-1 / FLUX 支持;DALL-E 3 不支持。
negative_promptstringOptional不想要的元素描述。OpenAI 自动忽略,Replicate / Wan 用。
seedintegerOptional确定性种子,同 prompt + seed 出同图(部分 provider)。
POST /v1/videos/generations · 异步,返 {job_id, status}
modelstringRequiredsora-2 / sora-2-pro / veo-3 / veo-3-fast / wan-2.6 / wan-2.6-pro / runway-gen4 / nexevo/video-{fast|balanced|pro}
promptstringRequired视频文本描述。
duration_secnumberDefault: 5视频时长,1-30 秒。Sora 2 / Veo 3 推荐 5-10。
aspect_ratiostringDefault: "16:9"16:9 / 9:16 / 1:1 / 4:3 / 3:4
reference_image_urlstringOptional图生视频参考图(https URL)。Runway Gen-4 强制必传;Wan 2.6 用作首帧。先调 POST /v1/generation/upload 拿 OSS URL。
negative_promptstringOptionalWan / Replicate / Veo 用。
seedintegerOptional确定性种子(部分 provider)。
POST /v1/3d/generations · 异步
modelstringRequiredhunyuan-3d-2 / hunyuan-3d-2-pro / nexevo/3d-{fast|balanced}
promptstringOptional文本描述(prompt 或 reference_image_url 二选一)。
reference_image_urlstringOptional图生 3D 参考图(https URL)。
output_formatstringDefault: "glb"glb / obj / usdz / stl / fbx
POST /v1/generation/upload · multipart,返 OSS 签名 URL
filemultipart fileRequiredmultipart/form-data 字段名 file,PNG / JPG / WebP / GIF,≤ 10 MB。
GET /v1/generation/jobs/{job_id} · poll(SDK 自动)
idstringOptionalNexevo 内部 job_id(gen_xxxx)。
status"pending" | "running" | "succeeded" | "failed" | "canceled"Optional异步任务状态。
progressnumberOptional0-100,部分 provider(Replicate / Veo)实时报。
resultsGenResult[]Optional完成后含 { url, b64_json, mime_type, duration_ms, ... }。Sora 2 / Veo 3 / Runway 自动镜像到 OSS,URL 24h 有效。
charged_usdstringOptional扣费金额(完成时填入)。
errorobject | nullOptional失败时含 { code, message, retryable }
Tip
Use the SDK's generate_and_wait instead of hand-rolled polling: client.videos.generate_and_wait(model='sora-2', prompt='...', duration_sec=5) — defaults to 5s poll interval, 10 min timeout, raises TimeoutError on miss.

Embeddings · Text vectorization

Compress text into fixed-dimensional vectors (768 / 1024 / 1536 / 3072) for RAG retrieval, semantic search, clustering, and recommendation. OpenAI-compatible schema — point base_url at us and you're done. Billed by input tokens, typically $0.02-$0.13/1M (30-100x cheaper than chat).

# OpenAI 兼容 schema — 把 OpenAI client 的 base_url 改成我们的就能用
resp = client.embeddings.create(
    model="text-embedding-3-large",      # 也可写 voyage-3 / jina-embeddings-v3 / bge-m3
    input="Nexevo.ai 是一个 LLM 网关",         # 或 list[str] 批量
)
vec = resp["data"][0]["embedding"]       # 3072 个浮点数
print(len(vec), resp["usage"]["prompt_tokens"])

# 智能路由 — admin 可后台改路由目标,你的代码不用改
resp = client.embeddings.create(
    model="nexevo/embed-balanced",    # 智能路由 = voyage-3(默认)
    input=["doc 1...", "doc 2...", "doc 3..."],
)
for row in resp["data"]:
    print(row["index"], len(row["embedding"]))
POST /v1/embeddings
modelstringRequired客户面 model id。可填:text-embedding-3-large / text-embedding-3-small / voyage-3-large / voyage-3 / jina-embeddings-v3 / bge-m3 / embed-multilingual-v3.0;或智能路由 nexevo/embed-fast / nexevo/embed-balanced
inputstring | string[]Required单段文本或批量(批量上限取决于 provider,通常 100-2048)。
encoding_format"float" | "base64"Default: "float"返回向量的编码;base64 体积小但需要客户端 decode。
dimensionsintegerOptional降维向量维度。仅 text-embedding-3-* / jina-embeddings-v3 支持。
userstringOptionaltenant 标识,审计与速率限制用。
Which provider should I pick?
Chinese RAG: BGE-m3 (Alibaba, $0.07/M). English RAG: Voyage-3 ($0.06/M). Multilingual general: Jina-v3 ($0.02/M). Cheapest: text-embedding-3-small ($0.02/M). Or use nexevo/embed-balanced for auto-routing.

Rerank · RAG step-2 fine-ranking

Re-rank top-50 candidates from embedding retrieval down to top-5 for the chat call. Embedding is coarse filtering (one-way projection); rerank is fine filtering (looks at query+candidate pair interactions). Critical for RAG accuracy.

# RAG 第二段:把 embedding 召回的 top-50 候选重排,只留 top-5 最相关
ranked = client.rerank.create(
    model="rerank-v3.5",                 # 也可 jina-reranker-v2-base / bge-reranker-v2
    query="如何重置员工 VPN?",
    documents=top50_docs,                # list[str] 或 list[{"text": "..."}]
    top_n=5,
)
for r in ranked["results"]:
    print(r["relevance_score"], r["document"][:60])
POST /v1/rerank
modelstringRequired客户面 model id:rerank-v3.5(Cohere)/ rerank-multilingual-v3.0 / jina-reranker-v2-base / bge-reranker-v2 / nexevo/rerank-fast / nexevo/rerank-balanced
querystringRequired检索 query / 用户问题。
documentsstring[] | object[]Required候选文档列表,通常来自 embedding 检索 top-50。可以是 string 或 {"text": "..."}
top_nintegerOptional排序后保留前 N 条。不设则全返(已排序)。
return_documentsbooleanDefault: true返回时是否包含原文。设 false 只返 index + score 节流。
Which reranker?
Strongest English: Cohere rerank-v3.5 ($0.002/call). Strongest Chinese: BGE-reranker-v2 ($0.0008/call). Best value: Jina-v2 ($0.001/call). Or nexevo/rerank-balanced for auto-routing.

Full RAG pipeline

Stitch embeddings + rerank + chat together: retrieval → fine-ranking → answering. Versus stuffing 10k docs straight into prompt, RAG drops cost from ~$5 to ~$0.06 (100x cheaper) and improves accuracy.

python
# 完整 RAG 三段:embedding 召回 → rerank 精排 → chat 答题
# 总成本 ~$0.06 vs 直接塞 1 万篇文档给 chat ~$5+(差 100x)

from nexevo_ai import Nexevo
client = Nexevo()

# ── 1. 离线索引(只跑一次)──
all_docs = ["...", "...", ...]   # 1 万篇文档
emb_resp = client.embeddings.create(model="bge-m3", input=all_docs)
vectors = [d["embedding"] for d in emb_resp["data"]]
# (省略向量库存取代码 — 用 Pinecone / Milvus / pgvector 都行)

# ── 2. 用户提问时(每次请求触发)──
question = "如何重置员工 VPN?"

# 2a) embed 问题 → 检索 top-50
q_emb = client.embeddings.create(model="bge-m3", input=question)
top50 = vector_db.query(q_emb["data"][0]["embedding"], k=50)

# 2b) rerank top-50 → top-5 最相关
ranked = client.rerank.create(
    model="rerank-v3.5",
    query=question,
    documents=[d.text for d in top50],
    top_n=5,
)["results"]
top5 = [top50[r["index"]] for r in ranked]

# 2c) chat 用 top-5 答题
context = "\n\n".join(d.text for d in top5)
ans = client.chat.completions.create(
    model="nexevo/balanced",
    messages=[
        {"role": "system",
         "content": f"基于以下材料答题(只能用这些材料,不要编):\n\n{context}"},
        {"role": "user", "content": question},
    ],
)
print(ans.choices[0].message.content)
Which vector database?
Small/local: pgvector (free Postgres extension). Mid-scale: Qdrant / Weaviate (self-hosted). Large-scale: Pinecone / Milvus (managed). We don't sell vector databases — pick whatever's cheapest for you.

Agents · Agent-as-a-Service

Hand a high-level task to an agent — it decomposes steps, calls tools, and loops until it answers. Built-in tools: rag_search (our own RAG stack) + list_models (catalog search). Two call modes: sync (wait=true, blocks up to 60s) or async (returns task_id for polling); plus SSE streaming for real-time step events.

from nexevo_ai import Nexevo
client = Nexevo()

# 1) 同步模式(默认 wait=True)— 阻塞等结果,deadline 默认 120s,可调到 3600s
job = client.agents.run(
    task="找一个最便宜的中文 RAG embedding 模型,告诉我维度和单价",
    model="nexevo/balanced",        # chat brain,可换 claude / gpt-5 等
    max_steps=10,
)
print(job["result"])
# Agent 内部会:
#   step 1: chat → tool_call list_models(kind=embedding, modality 多语言)
#   step 2: tool_result 返 BGE-m3 / Jina-v3 等候选
#   step 3: chat 综合 → final_answer "BGE-m3 1024 维,$0.07/1M"

# 2) 给 RAG 任务预加载文档
job = client.agents.run(
    task="基于这些资料答:如何重置员工 VPN?",
    rag_documents=[
        "VPN 服务器列表请联系 IT 支持...",
        "重置 VPN 密码需要登录员工门户...",
        # ... 上千条
    ],
    tools=["rag_search"],
)

# 3) 异步任务(长任务推荐)
submitted = client.agents.run(task="复杂调研任务...", wait=False)
job = client.agents.run_and_wait(submitted["id"], timeout_sec=300)

# 4) Memory tools(2026-04-29 P4 v2)— LLM 主动读写工作记忆 / 长期记忆
#    任务级 memory:节点之间共享中间事实(避免 prompt 拼接爆炸)
#    tenant 级 memory:跨任务的"上次客户做过 X" 让 agent 第二次更聪明
#    工具自动注入,LLM 调用 memory_read({level:"task", key:"..."}) 即可
POST /v1/agents/run · POST /v1/agents/run/stream(SSE)
taskstringRequired用户面任务描述。Agent 内部 LLM brain 拿这个当 user message 起循环。
modelstringDefault: "nexevo/balanced"Agent 大脑(chat completion 模型)。可换 claude-opus-4-7 / gpt-5 / nexevo/fast 等。
toolsstring[]Optional启用的内置 tool 名;不填 = 全部启用。内置:rag_search / list_models / web_search / generate_image / python_exec / spawn_agent / memory_read / memory_write
max_stepsintegerDefault: 10最多循环几步;防 LLM 死循环。上限 30。
rag_documentsstring[]Optionalrag_search tool 启动时预加载的文档,内部用 BGE-m3 embed + rerank-v3.5 精排。
system_promptstringOptional覆盖默认 agent 系统提示。
waitbooleanDefault: true同步阻塞等结果(true,默认 deadline 120s,可调上限 3600s)/ 异步立返 task_id 后客户走 GET /v1/tasks/{id} poll(false,长任务推荐)。
timeout_secintegerDefault: 120wait=true 时生效,超时返当前状态(可能仍 running),客户后续 poll。上限 3600s。
enable_verifierbooleanDefault: falsefinal_answer 出来后跑 cheap-model 多维度评估(factuality / relevance / completeness / safety),overall < threshold → verifier_passed=false
verifier_thresholdfloatDefault: 0.7verifier overall 分数低于此值标 failed。建议 0.6-0.8。
max_cost_usdfloatOptional软告警上限 — 估算累计花费超此值时 emit budget_warning step,**任务继续**;真正硬门 = 账户余额。避免估算误差导致误杀。

SSE streaming — live step events

python
# 流式 — 实时拿每步事件,边跑边看
for ev in client.agents.run_stream(task="..."):
    if ev["type"] == "step":
        s = ev["step"]
        if s["type"] == "tool_call":
            print(f"→ 调用 {s['tool_name']}({s['tool_input']})")
        elif s["type"] == "tool_result":
            print(f"  ← {s['tool_output']}")
        elif s["type"] == "final_answer":
            print(f"\n答:{s['content']}")
    elif ev["type"] == "done":
        print(f"\n总 token: in={ev['job']['total_tokens_in']}, out={ev['job']['total_tokens_out']}")
When should I use agents?
Simple one-shot tasks: just use chat. **Multi-step, tool-using, decomposable tasks** (like 'find X, then do Y'): use agents. Agents aren't cheap — each loop step is a chat call, so a 5-step task costs ~5x a single chat call.

/v1/tasks · Task-as-a-Service + Self-Healing v2

/v1/agents/run is a conversational agent. /v1/tasks is task-as-a-service — adds Planner (auto DAG decomposition), multi-dimension Verifier, Auto-repair reflection loop, and Partial Success markers. Full Plan→Execute→Evaluate→Adjust→Loop architecture, expected success rate +20-25 pp.

POST /v1/tasks(任务即服务,Self-Healing v2)
goalstringRequired高层任务目标(替代 task)。Planner 拆 DAG 时从这里读。
deliverablesobject[]Optional结构化交付物声明:[{type:"email", target:"x@y.com"}] 或 webhook。
budget_usdfloatOptional任务级软告警预算(同 max_cost_usd 语义)。
deadline_secintegerDefault: 120任务超时;wait=true 时是同步上限,wait=false 时是后台执行上限。≥10、≤3600。
enable_plannerbooleanDefault: false用便宜 model(nexevo/fast 默认)拆 NL goal → DAG plan,executor 按图并行调度。复杂任务质量提升明显。
planner_modelstringDefault: "nexevo/fast"Planner 用什么模型(便宜模型够,通常无需改)。
planner_n_candidatesintegerDefault: 1并行生成 N 个候选 plan + 启发评分选优(节点数 / aggregate 唯一性 / tool_call 存在 / 引用合法)。1 单跑 / 2-5 多样性。
auto_repair_max_roundsintegerDefault: 0**Self-Healing**:verifier 失败时 → cheap-LLM 反思根因 → 重新 plan + 局部 re-run(checkpoint 复用成功节点)。0 关 / 1-3 启用。期望成功率 +20-25 pp。
autonomy_level"L1" | "L2" | "L3"Default: "L3"L1 启动前一次性确认 / L2 副作用工具(email / webhook / mcp:slack:*)调用前确认 / L3 完全托管。
python
from nexevo_ai import Nexevo
client = Nexevo()

# Self-Healing v2 — 任务自我修复闭环(Plan → Execute → Evaluate → Adjust)
result = client.tasks.submit(
    goal="调研 2025 Q2 全球生成式视频生成 Top 5 厂商,输出对比表(ARR/客户/技术亮点)",
    enable_planner=True,
    planner_n_candidates=3,         # 并行生成 3 个候选 plan,启发选优
    auto_repair_max_rounds=2,       # verifier 失败 → 反思 + 重 plan 最多 2 轮
    deadline_sec=600,               # 长任务给充裕时间
    wait=True,                       # 阻塞拿结果(或 wait=False 异步 poll)
    deliverables=[{"type": "email", "target": "you@company.com"}],
)

# response 含:plan(实际跑的)+ deliverables + verifier 多维分 + partial 标记
print(result["plan"]["nodes"])                  # 看 agent 怎么拆的
print(result["deliverables"][0]["content"])     # 主答
print(result["deliverables"][0]["metadata"])    # verifier 多维分
if result["partial"]:
    print("部分成功节点:", result["succeeded_node_ids"])
    print("失败节点:",   result["failed_node_ids"])
💾 Memory system (new in 2026-04-29)
Two-tier memory injected automatically: **task-level working memory** (shared facts between nodes, prevents prompt bloat) + **tenant-level long-term memory** (cross-task knowledge). LLM uses built-in memory_read / memory_write tools; scope is backend-bound to api_key — no cross-tenant leakage.

Conversation history

Optional module for backend persistence of chat UI. Each conversation is a container with title/metadata. The append message does not trigger LLM but only persists (used with chat completions). Full CRUD + message append.

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。

Account management

Registration/Login/Password Reset/2FA/Profile Editing/GDPR Self-Service Deactivation. Most endpoints are for web application flows; backend integration is just me() / change-password / 2FA. All protected endpoints use Bearer tokens.

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 management

Dynamically create/revoke API key, and can set monthly consumption limit (monthly_spend_cap_usd), over-threshold alarm webhook (HTTPS only), and geographical routing policy (cn-only / overseas-only / any). create() returns full_key only once, be sure to save it.

full_key is displayed only once
The full_key returned by create() is the sk-xc-... complete string, which Nexevo will never display again (only the hash is stored). Be sure to save to the key manager or .env file immediately when created. If lost, it can only be undone and rebuilt.
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(无限额)。

Bill/Usage/Recharge

Balance, daily usage, by-tier breakdown (by_tier: fast / balanced / passthrough / byok), Stripe top-up. Billing tier is determined by the request's `model` field — `model=nexevo/fast` → fast flat-rate; a real model id → passthrough +5%. Treat all monetary strings as decimal — do not parse them as floats.

Use a string for the amount, do not use parseFloat
All amounts (balance_usd / cost / amount_usd) are returned as strings, retaining the original precision (decimal). Direct parseFloat may lose the mantissa, so use the Decimal/BigNumber library instead for addition and subtraction.
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-序号。

Organization/Multiple Users

Multi-user management of business accounts. Supports three roles: owner/admin/developer, member invitation/removal/transfer ownership. All keys + billing are shared under the organization name, suitable for company team access.

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 Feedback

Get generation_id from chat response header X-Nexevo-Generation-Id, submit thumbs up/down + optional comment + tag. The feedback goes directly to the data flywheel, and the self-learning routing will use it to optimize future model selections.

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
Feedback goes directly to self-learning routing
Submitted thumbs up/down are not just statistics — the self-learning router (bandit + ELO) will use them to adjust future selection models in real time. More feedback = automatic improvement in product quality.

Error handling

Error format alignment OpenAI: A single `error` object contains three fields: `message` / `type` / `code`. Common codes: `invalid_api_key` (401), `insufficient_balance` (402), `rate_limit_exceeded` (429), `tenant_monthly_quota_exceeded` (429), `upstream_error` (502). Upstream 5xx we will retry transparently; you will only see the final error if all retries fail.

json
{
  "error": {
    "message": "Account balance depleted. Please top up to continue.",
    "type": "insufficient_balance",
    "code": "account_suspended"
  }
}

rate limit

Default 60 RPM per key. If the limit is exceeded, 429 is returned, with `X-RateLimit-Remaining` and `X-RateLimit-Reset` headers attached. The enterprise plan can relax the upper limit - contact us for customization.

response header

Each response comes with useful metadata headers:

X-Trace-IDunique request ID, include it in support tickets
X-Usage-Input-Tokensinput tokens counted for billing
X-Usage-Output-Tokensoutput tokens counted for billing
X-RateLimit-Remainingremaining requests in current window
X-RateLimit-Resetseconds until window resets

price

All internal models have a unified flat price: input $3.00 / million tokens, output $12.00 / million tokens. Cache hits (exact + semantic) are charged at 25% of regular price. The cost of retries and hedging paths is absorbed internally by us - you only pay for the answers you end up seeing.

SDK compatibility

Because we expose OpenAI compatible APIs, most existing SDKs are available with zero changes. Just point the base_url to our gateway.

OpenAI-compatible SDKs

OpenAI Python
OpenAI Node.js
LangChain
LlamaIndex
Vercel AI SDK
Curl / HTTP

Native SDKs

Official first-party SDKs that wrap smart routing, billing, RLHF feedback and other extensions. 100% OpenAI-protocol compatible.

Python
nexevo-ai · sync + async + RAG / generation resources
Install
pip install nexevo-aiGitHub source
Node.js / TypeScript
@nexevo/sdk · ESM + CJS dual build, full types
Install
npm install @nexevo/sdkGitHub source

Migrate from OpenAI in 2 lines

Keep your OpenAI code as-is — only swap the api_key and add base_url.

Before
python
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["OPENAI_API_KEY"],
)

resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hi"}],
)
After
python
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NEXEVO_API_KEY"],
    base_url="https://api.nexevo.ai/v1",
)

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

Next step

API documentation · OpenAI compatible /v1/chat/completions | Nexevo.ai