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

# n8n Integration

> Automate AI workflows with AnyAPI and n8n's visual workflow builder

# n8n Integration

n8n is a workflow automation platform that lets you connect AI models with hundreds of apps and services. The AnyAPI community node gives you direct access to 300+ AI models inside n8n — no code required.

## Overview

The AnyAPI node for n8n supports:

<CardGroup cols={2}>
  <Card title="Chat Completions" icon="message">
    Send messages to GPT-4o, Claude, Gemini, Llama, and more
  </Card>

  <Card title="Web Search" icon="globe">
    Ground model responses with real-time web search
  </Card>

  <Card title="Image Generation" icon="image">
    Create images with DALL-E, Stable Diffusion, and others
  </Card>

  <Card title="Embeddings" icon="vector-square">
    Generate text embeddings for semantic search and RAG
  </Card>
</CardGroup>

### Advanced Capabilities

* **Function Calling** — Let models call external tools and APIs
* **Reasoning** — Extended thinking for complex tasks (o1, Claude with thinking)
* **Prompt Caching** — Reduce latency and cost on repeated prompts
* **Streaming** — Stream responses for real-time output
* **Assistant Prefill** — Guide model output by prefilling the response
* **URL Context** — Fetch and include web page content as context

## Installation

1. Open any workflow in n8n
2. Click **+** to open the nodes panel
3. Search for **AnyAPI**
4. Click **Install** on the community node

<Info>
  For self-hosted n8n, you can also install via **Settings > Community Nodes** and enter `n8n-nodes-anyapi.ai`.
</Info>

## Setup

### Create Credentials

1. Add an **AnyAPI** node to your workflow
2. Click **Credential to connect with** > **Create New Credential**
3. Enter your API key from the [AnyAPI Dashboard](https://dash.anyapi.ai/?page=api-keys)
4. Base URL defaults to `https://api.anyapi.ai/v1`
5. Click **Test** to verify the connection

## Quick Start

### Chat Completion

The simplest workflow — send a message and get a response:

1. Add a **Manual Trigger** node
2. Add an **AnyAPI** node and connect it
3. Set Resource to **Chat**, Operation to **Complete**
4. Choose a model (e.g. `openai/gpt-4o`)
5. Add a message with Role **User** and your prompt
6. Click **Test workflow**

### Example: Scheduled Summary

Generate a daily summary of your data on a schedule:

```
[Schedule Trigger] → [HTTP Request: fetch data] → [AnyAPI: summarize] → [Slack: post message]
```

### Example: Webhook AI Endpoint

Expose an AI-powered API endpoint:

```
[Webhook] → [AnyAPI: process request] → [Respond to Webhook]
```

## Resources

### Chat Completions

| Parameter             | Description                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------ |
| **Model**             | Model ID (e.g. `openai/gpt-4o`, `anthropic/claude-sonnet-4-20250514`, `google/gemini-2.0-flash`) |
| **Messages**          | List of messages with role (System, User, Assistant) and content                                 |
| **Simplified Output** | Return only the message content instead of the full API response                                 |

### Chat Options

<AccordionGroup>
  <Accordion title="Temperature">
    Sampling temperature from 0 to 2. Lower values make output more focused and deterministic, higher values make it more creative.
  </Accordion>

  <Accordion title="Max Tokens">
    Maximum number of tokens to generate in the response.
  </Accordion>

  <Accordion title="Web Search">
    Enable web search grounding. The model can search the web for up-to-date information. Configure **Web Search Context Size** (Low, Medium, High) to control how much context is included.
  </Accordion>

  <Accordion title="URL Context">
    Provide a URL to fetch and include as context. Useful for summarizing web pages or using web content as reference.
  </Accordion>

  <Accordion title="Function Calling">
    Pass a JSON array of tool definitions. The model can decide to call these tools based on the conversation.

    ```json theme={"system"}
    [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get current weather for a location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": { "type": "string" }
            },
            "required": ["location"]
          }
        }
      }
    ]
    ```
  </Accordion>

  <Accordion title="Tool Choice">
    Control how the model uses tools: **Auto** (model decides), **None** (no tool use), **Required** (must use a tool).
  </Accordion>

  <Accordion title="Parallel Function Calling">
    Allow the model to call multiple functions in a single turn. Enabled by default.
  </Accordion>

  <Accordion title="Reasoning">
    Enable extended thinking for complex tasks. Supported by models like `openai/o1`, `anthropic/claude-sonnet-4-20250514` with thinking. Set **Reasoning Budget** to control max tokens for thinking steps.
  </Accordion>

  <Accordion title="Prompt Caching">
    Cache repeated prompts to reduce latency and cost. Especially useful for system prompts and few-shot examples that don't change between requests.
  </Accordion>

  <Accordion title="Streaming">
    Stream the response. n8n will collect the full streamed response and return it as a single output.
  </Accordion>

  <Accordion title="Assistant Prefill">
    Start the assistant's response with specific text. The model will continue from where you left off. Supported by Anthropic models.
  </Accordion>

  <Accordion title="JSON Mode">
    Force the model to output valid JSON. Useful when you need structured data for downstream nodes.
  </Accordion>

  <Accordion title="Trace ID">
    Custom trace ID for tracking requests in the [AnyAPI Dashboard](https://dash.anyapi.ai). Useful for debugging workflows.
  </Accordion>
</AccordionGroup>

### Embeddings

| Parameter      | Description                                               |
| -------------- | --------------------------------------------------------- |
| **Model**      | Embedding model ID (e.g. `openai/text-embedding-3-small`) |
| **Input Text** | Text to generate embeddings for                           |

### Image Generation

| Parameter            | Description                                           |
| -------------------- | ----------------------------------------------------- |
| **Model**            | Image model ID (e.g. `google/gemini-2.5-flash-image`) |
| **Prompt**           | Text description of the image                         |
| **Size**             | Image dimensions (256x256 to 1792x1024)               |
| **Quality**          | Standard or HD                                        |
| **Number of Images** | How many images to generate (1-10)                    |

### Model Listing

Returns all available models on AnyAPI. Useful for dynamic model selection in workflows.

## Workflow Examples

### AI Content Pipeline

Automate content creation with multiple AI steps:

```
[Schedule Trigger]
    → [HTTP Request: fetch topics from CMS]
    → [AnyAPI: generate outline (Claude)]
    → [AnyAPI: write draft (GPT-4o)]
    → [AnyAPI: review and edit (Claude)]
    → [Google Sheets: save results]
    → [Slack: notify team]
```

### RAG with Web Search

Answer questions using both your data and the web:

```
[Webhook: receive question]
    → [Pinecone: search knowledge base]
    → [AnyAPI: answer with context + web search enabled]
    → [Respond to Webhook]
```

### Image Generation Bot

Generate images on demand via Slack:

```
[Slack Trigger: new message in #ai-images]
    → [AnyAPI: generate image from message text]
    → [Slack: upload image to channel]
```

### Multi-Model Comparison

Compare responses from different models:

```
[Manual Trigger]
    → [Split In Batches]
        → [AnyAPI: GPT-4o]
        → [AnyAPI: Claude Sonnet]
        → [AnyAPI: Gemini Flash]
    → [Merge]
    → [Google Sheets: save comparison]
```

## Troubleshooting

### Credential Test Fails

* Verify your API key is correct at [dash.anyapi.ai](https://dash.anyapi.ai/?page=api-keys)
* Check the Base URL is `https://api.anyapi.ai/v1`
* Ensure your account has available credits

### Model Not Found

* Use the full model ID with provider prefix: `openai/gpt-4o`, not just `gpt-4o`
* Use the **Model > List** operation to see all available models

### Unsupported Feature Error

Not all models support all features. If you get an error like "unsupported tool type", try a different model. For example, web search works with OpenAI and Anthropic models but may not work with all providers.

## Next Steps

<CardGroup cols={2}>
  <Card title="Hermes Agent" icon="terminal" href="/integrations/hermes">
    Autonomous coding agent with 21 messaging adapters
  </Card>

  <Card title="OpenClaw" icon="code" href="/integrations/openclaw">
    AI coding agent with multi-model fallbacks
  </Card>

  <Card title="Web Search" icon="globe" href="/features/web-search">
    Learn more about web search grounding
  </Card>

  <Card title="Tool Calling" icon="wrench" href="/features/tool-calling">
    Deep dive into function calling
  </Card>
</CardGroup>
