快速开始
SequenxAI 公开 API 的地址是 https://api.sequenxai.com/v1,目前开放两个端点:
| 端点 | 作用 | 计费 |
|---|---|---|
POST /v1/forecast | 按生效的清洗策略清洗历史序列,再调用预测模型,返回点预测、区间与清洗报告。 | 按实际喂给模型的观测点 + 预测点计费 |
POST /v1/clean | 清洗预演(Beta):只跑同一套清洗,返回清洗报告与生效策略,不调用模型。 | 免费,单独限流 |
OpenAPI 中的其余路径(/anomaly-detection、/batch/*)与 /cn/v1 区域前缀尚未开放,请求会得到 404;前两者在 OpenAPI 参考中标为「暂未开放」(x-availability: planned),只是规划中的设计形状。
1. 创建 API 密钥
- 登录 SequenxAI 平台:platform.sequenxai.com。
- 在「API 密钥」页点击「创建密钥」,填写名称(1–64 个字符)。工作区的所有者、管理员和成员都可以创建,只读成员不能创建。
- 完整密钥形如
sqx_live_…,只显示这一次。复制或下载.env文件后再关闭对话框;丢失后只能删除并重新创建。
2. 发起第一次预测
下面的示例都使用环境变量 SEQUENX_API_KEY。curl 示例使用文档站提供的样例数据 power-grid-15m.json(96 个 15 分钟点,h 为 24);Python 与 JavaScript 示例在本地生成 48 个小时点。
export SEQUENX_API_KEY="sqx_live_..." # created at https://platform.sequenxai.com
# 96 points at 15-minute steps, h=24, level=[80, 90], model hora-1.0
curl -sSO https://docs.sequenxai.com/data/power-grid-15m.json
curl -sS -X POST "https://api.sequenxai.com/v1/forecast" \
-H "Authorization: Bearer $SEQUENX_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Request-Id: quickstart-0001" \
-d @power-grid-15m.jsonimport math
import os
import requests
API_URL = "https://api.sequenxai.com/v1/forecast"
API_KEY = os.environ["SEQUENX_API_KEY"]
# 48 hourly observations of one meter.
series = [
{
"unique_id": "meter-001",
"ds": f"2026-09-{1 + i // 24:02d}T{i % 24:02d}:00:00Z",
"y": round(140 + 8 * math.sin(2 * math.pi * i / 24), 1),
}
for i in range(48)
]
resp = requests.post(
API_URL,
headers={"Authorization": f"Bearer {API_KEY}"},
json={"model": "hora-1.0", "series": series, "h": 24, "freq": "1h", "level": [80, 90]},
timeout=180,
)
body = resp.json()
if resp.status_code != 200:
error = body["error"]
raise SystemExit(f"{resp.status_code} {error['code']}: {error['message']} ({error['request_id']})")
print(body["request_id"], body["effective_policy"]["id"], body["usage"])
for row in body["forecast"][:3]:
print(row["ds"], row["y_hat"], row["intervals"]["80"])// Node.js 18+ (global fetch). Call from your server; never ship the key to a browser.
const API_URL = "https://api.sequenxai.com/v1/forecast";
// 48 hourly observations of one meter.
const series = Array.from({ length: 48 }, (_, i) => ({
unique_id: "meter-001",
ds: new Date(Date.UTC(2026, 8, 1, i)).toISOString().replace(".000Z", "Z"),
y: Math.round((140 + 8 * Math.sin((2 * Math.PI * i) / 24)) * 10) / 10,
}));
const resp = await fetch(API_URL, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SEQUENX_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ model: "hora-1.0", series, h: 24, freq: "1h", level: [80, 90] }),
signal: AbortSignal.timeout(180_000),
});
const body = await resp.json();
if (!resp.ok) {
const { code, message, request_id } = body.error;
throw new Error(`${resp.status} ${code}: ${message} (${request_id})`);
}
console.log(body.request_id, body.effective_policy.id, body.usage);
for (const row of body.forecast.slice(0, 3)) {
console.log(row.ds, row.y_hat, row.intervals["80"]);
}3. 读懂响应
成功响应为 HTTP 200。下例中数值仅为示意,cleaning_report 已折叠:
{
"request_id": "req_4f1c8e2a9b7d4e0c8a3f5b6d7e8f9a0b",
"model_used": "hora-1.0",
"freq": "1h",
"forecast": [
{
"unique_id": "meter-001",
"ds": "2026-09-03T00:00:00Z",
"y_hat": 140.6,
"intervals": {
"80": {"lo": 137.9, "hi": 143.2},
"90": {"lo": 136.4, "hi": 144.8}
}
}
],
"data_quality": {
"status": "ok",
"inferred_freq": null,
"missing_ratio": 0.0,
"imputed_points": 0,
"outlier_points_suppressed": 0,
"timezone_normalized": true,
"notes": []
},
"usage": {
"series_count": 1,
"input_data_points": 48,
"forecast_data_points": 24,
"latency_ms": 812
},
"effective_policy": {
"id": "default@2026-13",
"preset": "default",
"version": "2026-13",
"source": "platform"
},
"model_input": [
{
"unique_id": "meter-001",
"context_points": 48,
"fed_points": 48,
"truncated": 0,
"missing_mode": "filled",
"covariates_used": false
}
],
"quantile_report": {
"policy": "nearest",
"requested": [0.05, 0.1, 0.5, 0.9, 0.95],
"used": [0.05, 0.1, 0.5, 0.9, 0.95],
"substitutions": []
},
"cleaning_report": {
"schema_version": "cleaning_report/1",
"policy": {"id": "default@2026-13", "...": "..."},
"overall": {"series_count": 1, "input_points": 48, "output_points": 48, "...": "..."},
"series": ["..."],
"warnings": [],
"blocking": [],
"decisions": []
}
}| 字段 | 看什么 |
|---|---|
forecast[] | 每个实体 h 行,ds 为 UTC(Z);只有请求了 level 才有 intervals。 |
usage | input_data_points + forecast_data_points 就是本次计费点数。 |
effective_policy | 实际生效的清洗预设及其来源(请求 / 密钥 / 组织 / 平台默认)。 |
cleaning_report | cleaning_report/1 结构化报告,decisions[] 列出每一个改动数据的决定。 |
model_input[] | 每个实体真正喂给模型的点数。历史不会被截断:实体长于模型上下文时返回 SERIES_TOO_LONG。 |
request_id | 与响应头 X-Request-Id 相同;联系支持时请提供它。 |
完整字段见 POST /v1/forecast。
4. 先预演清洗(可选)
不确定数据会被怎样处理时,先用免费的 /v1/clean 看清洗报告。它不调用模型、不计费、不占每日点数额度,但每个账号每分钟最多 60 次(账号下所有密钥共用),单次最多 200,000 点。
# 12 hourly slots; 06:00 is missing. Free dry run: no model call, no points billed.
curl -sS -X POST "https://api.sequenxai.com/v1/clean" \
-H "Authorization: Bearer $SEQUENX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"freq": "1h",
"series": [
{"unique_id": "meter-001", "ds": "2026-09-01T00:00:00Z", "y": 142.5},
{"unique_id": "meter-001", "ds": "2026-09-01T01:00:00Z", "y": 141.8},
{"unique_id": "meter-001", "ds": "2026-09-01T02:00:00Z", "y": 140.9},
{"unique_id": "meter-001", "ds": "2026-09-01T03:00:00Z", "y": 139.7},
{"unique_id": "meter-001", "ds": "2026-09-01T04:00:00Z", "y": 139.2},
{"unique_id": "meter-001", "ds": "2026-09-01T05:00:00Z", "y": 138.8},
{"unique_id": "meter-001", "ds": "2026-09-01T07:00:00Z", "y": 138.2},
{"unique_id": "meter-001", "ds": "2026-09-01T08:00:00Z", "y": 139.0},
{"unique_id": "meter-001", "ds": "2026-09-01T09:00:00Z", "y": 140.4},
{"unique_id": "meter-001", "ds": "2026-09-01T10:00:00Z", "y": 141.3},
{"unique_id": "meter-001", "ds": "2026-09-01T11:00:00Z", "y": 142.0}
]
}'这份数据缺了 06:00 一个时间戳,报告会给出两条决定:grid.regrid(补上空槽位)与 gap.impute(线性插值填值)。每条决定的含义与处理方式见清洗策略与清洗报告。