Getting started
Install the exa-py SDKBash
Python
Get API Key
Follow this link to get your API key
search Method
Perform an Exa search given an input query and retrieve a list of relevant results as links.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| query | str | The input query string. | Required |
| num_results | Optional[int] | Number of search results to return. Limits vary by search type: with “keyword”: max 10, with “neural”: max 100. If you want to increase the num results, contact sales ([email protected]) | 10 |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude in the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| type | Optional[str] | The type of search, keyword or neural. | ”auto” |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. Currently, the available categories are: company, research paper, news, linkedin profile, github, tweet, movie, song, personal site, pdf and financial report. | None |
| include_text | Optional[List[str]] | List of strings that must be present in webpage text of results. Currently, only 1 string is supported, of up to 5 words. | None |
| exclude_text | Optional[List[str]] | List of strings that must not be present in webpage text of results. Currently, only 1 string is supported, of up to 5 words. Checks from the first 1000 words of the webpage text. | None |
| context | Union[ContextContentsOptions, Literal[True]] | If true, concatentates results into a context string. | None |
Returns Example:
JSON
Return Parameters:
SearchResponse[Result]
| Field | Type | Description |
|---|---|---|
| results | List[Result] | List of Result objects |
| context | Optional[str] | Results concatentated into a string |
Result Object:
| Field | Type | Description |
|---|---|---|
| url | str | URL of the search result |
| id | str | Temporary ID for the document |
| title | Optional[str] | Title of the search result |
search_and_contents Method
Perform an Exa search given an input query and retrieve a list of relevant results as links, optionally including the full text and/or highlights of the content.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| query | str | The input query string. | Required |
| text | Union[TextContentsOptions, Literal[True]] | If provided, includes the full text of the content in the results. | None |
| highlights | Union[HighlightsContentsOptions, Literal[True]] | If provided, includes highlights of the content in the results. | None |
| num_results | Optional[int] | Number of search results to return. Limits vary by search type: with “keyword”: max 10, with “neural”: max 100. If you want to increase the num results, contact sales ([email protected]) | 10 |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude in the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| type | Optional[str] | The type of search, keyword or neural. | ”auto” |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. Currently, the available categories are: company, research paper, news, linkedin profile, github, tweet, movie, song, personal site, pdf and financial report. | None |
| include_text | Optional[List[str]] | List of strings that must be present in webpage text of results. Currently, only 1 string is supported, of up to 5 words. | None |
| exclude_text | Optional[List[str]] | List of strings that must not be present in webpage text of results. Currently, only 1 string is supported, of up to 5 words. Checks from the first 1000 words of the webpage text. | None |
| context | Union[ContextContentsOptions, Literal[True]] | Return page contents as a context string for LLM RAG. When true, combines all result contents into one string. We recommend 10000+ characters for best results. Context strings often perform better than highlights for RAG applications. | None |
Returns Example:
JSON
Return Parameters:
The return type depends on the combination oftext and highlights parameters:
SearchResponse[ResultWithText]: When onlytextis provided.SearchResponse[ResultWithHighlights]: When onlyhighlightsis provided.SearchResponse[ResultWithTextAndHighlights]: When bothtextandhighlightsare provided.
SearchResponse[ResultWithTextAndHighlights]
| Field | Type | Description |
|---|---|---|
| results | List[ResultWithTextAndHighlights] | List of ResultWithTextAndHighlights objects |
| context | Optional[str] | Results concatenated into a string |
ResultWithTextAndHighlights Object
| Field | Type | Description |
|---|---|---|
| url | str | URL of the search result |
| id | str | Temporary ID for the document |
| title | Optional[str] | Title of the search result |
text nor highlights is specified, the method defaults to including the full text content.
find_similar Method
Find a list of similar results based on a webpage’s URL.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| url | str | The URL of the webpage to find similar results for. | Required |
| num_results | Optional[int] | Number of similar results to return. | None |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude from the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| exclude_source_domain | Optional[bool] | If true, excludes results from the same domain as the input URL. | None |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. | None |
| context | Union[ContextContentsOptions, Literal[True]] | Return page contents as a context string for LLM RAG. When true, combines all result contents into one string. We recommend 10000+ characters for best results. Context strings often perform better than highlights for RAG applications. | None |
Returns Example:
JSON
Return Parameters:
SearchResponse[_Result]: The response containing similar results and optional autoprompt string.
SearchResponse[Results]
| Field | Type | Description |
|---|---|---|
| results | List[ResultWithTextAndHighlights] | List of ResultWithTextAndHighlights objects |
| context | Optional[String] | Results concatentated into a string |
Results Object
| Field | Type | Description |
|---|---|---|
| url | str | URL of the search result |
| id | str | Temporary ID for the document |
| title | Optional[str] | Title of the search result |
find_similar_and_contents Method
Find a list of similar results based on a webpage’s URL, optionally including the text content or highlights of each result.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| url | str | The URL of the webpage to find similar results for. | Required |
| text | Union[TextContentsOptions, Literal[True]] | If provided, includes the full text of the content in the results. | None |
| highlights | Union[HighlightsContentsOptions, Literal[True]] | If provided, includes highlights of the content in the results. | None |
| num_results | Optional[int] | Number of similar results to return. | None |
| include_domains | Optional[List[str]] | List of domains to include in the search. | None |
| exclude_domains | Optional[List[str]] | List of domains to exclude from the search. | None |
| start_crawl_date | Optional[str] | Results will only include links crawled after this date. | None |
| end_crawl_date | Optional[str] | Results will only include links crawled before this date. | None |
| start_published_date | Optional[str] | Results will only include links with a published date after this date. | None |
| end_published_date | Optional[str] | Results will only include links with a published date before this date. | None |
| exclude_source_domain | Optional[bool] | If true, excludes results from the same domain as the input URL. | None |
| category | Optional[str] | A data category to focus on when searching, with higher comprehensivity and data cleanliness. | None |
| context | Union[ContextContentsOptions, Literal[True]] | If true, concatentates results into a context string. | None |
Returns:
The return type depends on the combination oftext and highlights parameters:
SearchResponse[ResultWithText]: When onlytextis provided or when neithertextnorhighlightsis provided (defaults to including text).SearchResponse[ResultWithHighlights]: When onlyhighlightsis provided.SearchResponse[ResultWithTextAndHighlights]: When bothtextandhighlightsare provided.
text nor highlights is specified, the method defaults to including the full text content.
answer Method
Generate an answer to a query using Exa’s search and LLM capabilities. This method returns an AnswerResponse with the answer and a list of citations. You can optionally retrieve the full text of each citation by setting text=True.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| query | str | The question to answer. | Required |
| text | Optional[bool] | If true, the full text of each citation is included in the result. | False |
| stream | Optional[bool] | Note: If true, an error is thrown. Use stream_answer() instead for streaming responses. | None |
Returns Example:
JSON
Return Parameters:
Returns anAnswerResponse object:
| Field | Type | Description |
|---|---|---|
| answer | str | The generated answer text |
| citations | List[AnswerResult] | List of citations used to generate the answer |
AnswerResult object
| Field | Type | Description |
|---|---|---|
| id | str | Temporary ID for the document |
| url | str | URL of the citation |
| title | Optional[str] | Title of the content, if available |
| published_date | Optional[str] | Estimated creation date |
| author | Optional[str] | The author of the content, if available |
| text | Optional[str] | The full text of the content (if text=True) |
stream_answer Method
Generate a streaming answer to a query with Exa’s LLM capabilities. Instead of returning a single response, this method yields chunks of text and/or citations as they become available.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| query | str | The question to answer. | Required |
| text | Optional[bool] | If true, includes full text of each citation in the streamed response. | False |
Return Type:
AStreamAnswerResponse object, which is iterable. Iterating over it yields StreamChunk objects:
StreamChunk
| Field | Type | Description |
|---|---|---|
| content | Optional[str] | Partial text content of the answer so far. |
| citations | Optional[List[AnswerResult]] | Citations discovered in this chunk, if any. |
stream.close() to end the streaming session if needed.
research.create_task Method
Create an asynchronous research task that performs multi-step web research and returns structured JSON results with citations.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| instructions | str | Natural language instructions describing what the research task should accomplish. | Required |
| model | Optional[str] | The research model to use. Options: “exa-research” (default), “exa-research-pro”. | “exa-research” |
| output_schema | Optional[Dict] | JSON Schema specification for the desired output structure. See json-schema.org/draft-07. | None |
| infer_schema | Optional[bool] | When true and no output schema is provided, an LLM will generate an output schema. | None |
Returns:
Returns aResearchTask object:
| Field | Type | Description |
|---|---|---|
| id | str | The unique identifier for the task |
Return Example:
JSON
research.get_task Method
Get the current status and results of a research task by its ID.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| task_id | str | The unique identifier of the task | Required |
Returns:
Returns aResearchTaskDetails object:
| Field | Type | Description |
|---|---|---|
| id | str | The unique identifier for the task |
| status | str | Task status: “running”, “completed”, or “failed” |
| instructions | str | The original instructions provided |
| schema | Optional[Dict] | The JSON schema specification used |
| data | Optional[Dict] | The research results (when completed) |
| citations | Optional[Dict[str, List]] | Citations grouped by root field (when completed) |
Return Example:
JSON
research.poll_task Method
Poll a research task until it completes or fails, returning the final result.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| task_id | str | The unique identifier of the task | Required |
| poll_interval | Optional[int] | Seconds between polling attempts | 2 |
| max_wait_time | Optional[int] | Maximum seconds to wait before timing out | 300 |
Returns:
Returns aResearchTaskDetails object with the completed task data (same structure as get_task).
research.list_tasks Method
List all research tasks with optional pagination.
Input Example:
Python
Input Parameters:
| Parameter | Type | Description | Default |
|---|---|---|---|
| cursor | Optional[str] | Pagination cursor from previous request | None |
| limit | Optional[int] | Number of results to return (1-200) | 25 |
Returns:
Returns a dictionary with:| Field | Type | Description |
|---|---|---|
| data | List[ResearchTaskDetails] | List of research task objects |
| hasMore | bool | Whether there are more results to paginate |
| nextCursor | Optional[str] | Cursor for the next page (if hasMore is true) |
Return Example:
JSON

