> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 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`.

<ParamField path="job_id" type="string" required>
  The unique job identifier (e.g., `run_abc123`).
</ParamField>

## Response

<ResponseField name="job_id" type="string" required>
  Unique job identifier.
</ResponseField>

<ResponseField name="status" type="string" required>
  Job status (should be `succeeded` for results to be available).
</ResponseField>

<ResponseField name="result" type="string" required>
  The output/result from the agent execution.
</ResponseField>

<ResponseField name="duration_seconds" type="number" required>
  Total execution time in seconds.
</ResponseField>

<ResponseField name="created_at" type="string" required>
  ISO 8601 timestamp of job creation.
</ResponseField>

<ResponseField name="completed_at" type="string" required>
  ISO 8601 timestamp of job completion.
</ResponseField>

<RequestExample>
  ```bash cURL theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  curl http://127.0.0.1:8005/api/v1/runs/run_abc123/result
  ```

  ```python Python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  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")
  ```

  ```bash CLI theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  praisonai run result run_abc123

  # JSON output
  praisonai run result run_abc123 --json
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "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"
  }
  ```

  ```json 400 Bad Request (Job Not Complete) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "detail": "Job is still running. Current status: running"
  }
  ```

  ```json 400 Bad Request (Job Failed) theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "detail": "Job failed. No result available.",
    "error": "Agent execution timeout"
  }
  ```

  ```json 404 Not Found theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  {
    "detail": "Job not found: run_abc123"
  }
  ```
</ResponseExample>

## Complete Workflow Example

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
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

| Status | Description                |
| ------ | -------------------------- |
| `400`  | Job not complete or failed |
| `404`  | Job not found              |
| `500`  | Internal server error      |

## See Also

* [Get Run Status](/docs/api/praisonai/async-jobs/get-run-status)
* [Submit Run](/docs/api/praisonai/async-jobs/submit-run)
* [Async Jobs Overview](/docs/api/praisonai/async-jobs)
