Exa Search: query the web and check the returned highlights
Send one specific query to Exa Search with highlights enabled, read each result's URL and highlights, then verify them on the original page.
Prepare the input and environment · Mechanism and data flow · Workflow map
At a glance
This tutorial follows the official Exa Search page. It shows how to submit one specific query, enable highlights, and use each result's url to check the original page. A highlight is a lead, and a conclusion you can cite has to be confirmed on the page itself. The page gives only a reference response schema and a short Python example, so nothing here describes real returned content.
Mechanism overview
Request and authentication
Request and authentication:The page documents a
POSTrequest tohttps://api.exa.ai/search.Search type and contents
Search type and contents:
typedefaults toauto, which the page describes as a balanced mode recommended for most applications, and the example sets it explicitly.Response structure
Response structure: the reference 200 response shows results and fields such as title, url, publishedDate, author and id, together with text, summary, subpages, entities, extras, requestId, costDollars and searchTime.
Error responses
Error responses:The page lists the status codes 200, 400, 401, 402, 403, 429, 500 and 503.
Prepare the input and environment
- An Exa API key created in the dashboard. The page says new accounts start with free credits; current pricing and credit amounts were not checked here.
YOUR_API_KEYin the example is a placeholder and must be replaced. - A Python environment where
from exa_py import Exaresolves. The page gives no installation instructions, and this article does not add any. - One specific query to replace
<query>in the example, at least 1 character long. - Network access to open the result
urlvalues, because the verification happens on the original pages.
Mechanism and data flow
Request and authentication:The page documents a POST request to https://api.exa.ai/search. The API key goes in the x-api-key header, and the page says Authorization: Bearer also works. The only required body field is query, a string of at least 1 character. In the Python example you do not write headers yourself, because the key is passed through the constructor's api_key parameter. The placeholder is not a working credential, and <query> is likewise a slot for your own text. The page does not say how the SDK builds the HTTP request, so that part is undocumented here.
Search type and contents:type defaults to auto, which the page describes as a balanced mode recommended for most applications, and the example sets it explicitly. contents is an optional object for text, highlights, summary, extras and freshness controls, and the example sets highlights to True inside it to request highlights. The page also lists numResults (default 10, range 1 to 100), includeDomains, excludeDomains, startPublishedDate and endPublishedDate, among others. Some combinations are rejected: the company and people categories do not support the published-date filters, and a request that sets an unsupported filter returns a 400 error. The lite type accepts only a subset of parameters that the page lists.
Response structure: the reference 200 response shows results and fields such as title, url, publishedDate, author and id, together with text, summary, subpages, entities, extras, requestId, costDollars and searchTime. The Python example explicitly requests highlights with highlights=True inside contents. Inspect the actual response to determine which fields were obtained; the reference is not a guarantee for every result. Handle warnings and notices when returned.
Error responses:The page lists the status codes 200, 400, 401, 402, 403, 429, 500 and 503. Each non-200 body is shown with the same three fields: requestId, error and tag. Apart from the 400 case above, the page does not explain what causes each code, so the numbers alone say little about meaning. When a request fails, record those three fields first, since they are the only error fields the page shows. A 200 response with an empty or weak results list is a different situation that the page does not describe.
Workflow map
| Stage | What happens |
|---|---|
| Request and authentication | Request and authentication:The page documents a POST request to https://api.exa.ai/search. |
| Search type and contents | Search type and contents:type defaults to auto, which the page describes as a balanced mode recommended for most applications, and the example sets it explicitly. |
| Response structure | Response structure: the reference 200 response shows results and fields such as title, url, publishedDate, author and id, together with text, summary, subpages, entities, extras, requestId, costDollars and searchTime. |
| Error responses | Error responses:The page lists the status codes 200, 400, 401, 402, 403, 429, 500 and 503. |
Complete the task
Create the key and keep it out of the code:Create an API key in the dashboard. The page says new accounts start with free credits; current pricing is not verified here, so check the official page. Put the key in an environment variable or a secret store, then supply it where the example has YOUR_API_KEY. The JavaScript and cURL examples on the page read the key from the EXA_API_KEY environment variable, while the Python example writes a placeholder, so how you supply the key is up to you. Do not commit the key to a repository or paste it into a screenshot.
Write a specific query:query cannot be empty. Choose a query with a clear question and a named subject, so you can later judge whether the highlights answer it. If you only want to restrict sources, the page recommends includeDomains or excludeDomains instead of adding a site: operator to the query. The example does not include these parameters, so adding them is your own change, and the page does not say whether the Python SDK accepts them as keyword arguments with the same names, so confirm that before relying on it.
Read the example code:The example imports Exa from exa_py and creates a client called exa with api_key. It then calls exa.search, passing the query string first, type set to auto, and a contents dictionary that sets highlights to True. The return value is stored in the variable result. The code does not install dependencies, read an environment variable, print anything or handle errors, so you have to add those. It also cannot show that the query suits your task or that the results are semantically correct.
Run it in your own environment:Running it needs a valid key and a network connection. The example only stores the response in result and outputs nothing, so add your own way of inspecting it, for example by looking at the structure of that object. The page does not document the attribute names of the Python SDK's return object, only the JSON reference schema, so compare the fields you actually see with the schema and do not assume they match. This article did not run the code and offers no run output.
Read url and highlights:For each entry in results, note title, url, publishedDate and highlights. highlights is an array of strings, so one entry may carry several passages. The reference schema does not promise that every field appears, so mark an entry without highlights as not retrieved instead of guessing from other fields. Keep the requestId as well, so you can trace this request later.
Check against the original page:Open each url, find the passage behind each highlight, and read it with its surrounding context to see whether it supports the conclusion you want to write. Then check the publication date. The page does not say whether highlights are verbatim excerpts, so locate the text on the original page and do not assume it is accurate. Only content you confirmed on the original page goes into the final notes, together with its url.
Review warnings and errors, then clean up:Look at warnings and notices in the response: log the first, and use the second together with the results. If you get a non-200 response, record requestId, error and tag, then recheck the query, the filters and the key. When you are done, remove the key from scripts, terminal history and shared documents. The page navigation lists endpoints for rotating, revoking and deleting API keys, but their usage is not on this page and this article does not describe it.
Worked example
Suppose you want to know what the Search page says about domain filtering. You replace <query> with a question about restricting results to a single site, keep type as auto with highlights enabled, and run the example. This is an illustration only: no code was run here and no output is claimed. If the response follows the reference schema, each entry in results gives a url and a highlights array. You open each url, find the original text behind every highlight, and compare it with the page's instruction to use includeDomains rather than a site: operator. Only statements you confirmed on the page go into your notes, along with the url and the requestId.
from exa_py import Exa
exa = Exa(api_key="YOUR_API_KEY")
result = exa.search(
"<query>",
type="auto",
contents={"highlights": True},
)
Check the result and failure paths
- Success: the response is 200,
resultsis not empty, every entry you rely on has aurlandhighlights, and its passages can be found on the original page and agree with the surrounding context. - Success: you recorded the
requestIdand looked atwarningsandnotices. - Failure: the body has the error shape of
requestId,errorandtag; and if you used thecompanyorpeoplecategory with a published-date filter, the page says you get a 400. - Failure:
warningsshows something likeIGNORED_FIELD, meaning a field was ignored; or a highlight cannot be found on the original page or conflicts with its context, in which case that result is not usable evidence.
Inspect result in an interactive environment and read fields according to the actual SDK object type; this tutorial does not invent attribute names. Refine the query if results are empty or irrelevant. Mark an item unverified if its page cannot be opened or highlights are missing. If you stop, do not turn unverified material into a conclusion, and handle any exposed key. These are editorial acceptance suggestions.
Scope and limits
- This article relies only on the official Search page, which does not state how accurate highlights are or how they map to the original text.
- This page does not provide exa_py installation instructions or the full SDK return-object contract. Its example demonstrates the query, type and contents. Check separate documentation for other parameters and their Python names; the JSON response is a reference structure.
- Free credits are the page's claim; current pricing, credit amounts and rate limits were not checked here, and
costDollarsis only an estimate. - The example code only sends a request and has no printing, error handling or key loading, so it is not a complete program.
No Exa product, API or SDK was run in this batch, no API key was used, and no real response was observed. Statements about the response come from the reference schema on the official page, and the checks describe what to look at when you run it yourself.
Article sources
Original editorial content; official descriptions and checking suggestions are distinguished.