exa-security-basics
Guidelines for securing Exa API keys and implementing content filtering.
Install
mkdir -p .claude/skills/exa-security-basics && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5337" && unzip -o skill.zip -d .claude/skills/exa-security-basics && rm skill.zipInstalls to .claude/skills/exa-security-basics
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Secure Exa API keys, implement content moderation, and manage domainKey capabilities
- →Manage Exa API keys securely
- →Enable content moderation for search results
- →Filter search results by trusted or blocked domains
- →Sanitize user-provided queries
- →Isolate API keys per environment
- →Scan Git history for leaked keys
How it works
The skill outlines security best practices for Exa API integrations, covering API key protection, content moderation, domain filtering, and query sanitization.
Inputs & outputs
When to use exa-security-basics
- →Configuring secure environment variables
- →Implementing content moderation filters
- →Auditing API key configuration
About this skill
Exa Security Basics
Overview
Security best practices for Exa API integrations. Exa authenticates via the x-api-key header. Key security concerns include API key protection, content moderation for search results, domain filtering to prevent exposure to malicious sources, and query sanitization.
Prerequisites
- Exa API key from dashboard.exa.ai
- Understanding of environment variable management
.gitignoreconfigured for secrets
Instructions
Step 1: API Key Management
# .env (NEVER commit to git)
EXA_API_KEY=your-api-key-here
# .gitignore — add these entries
.env
.env.local
.env.*.local
// Validate API key exists before creating client
import Exa from "exa-js";
function createSecureClient(): Exa {
const apiKey = process.env.EXA_API_KEY;
if (!apiKey) {
throw new Error("EXA_API_KEY not configured");
}
if (apiKey.startsWith("sk_") && apiKey.length < 20) {
throw new Error("EXA_API_KEY appears malformed");
}
return new Exa(apiKey);
}
Step 2: Enable Content Moderation
const exa = new Exa(process.env.EXA_API_KEY);
// Exa supports content moderation to filter unsafe results
const results = await exa.searchAndContents(
"user-provided search query",
{
numResults: 10,
text: true,
moderation: true, // filter unsafe content from results
}
);
Step 3: Domain Filtering for Safety
// Restrict results to trusted domains for sensitive use cases
const TRUSTED_DOMAINS = [
"docs.python.org", "developer.mozilla.org", "nodejs.org",
"github.com", "stackoverflow.com", "arxiv.org",
];
const BLOCKED_DOMAINS = [
"known-malware-site.com", "phishing-domain.net",
];
async function safeDomainSearch(query: string) {
return exa.searchAndContents(query, {
numResults: 10,
includeDomains: TRUSTED_DOMAINS, // only return results from these
text: { maxCharacters: 1000 },
});
}
async function searchWithBlocklist(query: string) {
return exa.searchAndContents(query, {
numResults: 10,
excludeDomains: BLOCKED_DOMAINS, // never return results from these
text: { maxCharacters: 1000 },
});
}
Step 4: Query Sanitization
// Sanitize user-provided queries before sending to Exa
function sanitizeQuery(input: string): string {
// Remove potential injection patterns
let clean = input
.replace(/[<>{}]/g, "") // strip HTML/template chars
.replace(/\0/g, "") // remove null bytes
.trim()
.substring(0, 500); // cap query length
if (!clean || clean.length < 2) {
throw new Error("Query too short or empty after sanitization");
}
return clean;
}
// Usage
const userQuery = sanitizeQuery(req.body.query);
const results = await exa.search(userQuery, {
numResults: 10,
moderation: true,
});
Step 5: Per-Environment Key Isolation
// Use separate API keys per environment
const KEY_MAP: Record<string, string> = {
development: process.env.EXA_API_KEY_DEV!,
staging: process.env.EXA_API_KEY_STAGING!,
production: process.env.EXA_API_KEY_PROD!,
};
function getExaForEnv(): Exa {
const env = process.env.NODE_ENV || "development";
const key = KEY_MAP[env];
if (!key) throw new Error(`No EXA key for ${env}`);
return new Exa(key);
}
Security Checklist
- API key stored in environment variables (never hardcoded)
-
.envfiles in.gitignore - Separate API keys for dev/staging/production
-
moderation: trueenabled for user-facing search - Query input sanitized before API calls
- Domain allowlist/blocklist applied for sensitive use cases
- API key rotation procedure documented
- Git history scanned for accidentally committed keys
Error Handling
| Security Issue | Detection | Mitigation |
|---|---|---|
| Exposed API key | git log -p search | Rotate key immediately at dashboard.exa.ai |
| Unsafe search results | User reports | Enable moderation: true |
| Untrusted domains | Review result URLs | Apply includeDomains filter |
| Query injection | Input validation | Sanitize before search |
Examples
Scan Git History for Leaked Keys
set -euo pipefail
# Check if API key was ever committed
git log -p --all -S "EXA_API_KEY" -- "*.ts" "*.js" "*.py" "*.env" | head -20
Key Rotation Procedure
set -euo pipefail
# 1. Generate new key in dashboard.exa.ai
# 2. Update environment
export EXA_API_KEY="new-key-here"
# 3. Verify new key works
curl -s -o /dev/null -w "%{http_code}" \
-X POST https://api.exa.ai/search \
-H "x-api-key: $EXA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query":"test","numResults":1}'
# 4. Revoke old key in dashboard
Resources
Next Steps
For production deployment, see exa-prod-checklist.
When not to use it
- →When API keys are hardcoded
- →When .env files are committed to Git
- →When user-provided queries are not sanitized
Prerequisites
Limitations
- →API key must be stored in environment variables, not hardcoded
- →Separate API keys are needed for different environments
- →Query input must be sanitized before API calls
How it compares
This skill provides concrete steps and code examples for securing Exa API integrations, unlike general security guidelines that lack specific implementation details.
Compared to similar skills
exa-security-basics side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| exa-security-basics (this skill) | 1 | 25d | Caution | Intermediate |
| mcp-builder | 136 | 3mo | Review | Advanced |
| telegram-mini-app | 62 | 6mo | Review | Advanced |
| stripe-integration | 48 | 2mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by jeremylongshore
View all by jeremylongshore →You might also like
mcp-builder
anthropics
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
telegram-mini-app
davila7
Expert in building Telegram Mini Apps (TWA) - web apps that run inside Telegram with native-like experience. Covers the TON ecosystem, Telegram Web App API, payments, user authentication, and building viral mini apps that monetize. Use when: telegram mini app, TWA, telegram web app, TON app, mini app.
stripe-integration
wshobson
Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.
copilot-sdk
github
Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent.
nodejs-backend-patterns
wshobson
Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.
chatgpt-app-builder
mcp-use
Build ChatGPT apps with interactive widgets using mcp-use and OpenAI Apps SDK. Use when creating ChatGPT apps, building MCP servers with widgets, defining React widgets, working with Apps SDK, or when user mentions ChatGPT widgets, mcp-use widgets, or Apps SDK development.