Exa는 AI와 개발자를 위한 지식 API입니다.

Installation and Setup

Exa integration은 자체 partner package로 존재합니다. 다음과 같이 설치할 수 있습니다:
pip install -qU langchain-exa
패키지를 사용하려면 EXA_API_KEY 환경 변수를 Exa API key로 설정해야 합니다.

Retriever

표준 retrieval pipeline에서 ExaSearchRetriever를 사용할 수 있습니다. 다음과 같이 import할 수 있습니다. 사용 예제를 참조하세요.
from langchain_exa import ExaSearchRetriever

Tools

Exa tool calling 문서에 설명된 대로 Exa를 agent tool로 사용할 수 있습니다. 사용 예제를 참조하세요.

ExaFindSimilarResults

Metaphor Search API를 쿼리하고 JSON을 반환하는 tool입니다.
from langchain_exa.tools import ExaFindSimilarResults

ExaSearchResults

Exa Search tool입니다.
from langchain_exa.tools import ExaSearchResults

Exa Search Retriever

다음과 같이 검색 결과를 검색할 수 있습니다
from langchain_exa import ExaSearchRetriever

exa_api_key = "YOUR API KEY"

# Create a new instance of the ExaSearchRetriever
exa = ExaSearchRetriever(exa_api_key=exa_api_key)

# Search for a query and save the results
results  = exa.invoke("What is the capital of France?")

# Print the results
print(results)

Advanced Features

텍스트 제한, 요약, 실시간 크롤링과 같은 고급 기능을 사용할 수 있습니다:
from langchain_exa import ExaSearchRetriever, TextContentsOptions

# Create a new instance with advanced options
exa = ExaSearchRetriever(
    exa_api_key="YOUR API KEY",
    k=20,  # Number of results (1-100)
    type="auto",  # Can be "neural", "keyword", or "auto"
    livecrawl="always",  # Can be "always", "fallback", or "never"
    summary=True,  # Get an AI-generated summary of each result
    text_contents_options={"max_characters": 3000}  # Limit text length
)

# Search for a query with custom summary prompt
exa_with_custom_summary = ExaSearchRetriever(
    exa_api_key="YOUR API KEY",
    summary={"query": "generate one line summary in simple words."}  # Custom summary prompt
)

Exa Search Results

다음과 같이 ExaSearchResults module을 실행할 수 있습니다
from langchain_exa import ExaSearchResults

# Initialize the ExaSearchResults tool
search_tool = ExaSearchResults(exa_api_key="YOUR API KEY")

# Perform a search query
search_results = search_tool._run(
    query="When was the last time the New York Knicks won the NBA Championship?",
    num_results=5,
    text_contents_options=True,
    highlights=True
)

print("Search Results:", search_results)

Exa Find Similar Results

다음과 같이 ExaFindSimilarResults module을 실행할 수 있습니다
from langchain_exa import ExaFindSimilarResults

# Initialize the ExaFindSimilarResults tool
find_similar_tool = ExaFindSimilarResults(exa_api_key="YOUR API KEY")

# Find similar results based on a URL
similar_results = find_similar_tool._run(
    url="http://espn.com",
    num_results=5,
    text_contents_options=True,
    highlights=True
)

print("Similar Results:", similar_results)

Configuration Options

모든 Exa tool은 다음과 같은 공통 parameter를 지원합니다:
  • num_results (1-100): 반환할 검색 결과 수
  • type: 검색 타입 - “neural”, “keyword”, 또는 “auto”
  • livecrawl: 실시간 크롤링 모드 - “always”, “fallback”, 또는 “never”
  • summary: AI 생성 요약 가져오기 (True/False 또는 custom prompt dict)
  • text_contents_options: 텍스트 길이를 제한하는 Dict (예: {"max_characters": 2000})
  • highlights: 강조 표시된 텍스트 snippet 포함 (True/False)

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I