Polling for results
Each query creates one task per target app. Poll GET /v1/queries/{query_id} until status leaves pending.
Query status
Section titled “Query status”| status | Meaning | Final |
|---|---|---|
pending |
At least one task is still in progress. | No |
completed |
All tasks have reached done, failed, or unavailable (individual tasks may still have failed). |
Yes |
timeout |
deadline_at (roughly 6 hours) passed before all tasks finished. |
Yes |
failed |
The query could not be queued; check error. No credits are charged. |
Yes |
Task status
Section titled “Task status”| status | Meaning | Final |
|---|---|---|
queued |
Waiting to run. Failed attempts return here for automatic retry. | No |
running |
Waiting for the app to answer. | No |
uploaded |
Raw response received; waiting to be parsed. | No |
parsing |
Extracting structured fields from the response. | No |
done |
result is populated. Only done tasks are charged. |
Yes |
failed |
Processing failed after retries; check error. |
Yes |
unavailable |
The target app did not respond (for example, due to overload). Retry later. | Yes |
Both completed and timeout queries can contain a mix of task outcomes, so inspect each task individually.
If a query reaches timeout while a task is already in uploaded or parsing, that task may still finish shortly afterward; fetch the query again if you need it.
Polling interval
Section titled “Polling interval”- Poll every 10 seconds. Tasks typically complete in about a minute, plus queue wait time under heavy load.
- Each API key allows up to 300 read requests per minute; exceeding this returns
429 rate_limitedwith aRetry-Afterheader. - For high-volume workloads, prefer callbacks or batch status checks via
GET /v1/queries.
Example
Section titled “Example”// Node 24+ runs this file as it is. Submits a query, waits until it is final and prints the answers.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 and 503 are temporary: wait and repeat the same request 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", // The same Idempotency-Key on a retry returns the same query instead of creating a second one headers: { "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() }, body: JSON.stringify({ query: "Which robot vacuum is the best choice?", apps: ["doubao", "kimi"] }),});
// Poll until the query is finalwhile (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. Submits a query, waits until it is final and prints the answers.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 and 503 are temporary: wait and repeat the same request 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", # The same Idempotency-Key on a retry returns the same query instead of creating a second one 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"])