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.
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.
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.
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)| model | string | Required | Model 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 → |
| messages | Message[] | Required | OpenAI 标准对话历史。{role, content} 数组,role ∈ system/user/assistant/tool。 |
| stream | boolean | Default: false | 开启 SSE 流式;返回 ChatCompletionChunk 序列,需用 SSE 解析器消费。 |
| temperature | number | Default: 1 | 采样温度,0-2。低 = 确定性 / 代码;高 = 创意。 |
| max_tokens | integer | Optional | 单次响应最大 token。不设则用模型默认。 |
| top_p | number | Default: 1 | 核采样阈值。一般 temperature OR top_p 二选一。 |
| tools | Tool[] | Optional | OpenAI function calling 标准 tools 数组。详见 Function calling 节。 |
| tool_choice | "auto" | "none" | object | Optional | 工具选择策略;指定具体 tool 名可强制调用。 |
| response_format | object | Optional | JSON 模式或 Schema 严格模式: {type: "json_object"} 或 {type: "json_schema", json_schema: {...}}。 |
| models | string[] | Optional | Nexevo 扩展:多模型 fallback 列表。主 model 失败按顺序尝试,大幅提升可用性。 |
| provider | ProviderPreference | Optional | Nexevo 扩展:路由偏好,如 {order: ["groq"], allow_fallbacks: true}。 |
| max_price | MaxPrice | Optional | Nexevo 扩展:成本上限 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.
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.
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.
# 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"],
)| model | string | Required | 模型 id,如 nexevo/image-balanced / dall-e-3 / imagen-4-ultra / flux-pro。完整 22 模型见 GET /generation/models。 |
| prompt | string | Required | 文本描述,最多 4000 字符。 |
| n | integer | Default: 1 | 生成数量,1-10。Imagen 上限 4,DALL-E 3 仅 1。 |
| size | string | Default: 1024x1024 | 尺寸,常见 1024x1024 / 1792x1024 / 1024x1792;Imagen 自动映射到 aspectRatio。 |
| quality | "standard" | "hd" | Optional | 仅 DALL-E 3 / gpt-image-1 用。hd 价格×2,细节更好。 |
| reference_image_b64 | string | Optional | 图生图用,base64 PNG / JPG。OpenAI gpt-image-1 / FLUX 支持;DALL-E 3 不支持。 |
| negative_prompt | string | Optional | 不想要的元素描述。OpenAI 自动忽略,Replicate / Wan 用。 |
| seed | integer | Optional | 确定性种子,同 prompt + seed 出同图(部分 provider)。 |
| model | string | Required | sora-2 / sora-2-pro / veo-3 / veo-3-fast / wan-2.6 / wan-2.6-pro / runway-gen4 / nexevo/video-{fast|balanced|pro}。 |
| prompt | string | Required | 视频文本描述。 |
| duration_sec | number | Default: 5 | 视频时长,1-30 秒。Sora 2 / Veo 3 推荐 5-10。 |
| aspect_ratio | string | Default: "16:9" | 16:9 / 9:16 / 1:1 / 4:3 / 3:4。 |
| reference_image_url | string | Optional | 图生视频参考图(https URL)。Runway Gen-4 强制必传;Wan 2.6 用作首帧。先调 POST /v1/generation/upload 拿 OSS URL。 |
| negative_prompt | string | Optional | Wan / Replicate / Veo 用。 |
| seed | integer | Optional | 确定性种子(部分 provider)。 |
| model | string | Required | hunyuan-3d-2 / hunyuan-3d-2-pro / nexevo/3d-{fast|balanced}。 |
| prompt | string | Optional | 文本描述(prompt 或 reference_image_url 二选一)。 |
| reference_image_url | string | Optional | 图生 3D 参考图(https URL)。 |
| output_format | string | Default: "glb" | glb / obj / usdz / stl / fbx。 |
| file | multipart file | Required | multipart/form-data 字段名 file,PNG / JPG / WebP / GIF,≤ 10 MB。 |
| id | string | Optional | Nexevo 内部 job_id(gen_xxxx)。 |
| status | "pending" | "running" | "succeeded" | "failed" | "canceled" | Optional | 异步任务状态。 |
| progress | number | Optional | 0-100,部分 provider(Replicate / Veo)实时报。 |
| results | GenResult[] | Optional | 完成后含 { url, b64_json, mime_type, duration_ms, ... }。Sora 2 / Veo 3 / Runway 自动镜像到 OSS,URL 24h 有效。 |
| charged_usd | string | Optional | 扣费金额(完成时填入)。 |
| error | object | null | Optional | 失败时含 { code, message, retryable }。 |
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"]))| model | string | Required | 客户面 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。 |
| input | string | string[] | Required | 单段文本或批量(批量上限取决于 provider,通常 100-2048)。 |
| encoding_format | "float" | "base64" | Default: "float" | 返回向量的编码;base64 体积小但需要客户端 decode。 |
| dimensions | integer | Optional | 降维向量维度。仅 text-embedding-3-* / jina-embeddings-v3 支持。 |
| user | string | Optional | tenant 标识,审计与速率限制用。 |
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])| model | string | Required | 客户面 model id:rerank-v3.5(Cohere)/ rerank-multilingual-v3.0 / jina-reranker-v2-base / bge-reranker-v2 / nexevo/rerank-fast / nexevo/rerank-balanced。 |
| query | string | Required | 检索 query / 用户问题。 |
| documents | string[] | object[] | Required | 候选文档列表,通常来自 embedding 检索 top-50。可以是 string 或 {"text": "..."}。 |
| top_n | integer | Optional | 排序后保留前 N 条。不设则全返(已排序)。 |
| return_documents | boolean | Default: true | 返回时是否包含原文。设 false 只返 index + score 节流。 |
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.
# 完整 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)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:"..."}) 即可| task | string | Required | 用户面任务描述。Agent 内部 LLM brain 拿这个当 user message 起循环。 |
| model | string | Default: "nexevo/balanced" | Agent 大脑(chat completion 模型)。可换 claude-opus-4-7 / gpt-5 / nexevo/fast 等。 |
| tools | string[] | Optional | 启用的内置 tool 名;不填 = 全部启用。内置:rag_search / list_models / web_search / generate_image / python_exec / spawn_agent / memory_read / memory_write。 |
| max_steps | integer | Default: 10 | 最多循环几步;防 LLM 死循环。上限 30。 |
| rag_documents | string[] | Optional | rag_search tool 启动时预加载的文档,内部用 BGE-m3 embed + rerank-v3.5 精排。 |
| system_prompt | string | Optional | 覆盖默认 agent 系统提示。 |
| wait | boolean | Default: true | 同步阻塞等结果(true,默认 deadline 120s,可调上限 3600s)/ 异步立返 task_id 后客户走 GET /v1/tasks/{id} poll(false,长任务推荐)。 |
| timeout_sec | integer | Default: 120 | 仅 wait=true 时生效,超时返当前状态(可能仍 running),客户后续 poll。上限 3600s。 |
| enable_verifier | boolean | Default: false | final_answer 出来后跑 cheap-model 多维度评估(factuality / relevance / completeness / safety),overall < threshold → verifier_passed=false。 |
| verifier_threshold | float | Default: 0.7 | verifier overall 分数低于此值标 failed。建议 0.6-0.8。 |
| max_cost_usd | float | Optional | 软告警上限 — 估算累计花费超此值时 emit budget_warning step,**任务继续**;真正硬门 = 账户余额。避免估算误差导致误杀。 |
SSE streaming — live step events
# 流式 — 实时拿每步事件,边跑边看
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']}")/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.
| goal | string | Required | 高层任务目标(替代 task)。Planner 拆 DAG 时从这里读。 |
| deliverables | object[] | Optional | 结构化交付物声明:[{type:"email", target:"x@y.com"}] 或 webhook。 |
| budget_usd | float | Optional | 任务级软告警预算(同 max_cost_usd 语义)。 |
| deadline_sec | integer | Default: 120 | 任务超时;wait=true 时是同步上限,wait=false 时是后台执行上限。≥10、≤3600。 |
| enable_planner | boolean | Default: false | 用便宜 model(nexevo/fast 默认)拆 NL goal → DAG plan,executor 按图并行调度。复杂任务质量提升明显。 |
| planner_model | string | Default: "nexevo/fast" | Planner 用什么模型(便宜模型够,通常无需改)。 |
| planner_n_candidates | integer | Default: 1 | 并行生成 N 个候选 plan + 启发评分选优(节点数 / aggregate 唯一性 / tool_call 存在 / 引用合法)。1 单跑 / 2-5 多样性。 |
| auto_repair_max_rounds | integer | Default: 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 完全托管。 |
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"])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.
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"])| title | string | Optional | 对话标题。可后续 update。 |
| metadata | object | Optional | 任意 JSON,关联你自己的 user_id / session_id / topic 等。最大 4KB。 |
| role | "user" | "assistant" | "system" | "tool" | Required | 消息角色。 |
| content | string | Required | 消息文本。注意:此 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.
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.
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",
)| name | string | Required | Key 显示名(用于在 dashboard 区分)。1-100 字符。 |
| monthly_spend_cap_usd | string | Optional | 月度上限 USD,字符串保留精度(如 "100.00")。超 cap 后该 key 该月所有请求被拒。 |
| clear | boolean | Default: false | true = 清除当前 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.
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"])| amount_usd | number | Required | 充值金额 USD,> 0。 |
| idempotency_key | string | Required | 幂等 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.
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.
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)| generation_id | string | Required | 从 chat 响应头 X-Nexevo-Generation-Id 或 SDK resp.nexevo.generation_id 拿。 |
| rating | 1 | -1 | Required | 1 = 👍, -1 = 👎。 |
| comment | string | Optional | 可选自由文本(最多 ~2K 字符)。 |
| tags | string[] | Optional | 可选标签。常用: accurate / incorrect / too_verbose / irrelevant。 |
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.
{
"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-ID | unique request ID, include it in support tickets |
| X-Usage-Input-Tokens | input tokens counted for billing |
| X-Usage-Output-Tokens | output tokens counted for billing |
| X-RateLimit-Remaining | remaining requests in current window |
| X-RateLimit-Reset | seconds 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
Native SDKs
Official first-party SDKs that wrap smart routing, billing, RLHF feedback and other extensions. 100% OpenAI-protocol compatible.
pip install nexevo-aiGitHub sourcenpm install @nexevo/sdkGitHub sourceMigrate from OpenAI in 2 lines
Keep your OpenAI code as-is — only swap the api_key and add base_url.
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"}],
)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
Get API Key
Register an account to get started, no credit card required.
Register nowBrowse the model library
60+ Model Side-by-side Comparison - Price / Context / Capability Ratings.
See 100+ modelsCookbook example
15 ready-to-use code examples — RAG / streaming / tool calls / batch processing.
View Cookbook