> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aisearchapi.io/llms.txt
> Use this file to discover all available pages before exploring further.

# n8n Node

This is a **custom n8n node** for integrating the **AI Search API** into your automation workflows.\
It brings **semantic search**, **context awareness**, and **balance monitoring** directly into your n8n pipelines.

👉 Get started now:

* [Sign Up](https://app.aisearchapi.io/join)
* [Log In](https://app.aisearchapi.io/login)
* [Dashboard](https://app.aisearchapi.io/dashboard)

***

# Features

* 🔍 **Intelligent Semantic Search** – Natural language queries with embeddings
* 💬 **Context Management** – Add previous messages for richer answers
* 📝 **Flexible Responses** – Markdown or plain text output
* 📊 **Balance Monitoring** – Track credits and usage in real time
* ⚡ **TypeScript Support** – Strong typings and IDE hints
* 🧩 **n8n Ready** – Works as a drag-and-drop node inside your n8n editor

***

# Installation

## From npm (recommended)

```bash theme={null}
npm install n8n-nodes-aisearchapi
```

## From source

```bash theme={null}
git clone https://github.com/aisearchapi/aisearchapi-n8n.git
cd aisearchapi-n8n
npm install
npm run build
```

***

# Run n8n with Your Extension

## Windows PowerShell (edit the path)

```powershell theme={null}
docker run -it --rm -p 5678:5678 `
  -e N8N_CUSTOM_EXTENSIONS=/extensions `
  -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true `
  -e DB_SQLITE_POOL_SIZE=5 `
  -e N8N_RUNNERS_ENABLED=true `
  -v "C:\n8n-extensions\aisearchapi-n8n:/extensions" `
  -v n8n_data:/home/node/.n8n `
  n8nio/n8n:latest
```

## macOS / Linux / WSL (edit the path)

```bash theme={null}
docker run -it --rm -p 5678:5678   -e N8N_CUSTOM_EXTENSIONS=/extensions   -e N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true   -e DB_SQLITE_POOL_SIZE=5   -e N8N_RUNNERS_ENABLED=true   -v "$HOME/n8n-extensions/aisearchapi-n8n:/extensions"   -v n8n_data:/home/node/.n8n   n8nio/n8n:latest
```

Then open: [http://localhost:5678](http://localhost:5678)\
You should see: `Loaded extensions from /extensions`

***

# Configuration in n8n

1. Go to **Credentials → New → AI Search API**
2. Paste your **API Key** (without the `Bearer` prefix)
3. Save credentials

***

# Usage

## Search

* **Resource:** Search
* **Operation:** Search
* **Parameters:**
  * `query` → your question (required)
  * `responseType` → `markdown | text`
  * `context` → optional array of messages
  * `timeout` → ms (default 30000)

## Balance

* **Resource:** Account
* **Operation:** Get Balance

***

# Error Codes

| Code | Meaning           | Fix                         |
| ---- | ----------------- | --------------------------- |
| 401  | Unauthorized      | Invalid key → Get a new key |
| 429  | Too Many Requests | Slow down / add retry logic |
| 433  | Quota Exceeded    | Buy credits / upgrade       |
| 500  | Server Error      | Try again later             |
| 503  | Service Down      | Temporary downtime          |

***

# Development

```bash theme={null}
git clone https://github.com/aisearchapi/aisearchapi-n8n.git
cd aisearchapi-n8n
npm install
npm run build
```

You should see compiled files:

* `dist/credentials/AiSearchApi.credentials.js`
* `dist/nodes/AiSearchApi/AiSearchApi.node.js`

**package.json important parts:**

```json theme={null}
{
  "name": "n8n-nodes-aisearchapi",
  "version": "0.1.0",
  "main": "dist/index.js",
  "files": ["dist", "README.md", "LICENSE"],
  "keywords": ["n8n", "n8n-community-node-package", "AI Search API", "semantic search", "automation"],
  "n8n": {
    "nodes": ["dist/nodes/AiSearchApi/AiSearchApi.node.js"],
    "credentials": ["dist/credentials/AiSearchApi.credentials.js"]
  }
}
```

***

# TypeScript Config

CommonJS build to avoid ESM issues:

```json theme={null}
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "moduleResolution": "Node",
    "lib": ["ES2020"],
    "outDir": "./dist",
    "rootDir": ".",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "allowSyntheticDefaultImports": true,
    "resolveJsonModule": true
  },
  "include": ["credentials/**/*", "nodes/**/*"],
  "exclude": ["node_modules", "dist", "**/*.spec.ts"]
}
```

***

# Logos / Icons

Put your SVGs in:

* `nodes/AiSearchApi/aisearchapi.svg`
* `credentials/aisearchapi.svg`

Build script copies them next to compiled files in `dist/...`

***

# Best Practices

* Keep your API key secret (use n8n Credentials)
* Use **Markdown** output for rich UI
* Reset context when changing topics
* Watch your credits with the **balance endpoint**

***

# Troubleshooting

* **Node not visible in n8n** → Check build files exist, restart Docker, verify mounted path
* **Cannot find package 'n8n-workflow'** → Install it: `npm i n8n-workflow@1.108.2`
* **Build issues on Windows** → Use `shx` for copy operations instead of `cp`

***

# Resources

* [AI Search API Homepage](https://aisearchapi.io)
* [Sign Up](https://app.aisearchapi.io/join) | [Log In](https://app.aisearchapi.io/login) | [Dashboard](https://app.aisearchapi.io/dashboard)
* [GitHub Issues](https://github.com/aisearchapi/aisearchapi-n8n/issues)
* [npm Package](https://www.npmjs.com/package/n8n-nodes-aisearchapi)
* [Blog](https://aisearchapi.io/blog)

***

# Start Now

Install and connect your API key in n8n, then start building AI-powered workflows:

```bash theme={null}
npm install n8n-nodes-aisearchapi
```

***
