Skip to content

feat: update Exa integration with tracking header and current API params#1312

Open
tgonzalezc5 wants to merge 1 commit intokhoj-ai:masterfrom
tgonzalezc5:feat/update-exa-integration
Open

feat: update Exa integration with tracking header and current API params#1312
tgonzalezc5 wants to merge 1 commit intokhoj-ai:masterfrom
tgonzalezc5:feat/update-exa-integration

Conversation

@tgonzalezc5
Copy link
Copy Markdown

Summary

  • Add x-exa-integration: khoj tracking header to both search_with_exa() and read_webpage_with_exa() for API usage attribution
  • Replace deprecated numSentences/highlightsPerUrl highlights parameters with maxCharacters per current Exa API docs
  • Remove deprecated livecrawl parameter from the contents endpoint (omitting it preserves the same fallback behavior)
  • Add unit tests for Exa search response parsing, snippet fallback, header verification, and deprecated param removal

Usage

No configuration changes required. Existing EXA_API_KEY env var continues to work as before.

# Search (unchanged interface, updated internals)
query, results = await search_with_exa("latest AI news", location)
# results["organic"][0] -> {"title": ..., "link": ..., "snippet": ..., "content": ...}

# Webpage reading (unchanged interface)
text = await read_webpage_with_exa("https://example.com", api_key, api_url)

Files changed

  • src/khoj/processor/tools/online_search.py -- updated Exa API headers and request params
  • tests/test_exa_search.py -- new unit tests for Exa search and webpage reading

Test plan

  • Verify x-exa-integration: khoj header is sent in search requests
  • Verify x-exa-integration: khoj header is sent in contents requests
  • Verify maxCharacters is used instead of deprecated numSentences/highlightsPerUrl
  • Verify livecrawl param is no longer sent in contents requests
  • Verify search result parsing with highlights, text content, and missing highlights
  • Verify empty results and API errors return empty dict gracefully
  • Verify location defaults to "US" when country_code is None
  • Full test suite requires Django/database setup (CI)

- Add x-exa-integration: khoj tracking header to search and contents requests
- Replace deprecated numSentences/highlightsPerUrl with maxCharacters
- Remove deprecated livecrawl param from contents endpoint
- Add unit tests for Exa search and webpage reading

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant