Skip to content

feat(search): add Brave Search as an alternative SearchProvider #1982

@amorel

Description

@amorel

Summary

Add Brave Search API as an alternative SearchProvider alongside Serper and Tavily. The provider architecture in apps/desktop/src/main/ai/tools/providers/ is already pluggable (clean SearchProvider interface), making this a straightforward addition.

Motivation

  1. Brave Search is what Claude Code itself uses for its built-in WebSearch tool. However, when Claude Code is invoked programmatically (via the Claude Agent SDK), Anthropic restricts web search access. Since Auto Claude now uses its own independent search tools via the Vercel AI SDK, adding Brave Search as a provider would give users a familiar, battle-tested search backend without any Anthropic restrictions.

  2. Many developers already have a Brave Search API subscription — either through Brave Premium or as a standalone API plan. Supporting it means they don't need to sign up for yet another service (Serper/Tavily).

  3. Free tier available — Brave Search API offers 2,000 free queries/month, which is competitive with Serper's 2,500 one-time free credits.

Proposed Implementation

Create apps/desktop/src/main/ai/tools/providers/brave-search.ts implementing the existing SearchProvider interface:

export class BraveSearchProvider implements SearchProvider {
  readonly name = 'brave';
  async search(query: string, options?: SearchOptions): Promise<SearchResult[]> {
    // GET https://api.search.brave.com/res/v1/web/search?q=...
    // Header: X-Subscription-Token: <BRAVE_SEARCH_API_KEY>
  }
}

Configuration via BRAVE_SEARCH_API_KEY environment variable (same pattern as SERPER_API_KEY and TAVILY_API_KEY).

Update createSearchProvider() in providers/index.ts to select the provider based on which API key is available (with fallback chain: Serper → Brave → Tavily).

API Reference

Scope

  • Create brave-search.ts provider
  • Add BRAVE_SEARCH_API_KEY to .env.example
  • Update provider factory with fallback logic
  • Add tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions