快速开始
1. 获取 Key 和积分
Section titled “1. 获取 Key 和积分”登录控制台,创建 API Key 并充值。新账号初始积分为 0,充值前无法提交 query。完整 Key 只显示 1 次。
2. 验证 Key
Section titled “2. 验证 Key”export GEOEVAL_API_KEY="geo_live_..."curl https://geo-api.geoeval.com/v1/me -H "Authorization: Bearer $GEOEVAL_API_KEY"3. 提交 query
Section titled “3. 提交 query”# 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,任务在后台执行。
4. 读取结果
Section titled “4. 读取结果”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。
// 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);}# pip install requests。提交 query,等待结束并打印回答。import osimport timeimport uuid
import requests
API = "https://geo-api.geoeval.com"session = requests.Session()session.headers["Authorization"] = f"Bearer {os.environ['GEOEVAL_API_KEY']}"
def call(method, path, **kwargs): while True: response = session.request(method, API + path, timeout=30, **kwargs) # 429 rate_limited 和 503 属于临时错误: 稍候并重发原请求 if response.status_code == 503 or ( response.status_code == 429 and response.json().get("code") == "rate_limited" ): time.sleep(int(response.headers.get("Retry-After", 5))) continue if not response.ok: raise RuntimeError(response.text) return response.json()
query = call( "POST", "/v1/queries", # 重试时传入相同的 Idempotency-Key 会返回原 query,不会重复创建 headers={"Idempotency-Key": str(uuid.uuid4())}, json={"query": "Which robot vacuum is the best choice?", "apps": ["doubao", "kimi"]},)
while query["status"] == "pending": time.sleep(10) query = call("GET", f"/v1/queries/{query['query_id']}")
print("query", query["status"])for task in query["tasks"]: if task["status"] == "done": print(task["app"], task["result"]["answer_markdown"]) else: print(task["app"], task["status"], task["error"])所有接口也可直接在浏览器中调试:打开任意接口页面 (如提交 query),使用侧边的在线调试面板即可。