Async Mode (Default)
Async mode returns immediately with a job ID, allowing you to poll for results or receive them via webhook callback. This is ideal for long-running analyses and CI/CD integrations.How It Works
- Submit analysis request to
/analyze - Receive job ID immediately (HTTP 202)
- Poll
/results/{job_id}for status updates - Or configure a callback webhook to receive results automatically
Example: Async with Polling
Example: Async with Callback
Configure a webhook to receive results automatically when analysis completes:cURL
Polling for Results
Check the analysis status using the job ID:Sync Mode
Sync mode blocks until analysis is complete and returns the full result immediately. Use this for simple scripts or when you need immediate results.How It Works
- Submit analysis request to
/analyze?sync=true - Server blocks until AI analysis completes
- Receive complete analysis result (HTTP 200)
Example: Sync Analysis
Choosing the Right Mode
Use Async When
- Integrating with CI/CD pipelines
- Analysis takes more than a few seconds
- You need to show progress to users
- Multiple analyses run concurrently
Use Sync When
- Running quick scripts or one-off analyses
- You need results immediately
- Simplicity is more important than scalability
- Testing or debugging the API
Implementation Details
Both modes use the same analysis engine under the hood. The difference is only in how results are delivered:- Async mode (main.py:366-451): Uses FastAPI’s
BackgroundTasksto queue analysis jobs - Sync mode (main.py:384-423): Awaits the analysis coroutine directly before returning
main.py:372-376