# Exa

> Use the Exa Python and JavaScript SDKs with Search1API by changing the base URL and key, and control when result pages are read.

Canonical URL: https://s1.dev/docs/compatibility/exa

Search1API answers Exa's `POST /search` and `POST /contents`. Set the Exa base URL to:

```text
https://api.search1api.com/compat/exa
```

Send your Search1API key as `x-api-key`, as the Exa SDKs do, or as `Authorization: Bearer`.

## Configure your client

<Tabs items={['Python', 'JavaScript']}>

<Tab value="Python">

```python
from exa_py import Exa

exa = Exa(api_key="YOUR_API_KEY", base_url="https://api.search1api.com/compat/exa")
results = exa.search("hono cloudflare workers", num_results=5, contents=False)
pages = exa.get_contents(["https://hono.dev/docs/"], text=True)
```

</Tab>

<Tab value="JavaScript">

```ts
import Exa from 'exa-js';

const exa = new Exa(process.env.SEARCH1API_KEY, 'https://api.search1api.com/compat/exa');
const results = await exa.search('hono cloudflare workers', { numResults: 5, contents: false });
const pages = await exa.getContents(['https://hono.dev/docs/'], { text: true });
```

</Tab>

</Tabs>

> **warn:** `search()` in `exa-py` and `exa-js` requests page text unless you pass `contents=False` (`contents: false` in JavaScript). Each page read costs 1 credit, so a default search for 10 results costs up to 11 credits. Pass `contents=False` when the title, URL and highlights are enough.

## Search

| Field | Behavior |
| --- | --- |
| `query` | Required. |
| `numResults` | Default `10`, up to `50`. |
| `category` | `news` searches news. Other categories search the web. |
| `includeDomains`, `excludeDomains` | Restrict or exclude sites. |
| `startPublishedDate`, `startCrawlDate` | Converted to the shortest of day, week, month or year that covers the period. |
| `contents.text` | `true` or `{ maxCharacters }` reads each result page into `text`, as Markdown, cut to `maxCharacters`. |
| `contents.highlights` | Returns the search snippet as the only highlight, with a highlight score of `1`. |

`type`, `contents.summary`, `livecrawl`, `maxAgeHours`, `userLocation` and other options are accepted and ignored.

The response has `requestId`, `results` and `searchTime`. Each result has `id` (the URL), `url`, `title`, and, when available or requested, `publishedDate`, `text`, `highlights` and `highlightScores`. `score`, `author`, `image`, `summary` and `costDollars` are not returned.

## Contents

`urls` (or `ids`, which are the result URLs) takes up to 50 URLs. Each page read is returned in `results` with `id`, `url`, `title` and `text`; `text.maxCharacters` cuts the text. `statuses` reports every URL as `success` or `error`, with the error tag `CRAWL_NOT_FOUND` for missing pages and `CRAWL_UNKNOWN_ERROR` otherwise.

## Credits

| Request | Credits |
| --- | --- |
| Search with `contents: false` or highlights only | 1 |
| Search with `contents.text` (the SDK default) | 1, plus 1 for each page read |
| Contents | 1 for each page read |

## Errors

Errors return `{ "requestId": "…", "error": "message", "tag": "…" }` with the status code. Tags include `INVALID_API_KEY` (401), `NO_MORE_CREDITS` (402), `RATE_LIMIT_EXCEEDED` (429) and `INVALID_REQUEST_BODY` (400).