const structuredResult = await exa.search("Who is the CEO of OpenAI?", { type: "deep", systemPrompt: "Prefer official sources and avoid duplicate results", outputSchema: { type: "object", properties: { leader: { type: "string" }, title: { type: "string" }, sourceCount: { type: "number" }, }, required: ["leader", "title"], }, contents: { highlights: { maxCharacters: 4000, }, },});console.log(structuredResult.output?.content);
outputSchema and systemPrompt work across all search types. Keep outputSchema focused on
output.content, and use systemPrompt to guide the final returned result. For more demanding
synthesis, prefer reasoning-focused search types like deep-lite, deep, deep-reasoning, or
deep-max. Do not include citations/confidence in your schema; Exa returns grounding
automatically in output.grounding. Including citation/confidence fields in outputSchema
duplicates data, reduces structure quality, and is usually less reliable.
Reasoning-focused search variants:
deep-lite: lowest-latency deep-search mode
deep: light mode
deep-reasoning: base reasoning mode
deep-max: maximum-effort deep-search mode
Need streaming structured synthesis? The raw /search endpoint supports stream: true together
with outputSchema and returns OpenAI-compatible SSE chunks. See the Search API
guide.