Skip to content

feat(exa): align Exa client with current API conventions#689

Open
tgonzalezc5 wants to merge 1 commit intothunderbird:mainfrom
tgonzalezc5:exa-search-conventions-update
Open

feat(exa): align Exa client with current API conventions#689
tgonzalezc5 wants to merge 1 commit intothunderbird:mainfrom
tgonzalezc5:exa-search-conventions-update

Conversation

@tgonzalezc5
Copy link
Copy Markdown

@tgonzalezc5 tgonzalezc5 commented Apr 19, 2026

Summary

Three small adjustments to backend/src/pro/exa.ts to align with the current Exa API reference (https://exa.ai/docs/reference/search) and improve observability:

  • Drop useAutoprompt: true from /search options. The parameter is no longer documented in the current Exa API reference; type: 'fast' is preserved so latency behavior is unchanged.
  • Add maxAgeHours: 24 to getContents. maxAgeHours is the documented successor to the now-deprecated livecrawl enum and lets the API serve cached content under 24h old while still live-crawling older pages within the existing livecrawlTimeout.
  • Set x-exa-integration: thunderbolt header on the Exa client. This lets the Exa team attribute API usage to this repository, which helps with support and tracking integration health. No behavior change for end users.

Code

// client construction now goes through a small helper so the header is always set
export const createExaClient = (apiKey: string): Exa => {
  const client = new Exa(apiKey)
  ;(client as unknown as { headers: Headers }).headers.set('x-exa-integration', 'thunderbolt')
  return client
}

// search no longer sends the undocumented useAutoprompt flag
await client.search(query, { numResults: 10, type: 'fast' })

// getContents uses the documented maxAgeHours freshness control
await client.getContents([url], {
  livecrawlTimeout: 5_000,
  maxAgeHours: 24,
  extras: { imageLinks: 1 },
  text: { maxCharacters },
})

Notes

  • exa-js v1.10.2 does not yet type maxAgeHours, so a narrow ContentsOptions & { maxAgeHours?: number } type is used at the call site. The SDK spreads unknown options into the request body, so the field reaches the API unchanged.
  • The headers property on the Exa class is marked private in the SDK types but is a runtime Headers instance. The as unknown as { headers: Headers } cast is intentional and documented inline.

Files changed

  • backend/src/pro/exa.ts — drop useAutoprompt, add maxAgeHours, extract createExaClient helper that sets x-exa-integration.
  • backend/src/pro/exa.test.ts — update existing assertions, add tests for the new header and for the absence of useAutoprompt.

Test plan

  • bun test src/pro/exa.test.ts — 27/27 pass (up from 25, added 2 new tests).
  • bun run type-check — no new errors introduced (pre-existing @types/react resolution errors in unrelated files are unchanged).
  • Manual smoke test against a real EXA_API_KEY — not run locally; verifying on a deployment would confirm the attribution header reaches Exa.

Note

Low Risk
Low risk: small request-option tweaks and an extra attribution header, with coverage added/updated in tests. Main risk is subtle behavior change in Exa search/content freshness due to dropping useAutoprompt and introducing caching via maxAgeHours.

Overview
Aligns the Exa integration with the current API by removing the undocumented useAutoprompt flag from /search requests.

Updates /fetch-content calls to include maxAgeHours: 24 (typed via a narrow ContentsOptions extension) to prefer cached results while keeping the existing livecrawlTimeout.

Adds a createExaClient helper that sets x-exa-integration: thunderbolt on the Exa client, and updates/extends tests to assert the new options/header behavior.

Reviewed by Cursor Bugbot for commit b6abb57. Bugbot is set up for automated code reviews on this repo. Configure here.

- Drop `useAutoprompt: true` from search options — no longer documented
  in the `/search` reference. `type: 'fast'` is preserved for low latency.
- Add `maxAgeHours: 24` to `getContents` options — the documented
  successor to the deprecated `livecrawl` enum. Pages cached within the
  last 24 hours are served as-is; older pages trigger a live crawl
  bounded by the existing `livecrawlTimeout`.
- Set `x-exa-integration: thunderbolt` on the Exa client so the Exa
  team can attribute API usage to this repository.

Extract client construction into `createExaClient` so the header
attachment is testable. Tests cover the new header, the absence of
`useAutoprompt`, and the `maxAgeHours` parameter on all `getContents`
call-site assertions.
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

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