Prerequisites
Before you begin, ensure you have:- Cerebras API Key
- Exa API Key
- Python or Node.js
Configure Exa with Cerebras
1
Install required dependencies
Install the Exa SDK and the OpenAI client library. The OpenAI client is used to connect to Cerebras’ OpenAI-compatible API.
The Node.js examples use ES modules and top-level
await. Save them with a .mjs extension (or set "type": "module" in your package.json) and run them with node file.mjs.2
3
Perform your first grounded web search
This example uses Exa search to gather current web results, then asks a Cerebras model to combine them into a short answer.
Search types and freshness controls
Exa supports a few search modes with different speed and coverage tradeoffs:
Freshness is controlled with
max_age_hours in Python or maxAgeHours in Node, inside contents. It is optional: leave it out for no freshness limit, or set 0 to always fetch fresh content, 24 to accept cached pages up to one day old, or -1 to use cached content only.
Get page contents
Every Exa search result already includes page content (highlights), so you usually don’t need a separate call. We recommend using search for most grounding workflows. Reach for the Contents API when you already have a URL and want to get its highlights directly.Use Exa as a tool for grounded answers
Tool calling works well when you want a Cerebras model to decide when to search the web. This example exposes Exa search as a tool.Next steps
- Explore the Exa API Dashboard
- See Build a Grounded Research Agent with Exa for a deeper tool-calling agent walkthrough
- See Build Your Own Perplexity with Exa for a longer end-to-end Exa workflow
- See Search Agent for another Cerebras + Exa research pattern

