> **For coding agents and LLMs:** This is one page from the Social Fetch docs (markdown export). For curated orientation and workflow guidance, start with [`/llms.txt`](https://www.socialfetch.dev/llms.txt); for agent onboarding and crawl rules, use [`/agents.txt`](https://www.socialfetch.dev/agents.txt); for the full endpoint list with links to pages like this one, use [`/llms-endpoints.txt`](https://www.socialfetch.dev/llms-endpoints.txt); for one platform's parameters and curls, use [`/llms-{platform}.txt`](https://www.socialfetch.dev/llms-tiktok.txt); use [`/llms.json`](https://www.socialfetch.dev/llms.json) when you need structured JSON for tool registration.

## This page

- **On-site (HTML):** <https://www.socialfetch.dev/docs/integrations/n8n/ai-agent>
- **Markdown (.mdx) URL:** <https://www.socialfetch.dev/docs/integrations/n8n/ai-agent.mdx>

## API base URL and authentication

- **API origin (from OpenAPI `servers`):** `https://api.socialfetch.dev`
- **Authentication:** send `x-api-key: sfk_...` on `/v1/**` and `/v2/**` routes unless the operation is explicitly anonymous (check OpenAPI `security`, the [API reference hub](https://www.socialfetch.dev/docs/api.mdx), [`/llms.txt`](https://www.socialfetch.dev/llms.txt), or [`/llms.json`](https://www.socialfetch.dev/llms.json) for each route).
- **OpenAPI JSON:** <https://www.socialfetch.dev/openapi.json>

## Recommended docs entrypoints (this site)

- [Documentation overview](https://www.socialfetch.dev/docs.mdx) — top-level orientation (markdown).
- [Quickstart](https://www.socialfetch.dev/docs/quickstart.mdx) — authenticate with `x-api-key`, validate auth with `whoami`, and understand the JSON envelope.
- [SDK](https://www.socialfetch.dev/docs/sdk.mdx) — official TypeScript SDK guide, including `SocialFetchClient`, `Result`, and `unwrap()`.
- [Capability matrix](https://www.socialfetch.dev/docs/capability-matrix.mdx) — every operation with identifiers, pagination, outcomes, media download, credits, and its SDK method. Generated from OpenAPI, so use it for route selection instead of scanning individual pages.
- [Recipes](https://www.socialfetch.dev/docs/recipes.mdx) — copyable workflows (brand monitoring, transcripts, Ad Library, creator scoring, Reddit research) with credit callouts and SDK examples.
- [Integrations](https://www.socialfetch.dev/docs/integrations.mdx) — MCP for AI clients, n8n verified node, Apify Store Actors, Make custom app, SDK, and REST API connection paths.
- [MCP product page](https://www.socialfetch.dev/mcp) — hosted MCP overview, OAuth, Skills install.
- [MCP integration](https://www.socialfetch.dev/docs/integrations/mcp.mdx) — hosted `/mcp` server, OAuth, Cursor/VS Code/Claude install snippets, 264 endpoint tools, plus docs_search/docs_read for implementation help.
- [n8n integration](https://www.socialfetch.dev/docs/integrations/n8n.mdx) — install `n8n-nodes-socialfetch`, credentials, and workflow examples.
- [Apify integration](https://www.socialfetch.dev/docs/integrations/apify.mdx) — Store Actors under @social-fetch, PPE billing, dataset export, and quick start.
- [Make integration](https://www.socialfetch.dev/docs/integrations/make.mdx) — custom app modules for Make scenarios, API key credentials, and module catalog.
- [`/llms-endpoints.txt`](https://www.socialfetch.dev/llms-endpoints.txt) — every documented operation with a direct link to that route's agent-readable markdown page (prefer this over parsing OpenAPI).
- [`/llms-{platform}.txt`](https://www.socialfetch.dev/llms-tiktok.txt) — per-platform endpoint files generated from OpenAPI (parameters, credits, curls).
- [`/agents.txt`](https://www.socialfetch.dev/agents.txt) — agent crawl/onboarding file with capabilities, auth rules, and allowlist.
- [`/llms.json`](https://www.socialfetch.dev/llms.json) — structured machine-readable operation inventory with parameter names, pagination, outcomes, credits, and SDK mapping.
- [API reference hub](https://www.socialfetch.dev/docs/api.mdx) — human-friendly index of operations with links into generated pages.
- [Errors](https://www.socialfetch.dev/docs/errors.mdx) — shared error envelope and HTTP status guidance.
- [Credits](https://www.socialfetch.dev/docs/credits.mdx) — metering, `402`, and planning batch jobs.
- Outcome semantics such as `found`, `not_found`, and `private` are documented in [Errors](https://www.socialfetch.dev/docs/errors.mdx) and on operation pages when present in the OpenAPI contract.

## Markdown docs convention

- Every docs page has a markdown twin: append **`.mdx`** to the docs pathname (for example `/docs/quickstart` → `/docs/quickstart.mdx`).
- Agents that send `Accept: text/markdown` on `/docs/**` HTML URLs may receive markdown directly (same URL, `Vary: Accept`).
- Published blog posts use the same convention: `/blog/{slug}` → `/blog/{slug}.mdx`, or `Accept: text/markdown` on the HTML URL (`Vary: Accept`).

---
# Use Social Fetch with the n8n AI Agent (https://www.socialfetch.dev/docs/integrations/n8n/ai-agent)

n8n's **AI Agent** can call other nodes as tools while it answers. Add Social Fetch as a tool and the agent can look up live profiles, posts, comments and search results instead of guessing, for example "How many followers does @nasa have on TikTok and Instagram?" or "What are people saying on Reddit about our launch?"

## Add Social Fetch as a tool

1. Add an **AI Agent** node and connect a chat model to it, for example **OpenAI Chat Model**.
2. Click the **+** under the agent's **Tool** input, search for **Social Fetch** and choose an action, for example **Get TikTok profile**.
3. Pick your Social Fetch credential.
4. Under **Tool Description**, choose **Set Manually** and say in plain words what the tool does and when to use it, for example *Get a TikTok profile by handle: bio, followers, likes and video count.* The agent reads this to decide when to call the tool.
5. Next to **Handle**, click the sparkle button, **Let the model define this parameter**. The field changes to *Defined automatically by the model*: the agent fills in the handle from the conversation.

Add one Social Fetch tool per job you want the agent to do: one for TikTok profiles, one for Instagram profiles, one for YouTube channel videos, and so on. Each tool does one thing, which keeps the agent's choices clear.

The [AI research agent template](/docs/integrations/n8n/templates#ai-research-agent) has three tools set up already.

## Tips for good answers

* **Keep Simplify on.** The agent gets the results without page and billing details, which means fewer tokens and fewer mistakes.
* **Fix what doesn't need to change.** If the agent should always look at your own brand, type the handle into the field instead of letting the model define it.
* **Say what the fields mean in the system prompt**, for example *Handles are usernames without the @*. Agents often add an @ or paste a full URL otherwise.
* **Prefer specific tools over general ones.** "Get TikTok profile" is easier for a model to use well than one tool that can do anything.
* **Lists can be long.** Tools that list posts or comments return a page of results. Leave **Return All** off for agents, so one question can't fetch up to 100 pages in a single tool call.

## Credits and limits

Every tool call is a real Social Fetch request and uses credits, the same as running the node in a workflow. An agent may call a tool several times for one question (for example once per account it compares). To keep usage predictable:

* Give the agent only the tools it needs.
* Under the agent's **Options**, set **Max Iterations** to cap how many steps it takes per question.
* Watch usage in your [request log](https://app.socialfetch.dev/requests); each tool call appears there like any other request.

## Self-hosted n8n

On some self-hosted versions, community nodes only appear as agent tools when the environment variable `N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE` is `true`. If Social Fetch is missing from the agent's tool list, set it and restart n8n.

## Prefer to connect an AI app directly?

If you use Claude, ChatGPT, Cursor or another AI app rather than n8n, connect it to Social Fetch's hosted [MCP server](/docs/integrations/mcp) instead. Every Social Fetch operation becomes a tool, with no workflow to build.

## Next steps

- [Workflow templates](/docs/integrations/n8n/templates) — Import the AI research agent and try it.

- [MCP server](/docs/integrations/mcp) — Social Fetch as tools in Claude, ChatGPT and Cursor.

- [Operation catalog](/docs/integrations/n8n/operations) — Every operation you can add as a tool.

- [Troubleshooting](/docs/integrations/n8n/troubleshooting) — Errors and missing tools.