Deep Research Agent API

AI-powered multi-round web research with fact extraction, synthesis, and validation.

Endpoints

GET/health

Health check endpoint.

Response

{ "ok": true, "service": "deep-research-agent" }

GET/research/:responseId

Resume polling for a background deep research job. Use this to check on jobs that failed due to rate limits or timeouts.

Path Parameters

ParameterDescription
responseIdThe response_id returned from the initial POST /research call (e.g., resp_abc123)

Authentication

Requires X-API-Key header.

Behavior

Example

curl -H "X-API-Key: YOUR_KEY" \
  "https://deep-research-agent.vetapp.workers.dev/research/resp_abc123"

Response

{
  "ok": true,
  "answer": "...",
  "response_id": "resp_abc123",
  "mode": "deep_research",
  "raw_response": { ... },
  "trace": [ ... ]
}

POST/research

Execute a deep research query with multi-round web search, fact extraction, and validated synthesis.

Request Body

FieldTypeDescription
questionrequiredstringThe research question to answer
optionsoptionalobjectConfiguration overrides (see below)

Model Options

OptionTypeDefaultDescription
modelstring"gpt-4o-mini"OpenAI model (o3-deep-research, o4-mini-deep-research, gpt-5.2, gpt-4.1, gpt-4o, o3, etc.)
temperaturenumbernullSampling temperature (0-2)
top_pnumbernullNucleus sampling (0-1)
max_output_tokensnumbernullMax tokens to generate (1-128000)
reasoning_effortstringnullFor o1/o3 models: "low", "medium", or "high"
instructionsstringnullSystem instructions/prompt
storebooleantrueWhether to store response in OpenAI
maxRetriesnumber3Max retry attempts for failed API calls (0-5)

Deep Research Options (o3-deep-research, o4-mini-deep-research)

OptionTypeDefaultDescription
backgroundbooleanfalseRun in background mode (recommended for long tasks)
codeInterpreterbooleanfalseEnable Python code execution for data analysis
maxToolCallsnumbernullMax tool calls before returning (1-1000)
reasoningSummarystringnullReasoning summary: "auto", "concise", or "detailed"

Deep research models can analyze hundreds of sources and take 10-30+ minutes. Use background mode to prevent timeouts.

Research Agent Options

OptionTypeDefaultDescription
maxSearchRoundsnumber4Max search iterations (1-10)
maxFactsnumber18Max facts to collect (5-50)
minNewFactsPerRoundnumber2Min new facts per round before stagnation (0-10)

Web Search Options

OptionTypeDefaultDescription
webContextSizestring"medium"Search depth: "low", "medium", or "high"
forceDomainsarraynullRestrict sources to specific domains (e.g., [".gov", ".edu"])
userLocationobjectnullLocation for localized results (see below)

User Location Object

FieldTypeDescription
countrystringISO 2-letter country code (e.g., "US", "GB")
citystringCity name (e.g., "San Francisco")
regionstringState/region (e.g., "California")
timezonestringIANA timezone (e.g., "America/Los_Angeles")

Authentication

This endpoint requires an API key. Include it in the X-API-Key header.

Example Request

curl -X POST "https://deep-research-agent.vetapp.workers.dev/research" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "question": "What is the OpenAI Responses API?",
    "options": {
      "model": "gpt-4o",
      "temperature": 0.7,
      "maxSearchRounds": 3,
      "maxFacts": 12,
      "webContextSize": "medium",
      "forceDomains": ["openai.com", ".edu"],
      "userLocation": { "country": "US" }
    }
  }'

Response

FieldDescription
okSuccess boolean
questionOriginal question
answerSynthesized answer with [F#] citations
fact_tableArray of extracted facts with URLs, confidence, and quality scores
conflictsDetected conflicting claims between sources
planResearch plan with queries and stop conditions
validationValidation results and any issues found
traceExecution trace for debugging
startedAt / finishedAtTimestamps

Source Quality Scoring

ScoreSource Types
5.gov, .edu domains
4Standards bodies (IETF, W3C, ISO), official docs, academic publishers
3Reference sites (Wikipedia, Britannica)
2Blogs, general websites
1Social media (X, Reddit, TikTok)

Pipeline Stages

  1. Planner - Generates 6-10 search queries and stop conditions
  2. Web Search - Multi-round searches using OpenAI's web_search tool
  3. Fact Extraction - Extracts atomic, verifiable facts with confidence scores
  4. Synthesis - Combines facts into a coherent answer with citations
  5. Validation - Verifies all claims are supported by extracted facts