Get Run Result API

Get the result of a completed async job

Retrieve the result of a completed async job. Only available when job status is succeeded.

job_id string

The unique job identifier (e.g., run_abc123).

Response

ResponseField string

Unique job identifier.

ResponseField string

Job status (should be succeeded for results to be available).

ResponseField string

The output/result from the agent execution.

ResponseField number

Total execution time in seconds.

ResponseField string

ISO 8601 timestamp of job creation.

ResponseField string

ISO 8601 timestamp of job completion.

cURL
curl http://127.0.0.1:8005/api/v1/runs/run_abc123/result
Python
import httpx

job_id = "run_abc123"

# Get result (only works if job succeeded)
response = httpx.get(f"http://127.0.0.1:8005/api/v1/runs/{job_id}/result")

if response.status_code == 200:
    result = response.json()
    print(f"Result: {result['result']}")
    print(f"Duration: {result['duration_seconds']}s")
elif response.status_code == 404:
    print("Job not found")
elif response.status_code == 400:
    print("Job not yet complete or failed")
CLI
praisonai run result run_abc123

# JSON output
praisonai run result run_abc123 --json
200 OK
{
  "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"
}
400 Bad Request (Job Not Complete)
{
  "detail": "Job is still running. Current status: running"
}
400 Bad Request (Job Failed)
{
  "detail": "Job failed. No result available.",
  "error": "Agent execution timeout"
}
404 Not Found
{
  "detail": "Job not found: run_abc123"
}

Complete Workflow Example

python
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}")

Error Responses

StatusDescription
400Job not complete or failed
404Job not found
500Internal server error

See Also