> SpecStream is the live web data engine for teams and agents. This is the Markdown copy of https://specstream.ai/docs/integrations/khoj. Every page, with what SpecStream does and costs: https://specstream.ai/llms.txt

# Khoj

For self-hosted Khoj: online search runs on the Search API once you set two environment variables on the Khoj server.

Use one of the two pairs below, in the environment Khoj starts in (for Docker, the `environment` block of the server in `docker-compose.yml`), then restart Khoj. Khoj uses the first search service it has a key for, in this order: Serper, Exa, Firecrawl. Leave `SERPER_DEV_API_KEY` unset.

## Exa search

Put [your key](https://specstream.ai/workspace/search?route=exa&utm_source=khoj&utm_medium=howto) in `EXA_API_KEY`:

Environment

```bash
EXA_API_URL=https://api.specstream.ai/exa
EXA_API_KEY=YOUR_SPECSTREAM_KEY
```

## Firecrawl search

Put [your key](https://specstream.ai/workspace/search?route=firecrawl&utm_source=khoj&utm_medium=howto) in `FIRECRAWL_API_KEY`:

Environment

```bash
FIRECRAWL_API_URL=https://api.specstream.ai/firecrawl
FIRECRAWL_API_KEY=YOUR_SPECSTREAM_KEY
```

Khoj searches with Exa whenever `EXA_API_KEY` is set, so set only one of the two keys.

## Reading web pages

Khoj can also read the pages it finds through the Extract API. In the Khoj admin panel, open **Web scrapers** and add one: **Type** Firecrawl, your key in **Api key**, and this in **Api url**:

Api url

```text
https://api.specstream.ai/firecrawl
```

## Check it works

In a chat, start your message with `/online` and ask about something from this week. The answer lists the pages it read as references.

## Cost

Each search is one Search API call at $5 per 1,000 searches of up to 10 results. It comes out of your balance, with no quote and no approval. [Search API](https://specstream.ai/docs/search-api.md) has the details.

Khoj splits one question into a few searches, and each is one Search API call. Each page read by the web scraper is one Extract API page, at $0.80 per 1,000 pages.

## Your key

[Get your key](https://specstream.ai/workspace/search?route=exa&utm_source=khoj&utm_medium=howto) on the Search API screen of your SpecStream workspace. New accounts start with $10 of credit, no card.

The same setting works in other tools too: [Search API by one setting](https://specstream.ai/docs/integrations/drop-in-search.md).
