1. 登录获取 Token
入门几乎所有需要鉴权的 API 都需要 Bearer Token。先用手机号 + SMS 验证码登录拿到。
bash
# 1. 发送验证码
curl -X POST https://api.novalinktech.ai/api/auth/sms-code \
-H 'Content-Type: application/json' \
-d '{"phone": "13800138000"}'
# 2. 用验证码换 token
curl -X POST https://api.novalinktech.ai/api/auth/login \
-H 'Content-Type: application/json' \
-d '{"phone": "13800138000", "code": "1234"}'
# 返回:
# { "access_token": "eyJhbGc...", "token_type": "bearer" }
2. 一键创建并发布原生 Agent
入门用 prompt + 工具配置创建一个付费 Agent。creator 自动设为当前用户。
bash
curl -X POST https://api.novalinktech.ai/api/custom-agents \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{
"name": "智能税务管家",
"short_desc": "帮中小企业老板做税务规划",
"instructions": "你是一个资深税务顾问。当用户描述他们的业务情况时,你需要:\n1. 询问营收规模和企业类型\n2. 分析适用的税收优惠\n3. 给出具体的节税建议",
"icon_emoji": "💼",
"category": "商业咨询",
"tool_names": ["deep_search", "calculator"],
"agent_type": "native",
"publish": true,
"pricing_type": "per_chat",
"price_cents": 1000,
"free_trial_count": 3,
"tags": ["税务", "财务", "中小企业"]
}'
3. 创建一个远端 Agent (BYOA)
进阶把你自己的 OpenAI 兼容服务接入。AI 跑在你的服务器,平台只做 routing。
bash
curl -X POST https://api.novalinktech.ai/api/custom-agents \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{
"name": "我的 RAG Bot",
"short_desc": "基于公司内部文档的智能问答",
"icon_emoji": "🤖",
"agent_type": "remote",
"remote_endpoint": "https://your-server.com/v1/chat/completions",
"remote_api_key": "sk-your-secret",
"remote_model": "rag-v1",
"publish": true,
"pricing_type": "per_chat",
"price_cents": 500
}'
4. 远端 Agent 健康检查
进阶在保存 Agent 之前测试 endpoint 是否可用。30 秒超时,返回示例响应。
bash
curl -X POST https://api.novalinktech.ai/api/custom-agents/test-remote \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{
"endpoint": "https://your-server.com/v1/chat/completions",
"api_key": "sk-your-secret",
"model": "your-model"
}'
# 返回示例:
# { "ok": true, "sample_response": "ok", "elapsed_ms": 423,
# "input_tokens": 12, "output_tokens": 1 }
5. 查询已发布 Agent(无需登录)
入门公开接口,任何人都可以拿到已发布 Agent 的元数据。用于嵌入到自己的网站。
bash
# 任何人(无需登录)可以查询已发布 Agent 的元数据
curl https://api.novalinktech.ai/api/a/strategy
# 返回:
# {
# "id": 1, "slug": "strategy", "name": "策略规划",
# "short_desc": "...", "pricing_type": "free",
# "creator_name": "NovaLink", "chat_count": 1234, ...
# }
6. Plan → Agent 自动转化
进阶从一份策略规划报告自动生成 Agent 草稿(含 prompt、定价、工具)。Demo 模式下用 LLM 提取。
bash
# Plan→Agent: 从一份策略报告自动生成 Agent 草稿
curl -X POST https://api.novalinktech.ai/api/agents/from-plan \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-d '{"report_id": 123}'
# 返回新生成的 draft agent (is_published=False)
# 用户可以审阅后通过 PUT /api/custom-agents/{id} 发布
7. 创作者后台数据
入门查询当前用户发布的所有 Agent 的统计数据 + 收入。
bash
curl https://api.novalinktech.ai/api/creator/dashboard \
-H 'Authorization: Bearer YOUR_TOKEN'
# 返回:
# {
# "agents": [...],
# "total_chats": 156,
# "total_users": 42,
# "total_paid_users": 8,
# "total_gross_revenue_cents": 8000,
# "total_creator_earnings_cents": 5600,
# "revenue_share": 0.7
# }