Research
Asynchronous deep research: a cited report from several searches and page reads.
POST /v1/research starts a job that plans several searches, reads the best pages and writes a report where every claim cites its source as [S1]..[Sn] (or, with output_schema, a JSON answer). The request waits up to wait_s seconds (default 0) and answers 200 with the finished job or 202 while it is queued / running; poll GET /v1/research/{id} until status is done or failed. Resending the same Idempotency-Key returns the existing job. Admission is the same as tools — your rules see it as web_search. Price: $0.20 per job plus its model tokens; jobs inside the monthly free allowance or a codai agent turn are not charged the job fee.
The SDKs wrap the polling: codai.research.run({ question }) (TypeScript) and codai.research.run("…") (Python) start the job and wait for it. The same engine is the deep_research tool in VS Code, desktop, phone, headless and the hosted MCP. Details: tools guide.
bearerAuthAuthorizationBearer <codai_…>A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by the media surfaces matching their scope (/v1/realtime, /v1/audio/*, /v1/embeddings).
x-request-id?stringClient correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128Idempotency-Key?stringReturns the job created earlier with the same key instead of starting another one (first 200 characters are used).
length <= 200application/json- body
Body of POST /v1/research.
question*stringThe research question, with any constraints (region, period, what to compare).
1 <= length <= 2000time_budget_s?integerMaximum research time in seconds.
20 <= value <= 30090max_sources?integerMaximum number of pages to read.
3 <= value <= 3012include_domains?array<>Only use pages from these hosts.
items <= 10published_after?stringOnly use pages published on or after this date (YYYY-MM-DD).
^\d{4}-\d{2}(-\d{2})?$output_schema?Optional JSON Schema; the result is then a JSON object matching it in answer instead of a prose report.
wait_s?numberSeconds to wait for the job to finish before answering 202.
0 <= value <= 550The job finished within wait_s (status is done or failed).
application/json- response
A deep-research job. Result fields are present only when status is done, error only when it is failed.
id*stringuuidstatus*string"queued""running""done""failed"created_at*stringdate-timefinished_at?stringdate-timereport?stringMarkdown report citing sources as [S1]..[Sn] (absent when output_schema was set).
answer?JSON object matching output_schema, when one was sent.
sources?array<>searches?integerNumber of web searches the job ran.
0 <= valuepages_read?integerNumber of pages the job read.
0 <= valueerror?curl -X POST 'https://ai.codai.ro/v1/research' \ -H 'Content-Type: application/json' \ -d '{ "question": "Compare the e-Factura obligations for B2C sales in Romania in 2025 and 2026"}'{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "status": "queued", "created_at": "2019-08-24T14:15:22Z", "finished_at": "2019-08-24T14:15:22Z", "report": "string", "answer": {}, "sources": [ { "id": "string", "title": "string", "url": "http://example.com" } ], "searches": 0, "pages_read": 0, "error": { "message": "string" }}bearerAuthAuthorizationBearer <codai_…>A codai API key (codai_ prefix). Ephemeral tokens from POST /v1/tokens are accepted only by the media surfaces matching their scope (/v1/realtime, /v1/audio/*, /v1/embeddings).
id*stringResearch job UUID returned by POST /v1/research.
uuidx-request-id?stringClient correlation id; echoed back as x-codai-trace-id and persisted on the usage row.
length <= 128The job.
application/json- response
A deep-research job. Result fields are present only when status is done, error only when it is failed.
id*stringuuidstatus*string"queued""running""done""failed"created_at*stringdate-timefinished_at?stringdate-timereport?stringMarkdown report citing sources as [S1]..[Sn] (absent when output_schema was set).
answer?JSON object matching output_schema, when one was sent.
sources?array<>searches?integerNumber of web searches the job ran.
0 <= valuepages_read?integerNumber of pages the job read.
0 <= valueerror?curl -X GET 'https://ai.codai.ro/v1/research/497f6eca-6276-4993-bfeb-53cbbbba6f08'{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "status": "queued", "created_at": "2019-08-24T14:15:22Z", "finished_at": "2019-08-24T14:15:22Z", "report": "string", "answer": {}, "sources": [ { "id": "string", "title": "string", "url": "http://example.com" } ], "searches": 0, "pages_read": 0, "error": { "message": "string" }}