exa-cli
Setup
If exa-cli is not installed, install it from GitHub:
CODEBLOCK0
If exa-cli is not found, install and build it:
CODEBLOCK1
INLINECODE2 adds ~/.local/bin to PATH automatically. The CLI is available in the next command.
Always use --json flag when calling commands programmatically.
Authentication
CODEBLOCK2
Resources
search
| Command | Description |
|---|
| INLINECODE5 | Search web with natural language query |
| INLINECODE6 |
Neural search with custom result count |
|
exa-cli search query --query "SpaceX news" --type keyword --json | Keyword-based search |
|
exa-cli search query --query "AI trends" --start-date 2024-01-01 --json | Search with date filter |
|
exa-cli search query --query "research" --category news --json | Search by category |
|
exa-cli search query --query "frameworks" --include-domains github.com,stackoverflow.com --json | Include specific domains |
|
exa-cli search query --query "news" --exclude-domains twitter.com --json | Exclude specific domains |
|
exa-cli search query --query "topic" --text --json | Include page text in results |
|
exa-cli search query --query "topic" --summary --json | Include AI summary for each result |
|
exa-cli search query --query "topic" --highlights --json | Include text highlights |
|
exa-cli search find-similar --url "https://example.com" --json | Find similar pages to URL |
|
exa-cli search find-similar --url "https://example.com" --num-results 5 --text --json | Find similar with text content |
contents
| Command | Description |
|---|
| INLINECODE17 | Get page contents for URL |
| INLINECODE18 |
Get contents for multiple URLs |
|
exa-cli contents get --urls "https://example.com" --text --json | Get contents with full page text |
|
exa-cli contents get --urls "https://example.com" --summary --json | Get contents with AI summary |
|
exa-cli contents get --urls "https://example.com" --highlights --json | Get contents with text highlights |
answer
| Command | Description |
|---|
| INLINECODE22 | Get AI answer with web citations |
| INLINECODE23 |
Answer with source text included |
|
exa-cli answer query --query "Explain quantum computing" --stream --json | Stream answer response |
context
| Command | Description |
|---|
| INLINECODE25 | Get web context for query |
| INLINECODE26 |
Get context with token limit |
Global Flags
All commands support: --json, --format <text|json|csv|yaml>, --verbose, --no-color, INLINECODE31
exa-cli
设置
如果 exa-cli 未安装,请从 GitHub 安装:
bash
npx api2cli install Melvynx/exa-cli
如果找不到 exa-cli,请安装并构建:
bash
bun --version || curl -fsSL https://bun.sh/install | bash
npx api2cli bundle exa
npx api2cli link exa
api2cli link 会自动将 ~/.local/bin 添加到 PATH 中。CLI 可在下一条命令中使用。
以编程方式调用命令时,始终使用 --json 标志。
身份验证
bash
exa-cli auth set your-token
exa-cli auth test
资源
搜索
| 命令 | 描述 |
|---|
| exa-cli search query --query latest AI research --json | 使用自然语言查询搜索网页 |
| exa-cli search query --query best React frameworks --type neural --num-results 5 --json |
自定义结果数量的神经搜索 |
| exa-cli search query --query SpaceX news --type keyword --json | 基于关键词的搜索 |
| exa-cli search query --query AI trends --start-date 2024-01-01 --json | 带日期过滤器的搜索 |
| exa-cli search query --query research --category news --json | 按类别搜索 |
| exa-cli search query --query frameworks --include-domains github.com,stackoverflow.com --json | 包含特定域名 |
| exa-cli search query --query news --exclude-domains twitter.com --json | 排除特定域名 |
| exa-cli search query --query topic --text --json | 在结果中包含页面文本 |
| exa-cli search query --query topic --summary --json | 为每个结果包含 AI 摘要 |
| exa-cli search query --query topic --highlights --json | 包含文本高亮 |
| exa-cli search find-similar --url https://example.com --json | 查找与 URL 相似的页面 |
| exa-cli search find-similar --url https://example.com --num-results 5 --text --json | 查找相似页面并包含文本内容 |
内容
| 命令 | 描述 |
|---|
| exa-cli contents get --urls https://example.com --json | 获取 URL 的页面内容 |
| exa-cli contents get --urls https://a.com,https://b.com --json |
获取多个 URL 的内容 |
| exa-cli contents get --urls https://example.com --text --json | 获取包含完整页面文本的内容 |
| exa-cli contents get --urls https://example.com --summary --json | 获取包含 AI 摘要的内容 |
| exa-cli contents get --urls https://example.com --highlights --json | 获取包含文本高亮的内容 |
回答
| 命令 | 描述 |
|---|
| exa-cli answer query --query What is the latest valuation of SpaceX? --json | 获取带网络引用的 AI 回答 |
| exa-cli answer query --query Who won the 2024 election? --text --json |
回答并包含来源文本 |
| exa-cli answer query --query Explain quantum computing --stream --json | 流式传输回答响应 |
上下文
| 命令 | 描述 |
|---|
| exa-cli context get --query how to use React hooks --json | 获取查询的网络上下文 |
| exa-cli context get --query Python async await patterns --tokens-num 8000 --json |
获取带令牌限制的上下文 |
全局标志
所有命令支持:--json、--format 、--verbose、--no-color、--no-header