!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}(),document.documentElement.setAttribute("data-announcement-bar-initially-dismissed",function(){try{return"true"===localStorage.getItem("docusaurus.announcement.dismiss")}catch(t){}return!1}())

[Skip to main content](#__docusaurus_skipToContent_fallback)

You are viewing the **preview** v0.2 docs. View the **stable** v0.1 docs [here](/v0.1/docs/get_started/introduction/). Leave feedback on the v0.2 docs [here](https://github.com/langchain-ai/langchainjs/discussions/5386).

[

![🦜️🔗 Langchain](/v0.2/img/brand/wordmark.png)![🦜️🔗 Langchain](/v0.2/img/brand/wordmark-dark.png)

](/v0.2/)[Integrations](/v0.2/docs/integrations/platforms/)[API Reference](https://v02.api.js.langchain.com)

[More](#)

*   [People](/v0.2/docs/people/)
*   [Community](/v0.2/docs/community)
*   [Tutorials](/v0.2/docs/additional_resources/tutorials)
*   [Contributing](/v0.2/docs/contributing)

[v0.2](#)

*   [v0.2](/v0.2/docs/introduction)
*   [v0.1](https://js.langchain.com/v0.1/docs/get_started/introduction)

[🦜🔗](#)

*   [LangSmith](https://smith.langchain.com)
*   [LangSmith Docs](https://docs.smith.langchain.com)
*   [LangChain Hub](https://smith.langchain.com/hub)
*   [LangServe](https://github.com/langchain-ai/langserve)
*   [Python Docs](https://python.langchain.com/)

[Chat](https://chatjs.langchain.com)[](https://github.com/langchain-ai/langchainjs)

Search

*   [Providers](/v0.2/docs/integrations/platforms/)
    
    *   [Providers](/v0.2/docs/integrations/platforms/)
    *   [Anthropic](/v0.2/docs/integrations/platforms/anthropic)
    *   [AWS](/v0.2/docs/integrations/platforms/aws)
    *   [Google](/v0.2/docs/integrations/platforms/google)
    *   [Microsoft](/v0.2/docs/integrations/platforms/microsoft)
    *   [OpenAI](/v0.2/docs/integrations/platforms/openai)
*   [Components](/v0.2/docs/integrations/components)
    
    *   [Chat models](/v0.2/docs/integrations/chat/)
        
    *   [LLMs](/v0.2/docs/integrations/llms/)
        
    *   [Embedding models](/v0.2/docs/integrations/text_embedding)
        
    *   [Document loaders](/v0.2/docs/integrations/document_loaders)
        
    *   [Document transformers](/v0.2/docs/integrations/document_transformers)
        
    *   [Vector stores](/v0.2/docs/integrations/vectorstores)
        
    *   [Retrievers](/v0.2/docs/integrations/retrievers)
        
        *   [Knowledge Bases for Amazon Bedrock](/v0.2/docs/integrations/retrievers/bedrock-knowledge-bases)
        *   [Chaindesk Retriever](/v0.2/docs/integrations/retrievers/chaindesk-retriever)
        *   [ChatGPT Plugin Retriever](/v0.2/docs/integrations/retrievers/chatgpt-retriever-plugin)
        *   [Dria Retriever](/v0.2/docs/integrations/retrievers/dria)
        *   [Exa Search](/v0.2/docs/integrations/retrievers/exa)
        *   [HyDE Retriever](/v0.2/docs/integrations/retrievers/hyde)
        *   [Amazon Kendra Retriever](/v0.2/docs/integrations/retrievers/kendra-retriever)
        *   [Metal Retriever](/v0.2/docs/integrations/retrievers/metal-retriever)
        *   [Supabase Hybrid Search](/v0.2/docs/integrations/retrievers/supabase-hybrid)
        *   [Tavily Search API](/v0.2/docs/integrations/retrievers/tavily)
        *   [Time-Weighted Retriever](/v0.2/docs/integrations/retrievers/time-weighted-retriever)
        *   [Vector Store](/v0.2/docs/integrations/retrievers/vectorstore)
        *   [Vespa Retriever](/v0.2/docs/integrations/retrievers/vespa-retriever)
        *   [Zep Retriever](/v0.2/docs/integrations/retrievers/zep-retriever)
    *   [Tools](/v0.2/docs/integrations/tools)
        
    *   [Toolkits](/v0.2/docs/integrations/toolkits)
        
    *   [Stores](/v0.2/docs/integrations/stores/)
        

*   [](/v0.2/)
*   [Components](/v0.2/docs/integrations/components)
*   [Retrievers](/v0.2/docs/integrations/retrievers)
*   Exa Search

On this page

Exa Search
==========

The Exa Search API provides a new search experience designed for LLMs.

Usage[​](#usage "Direct link to Usage")
---------------------------------------

First, install the LangChain integration package for Exa:

tip

See [this section for general instructions on installing integration packages](/v0.2/docs/how_to/installation#installing-integration-packages).

*   npm
*   Yarn
*   pnpm

    npm install @langchain/exa

    yarn add @langchain/exa

    pnpm add @langchain/exa

You'll need to set your API key as an environment variable.

The `Exa` class defaults to `EXASEARCH_API_KEY` when searching for your API key.

    import { ExaRetriever } from "@langchain/exa";import Exa from "exa-js";const retriever = new ExaRetriever({  // @ts-expect-error Some TS Config's will cause this to give a TypeScript error, even though it works.  client: new Exa(    process.env.EXASEARCH_API_KEY // default API key  ),});const retrievedDocs = await retriever.invoke(  "What did the speaker say about Justice Breyer in the 2022 State of the Union?");console.log(retrievedDocs);/*[  Document {    pageContent: undefined,    metadata: {      title: '2022 State of the Union Address | The White House',      url: 'https://www.whitehouse.gov/state-of-the-union-2022/',      publishedDate: '2022-02-25',      author: null,      id: 'SW3SLghgYTLQKnqBC-6ftQ',      score: 0.163949653506279    }  },  Document {    pageContent: undefined,    metadata: {      title: "Read: Justice Stephen Breyer's White House remarks after announcing his retirement | CNN Politics",      url: 'https://www.cnn.com/2022/01/27/politics/transcript-stephen-breyer-retirement-remarks/index.html',      publishedDate: '2022-01-27',      author: 'CNN',      id: 'rIeqmU1L9sd28wGrqefRPA',      score: 0.1638609766960144    }  },  Document {    pageContent: undefined,    metadata: {      title: 'Sunday, January 22, 2023 - How Appealing',      url: 'https://howappealing.abovethelaw.com/2023/01/22/',      publishedDate: '2023-01-22',      author: null,      id: 'aubLpkpZWoQSN-he-hwtRg',      score: 0.15869899094104767    }  },  Document {    pageContent: undefined,    metadata: {      title: "Noting Past Divisions Retiring Justice Breyer Says It's Up to Future Generations to Make American Experiment Work",      url: 'https://www.c-span.org/video/?517531-1/noting-past-divisions-retiring-justice-breyer-future-generations-make-american-experiment-work',      publishedDate: '2022-01-27',      author: null,      id: '8pNk76nbao23bryEMD0u5g',      score: 0.15786601603031158    }  },  Document {    pageContent: undefined,    metadata: {      title: 'Monday, January 24, 2022 - How Appealing',      url: 'https://howappealing.abovethelaw.com/2022/01/24/',      publishedDate: '2022-01-24',      author: null,      id: 'pt6xlioR4bdm8kSJUQoyPA',      score: 0.1542145311832428    }  },  Document {    pageContent: undefined,    metadata: {      title: "Full transcript of Biden's State of the Union address",      url: 'https://www.axios.com/2023/02/08/sotu-2023-biden-transcript?utm_source=twitter&utm_medium=social&utm_campaign=editorial&utm_content=politics',      publishedDate: '2023-02-08',      author: 'Axios',      id: 'Dg5JepEwPwAMjgnSA_Z_NA',      score: 0.15383175015449524    }  },  Document {    pageContent: undefined,    metadata: {      title: "Read Justice Breyer's remarks on retiring and his hope in the American 'experiment'",      url: 'https://www.npr.org/2022/01/27/1076162088/read-stephen-breyer-retirement-supreme-court',      publishedDate: '2022-01-27',      author: 'NPR Staff',      id: 'WDKA1biLMREo3BsOs95SIw',      score: 0.14877735078334808    }  },  Document {    pageContent: undefined,    metadata: {      title: 'Grading My 2021 Predictions',      url: 'https://astralcodexten.substack.com/p/grading-my-2021-predictions',      publishedDate: '2022-01-24',      author: 'Scott Alexander',      id: 'jPutj4IcqgAiKSs6-eqv3g',      score: 0.14813132584095    }  },  Document {    pageContent: undefined,    metadata: {      title: '',      url: 'https://www.supremecourt.gov/oral_arguments/argument_transcripts/2021/21a240_l537.pdf',      author: null,      id: 'p97vY-5yvA2kBB9nl-7B3A',      score: 0.14450226724147797    }  },  Document {    pageContent: undefined,    metadata: {      title: 'Remarks by President Biden at a Political Event | Charleston, SC',      url: 'https://www.whitehouse.gov/briefing-room/speeches-remarks/2024/01/08/remarks-by-president-biden-at-a-political-event-charleston-sc/',      publishedDate: '2024-01-08',      author: 'The White House',      id: 'ZdPbaacRn8bgwDWv_aA6zg',      score: 0.14446410536766052    }  }]*/

#### API Reference:

*   [ExaRetriever](https://v02.api.js.langchain.com/classes/langchain_exa.ExaRetriever.html) from `@langchain/exa`

* * *

#### Was this page helpful?

  

#### You can leave detailed feedback [on GitHub](https://github.com/langchain-ai/langchainjs/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E).

[

Previous

Dria Retriever

](/v0.2/docs/integrations/retrievers/dria)[

Next

HyDE Retriever

](/v0.2/docs/integrations/retrievers/hyde)

*   [Usage](#usage)

Community

*   [Discord](https://discord.gg/cU2adEyC7w)
*   [Twitter](https://twitter.com/LangChainAI)

GitHub

*   [Python](https://github.com/langchain-ai/langchain)
*   [JS/TS](https://github.com/langchain-ai/langchainjs)

More

*   [Homepage](https://langchain.com)
*   [Blog](https://blog.langchain.dev)

Copyright © 2024 LangChain, Inc.