curl http://127.0.0.1:8005/api/v1/runs/run_abc123/result
{ "job_id": "run_abc123", "status": "succeeded", "result": "The quarterly sales data shows a 15% increase in Q4 compared to Q3. Key highlights:\n\n1. Product A: +20% growth\n2. Product B: +10% growth\n3. New customer acquisition: +25%\n\nRecommendation: Focus marketing efforts on Product A momentum.", "duration_seconds": 45.23, "created_at": "2025-01-01T00:00:00Z", "completed_at": "2025-01-01T00:00:45Z" }
Get the result of a completed async job
succeeded
run_abc123
import httpx import time API_URL = "http://127.0.0.1:8005" def submit_and_get_result(prompt): # Submit job response = httpx.post( f"{API_URL}/api/v1/runs", json={"prompt": prompt} ) job_id = response.json()["job_id"] print(f"Submitted job: {job_id}") # Wait for completion while True: status = httpx.get(f"{API_URL}/api/v1/runs/{job_id}").json() if status["status"] == "succeeded": # Get result result = httpx.get(f"{API_URL}/api/v1/runs/{job_id}/result").json() return result["result"] elif status["status"] in ("failed", "cancelled"): raise Exception(f"Job {status['status']}: {status.get('error', 'Unknown error')}") time.sleep(status.get("retry_after", 2)) result = submit_and_get_result("What is 2+2?") print(f"Result: {result}")
400
404
500