跳转到内容

快速开始

登录控制台,创建 API Key 并充值。新账号初始积分为 0,充值前无法提交 query。完整 Key 只显示 1 次。

export GEOEVAL_API_KEY="geo_live_..."
curl https://geo-api.geoeval.com/v1/me -H "Authorization: Bearer $GEOEVAL_API_KEY"
# uuidgen 生成一个 UUID。重试同一次提交时沿用这个值,只扣一次费
IDEMPOTENCY_KEY=$(uuidgen)
curl -X POST https://geo-api.geoeval.com/v1/queries \
-H "Authorization: Bearer $GEOEVAL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-d '{"query":"Which robot vacuum is the best choice?","apps":["doubao"]}'

接口返回 202 和 query_id,任务在后台执行。

curl https://geo-api.geoeval.com/v1/queries/$QUERY_ID -H "Authorization: Bearer $GEOEVAL_API_KEY"

status 仍为 pending 时请稍后再查。单个任务通常耗时约 1 分钟,空闲一段时间后的第 1 个任务可能需要几分钟。任务变为 done 后,回答位于 tasks[].result.answer_markdown。

submit-and-wait.ts
// Node 24+ 可直接运行此文件。提交 query,等待结束并打印回答。
export {};
const API = "https://geo-api.geoeval.com";
const headers = { Authorization: `Bearer ${process.env.GEOEVAL_API_KEY}` };
interface Task {
app: string;
status: "queued" | "running" | "uploaded" | "parsing" | "done" | "failed" | "unavailable";
error: string | null;
result: { answer_markdown: string } | null;
}
interface Query {
query_id: string;
status: "pending" | "completed" | "timeout" | "failed";
tasks: Task[];
}
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
async function call(path: string, init: { method?: string; headers?: Record<string, string>; body?: string } = {}): Promise<Query> {
for (;;) {
const response = await fetch(API + path, { ...init, headers: { ...headers, ...init.headers } });
const data = (await response.json().catch(() => ({}))) as { code?: string; message?: string };
// 429 rate_limited 和 503 属于临时错误: 稍候并重发原请求
if (response.status === 503 || (response.status === 429 && data.code === "rate_limited")) {
await sleep(Number(response.headers.get("Retry-After") ?? 5) * 1000);
continue;
}
if (!response.ok) throw new Error(`${response.status} ${data.code}: ${data.message}`);
return data as Query;
}
}
let query = await call("/v1/queries", {
method: "POST",
// 重试时传入相同的 Idempotency-Key 会返回原 query,不会重复创建
headers: { "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
body: JSON.stringify({ query: "Which robot vacuum is the best choice?", apps: ["doubao", "kimi"] }),
});
// 轮询直至 query 结束
while (query.status === "pending") {
await sleep(10_000);
query = await call(`/v1/queries/${query.query_id}`);
}
console.log("query", query.status);
for (const task of query.tasks) {
if (task.status === "done") console.log(task.app, task.result?.answer_markdown);
else console.log(task.app, task.status, task.error);
}

所有接口也可直接在浏览器中调试:打开任意接口页面 (如提交 query),使用侧边的在线调试面板即可。