Skip to main content

Exa

Give agents tools to search the web, read page contents, and answer questions with cited sources in Exa through Mastra Connect. Each tool call goes through the Mastra platform, which adds the connection's credential. Your application never stores Exa credentials.

Connect
Direct link to Connect

Before you start, complete the Connect setup to install @mastra/connect and configure your platform project.

note

Exa bills each search, contents, and answer call to the API key on the connection. The deep search types run multi-step searches that take several seconds and cost more than auto or lite.

Connect an account
Direct link to Connect an account

Run this command from the directory that contains your .env file:

mastra connect add exa

The CLI guides you through Exa's authorization and waits until the connection is active.

Add tools to an agent
Direct link to Add tools to an agent

Pass tools() to the agent and select the exa provider:

src/mastra/agents/exa-agent.ts
import { Agent } from '@mastra/core/agent'
import { tools } from '@mastra/connect'

export const exaAgent = new Agent({
id: 'exa-agent',
name: 'Exa agent',
instructions:
'You help people search the web, read page contents, and answer questions with cited sources in Exa.',
model: 'openai/gpt-6-luna',
tools: tools({ providers: ['exa'] }),
})

The agent gets 3 Exa tools, with keys such as exa_answer. See Exa tools for the full list, and the tools() parameters to restrict tools or require approval before a call runs.

On this page