spicyapiDocs
Main content

n8n

Use SpicyAPI's image, video, audio and chat models in n8n workflows. Install the community node, import the HTTP Request templates, or point n8n's OpenAI credential at SpicyAPI for AI Agent nodes.

n8n is a workflow automation tool. SpicyAPI gives it image, video, audio and chat models behind one API and one prepaid balance. There are three ways to connect them, and they can be mixed in one workflow:

You want to…UseWorks on
Generate images, video and audio with a ready-made nodeThe SpicyAPI community nodeSelf-hosted n8n
Generate media on n8n Cloud, or without installing anythingThe HTTP Request templatesSelf-hosted n8n and n8n Cloud
Use chat models in AI Agent, Basic LLM Chain and other AI nodesn8n's built-in OpenAI credential with a new Base URLSelf-hosted n8n and n8n Cloud

All three use the same account, key, models and prices. For media, the node and HTTP Request templates check the request price before submission. Replaying the same accepted media request with its original Idempotency-Key returns the existing task.

For a starting image workflow, see the n8n NSFW image workflow guide: it covers model selection, reference editing, a first portrait and example costs. Use the steps below to connect it to your n8n instance.

The short version

  1. Create an API key in the console. Give it a daily spend cap.
  2. Self-hosted: in n8n open Settings > Community Nodes > Install, enter @spicyapi/n8n-nodes-spicyapi, then add a SpicyAPI (spicyapi.ai) API credential.
  3. n8n Cloud: import a template from the node's examples folder and give its HTTP Request nodes a Bearer Auth credential.
  4. Chat in AI nodes: create an OpenAI credential with Base URL https://api.spicyapi.ai/v1 and your SpicyAPI key.

Before you start

  • An API key. Create one in the console; it starts with sk-spicy-. See Account setup if you do not have an account yet.
  • A balance. Add funds in console Billing before your first generation. Your n8n workflows, Studio and API use the same account balance. See Billing for how charges are settled.
  • One key per automation. Workflows can run far more often than a person clicks. Create a separate key for n8n and set a daily or monthly spend cap on it, so a mistake in a loop has a ceiling. See Authentication.
  • n8n can reach api.spicyapi.ai. The calls are made by the n8n server, not by your browser.

Option 1: the SpicyAPI community node

The node is open source (MIT) at github.com/spicyapi-ai/n8n-nodes-spicyapi and published on npm as @spicyapi/n8n-nodes-spicyapi. It has no runtime dependencies and talks only to api.spicyapi.ai.

Self-hosted n8n only

n8n Cloud can only install community nodes that n8n has verified, and this one is not verified. On n8n Cloud use the HTTP Request templates below. They call the same API.

Other npm packages have similar names but belong to unrelated services. This one is the package named @spicyapi/n8n-nodes-spicyapi, and its credential is called SpicyAPI (spicyapi.ai) API.

Install

Install the package

In n8n, open Settings > Community Nodes, select Install, enter @spicyapi/n8n-nodes-spicyapi, tick the box that acknowledges installing unverified code, and confirm. You must be the instance owner or an admin.

For queue mode, or if you manage nodes by hand, run this in the n8n data folder and restart n8n:

cd ~/.n8n/nodes
npm install @spicyapi/n8n-nodes-spicyapi

See n8n's community nodes guide for the options your setup supports.

Add the credential

Create a SpicyAPI (spicyapi.ai) API credential:

FieldValue
API KeyYour key, starting with sk-spicy-
Base URLLeave https://api.spicyapi.ai as it is

Saving the credential checks the key against your account balance.

Add the node to a workflow

Search for SpicyAPI in the nodes panel, pick a resource and an operation, then choose the credential.

Operations

ResourceOperationWhat it does
ImageGenerateText to image, image editing, upscaling, background removal and other image models
VideoGenerateText to video, image to video and other video models
AudioGenerateText to speech, music, transcription and other audio models
TaskGetRead a task by ID, optionally wait for it and download its files
FileUploadUpload a binary file and get a spicy:// URI to use as model input
ModelGet ManyThe model catalogue with prices, filtered by modality and keyword
ModelGetOne model with its input schema and examples
ModelGet QuoteThe exact price of a request, without running it
AccountGet BalanceAvailable, held and total balance in US dollars
ChatMessage a ModelOne chat completion from a text model

Generate images, video and audio

The three Generate operations share the same fields:

  1. Model. Pick from the list, which shows the models for the selected resource with their starting price, or enter a model ID by hand. Every model and its parameters are listed at spicyapi.ai/models.
  2. Prompt. The model's main text input. For speech models this is the text to speak. Leave it empty for models that have no prompt, such as upscalers.
  3. Media Inputs. Images, videos or audio that the model reads. Pick the field (the list shows the selected model's file inputs), then use a binary field from the previous node or a URL. Binary files are uploaded to SpicyAPI automatically. Add several inputs for the same field to fill list fields such as reference images.
  4. Model Parameters. A form generated from the selected model's schema: aspect ratio, resolution, duration, seed and so on. Fields you leave empty are not sent, so the model uses its own default.
  5. Additional Parameters (JSON). Any other input fields as a JSON object. They override the fields above.

The output contains the task record (taskId, state, cost, settled, output). With Download Output on, which is the default, the files are also attached as binary data in data, data_1 and so on. The links in output.assets[].url expire after about 20 minutes; the binary copies do not.

Large videos are held in memory unless n8n stores binary data on disk. On self-hosted n8n, set N8N_DEFAULT_BINARY_DATA_MODE=filesystem when you work with video.

Cost control and retries

  • Every item is priced first. The node asks for a quote. If the quote is above Max Cost per Item (USD), which defaults to $2, it stops with an error before anything is created, and nothing is charged. Set the limit to 0 to remove it.
  • The task is created with the quoted price. If the price changes between the quote and the submission, the node quotes again, checks the limit again and resubmits.
  • Retries do not charge twice. See Cost limits and retries.

Long-running tasks

See Long-running video tasks for the options and when to use each one.

Option 2: HTTP Request templates

Two importable workflows use only built-in n8n nodes, so they run on self-hosted n8n and on n8n Cloud, with no community node. They are in the examples folder of the node's repository.

FileWhat it does
http-request-image.jsonGets a quote, stops if it is above a price limit, creates a task, polls until it finishes and downloads the image as a binary file
http-request-chat.jsonOne chat completion through the OpenAI-compatible endpoint

Import the workflow

Download the .json file. In n8n choose Workflow menu > Import from File.

Create a Bearer Auth credential

Create a Bearer Auth credential, paste your SpicyAPI key as the token, and select it in each HTTP Request node that calls api.spicyapi.ai. The image template has four of them.

Edit the settings and run

Open the Settings node. In the image template you can change the model, the prompt, the aspect ratio and the maximum price in US dollars (maxCostUsd). Replace the model with an ID from the model catalogue, then run the workflow.

How the image template is built

The same steps work for any media model, so you can copy the pattern into your own workflow.

StepNodeRequest
1HTTP RequestPOST https://api.spicyapi.ai/api/v1/jobs/quote with model and input returns a quoteId and estimatedCost
2IfStops with an error when the quote is above your limit. Nothing has been charged yet
3HTTP RequestPOST https://api.spicyapi.ai/api/v1/jobs/createTask with the quoteId, expectedCost and an Idempotency-Key header. The template adds ?wait=50 so that quick image models answer in the same request
4If, Wait, HTTP RequestIf the task is still queued or running, wait 5 seconds and call GET https://api.spicyapi.ai/api/v1/jobs/recordInfo?taskId=…, then check again
5HTTP RequestDownloads output.assets[0].url as a file

The request and response shapes are in Tasks, Quotes and compatibility and Media inputs and outputs. Files that a model reads, such as a start image, can be a public URL or an uploaded spicy:// file.

Option 3: chat models in AI Agent and other AI nodes

SpicyAPI's chat endpoint is OpenAI-compatible, so n8n's own OpenAI nodes can use it. You do not need the community node for this, and it works on n8n Cloud.

Create an OpenAI credential

In n8n create a new OpenAI credential. Paste your SpicyAPI key as the API Key and set Base URL to:

https://api.spicyapi.ai/v1

Choose a chat model

Add an OpenAI Chat Model to your AI Agent or Basic LLM Chain and select the credential. Pick a model whose ID ends in /chat (written MODEL_ID_FROM_CATALOG on this page: copy a real id from the live catalog). The full list is at GET https://api.spicyapi.ai/v1/models?modality=text.

Things to know:

  • The model list includes image and video models. With a custom Base URL n8n shows everything /v1/models returns, and SpicyAPI's list covers all its models. Pick one that ends in /chat, or type the ID in expression mode. Image and video models are not chat models and will fail in an agent.
  • Use Responses API. Recent versions of the OpenAI Chat Model node can send requests to /v1/responses instead of /v1/chat/completions. SpicyAPI supports /v1/responses, but not previous_response_id. If an agent request fails with the Responses API on, turn Use Responses API off in the node.
  • Sampling settings. If you set an option the model does not declare, such as temperature on a reasoning model, SpicyAPI ignores it instead of failing and lists the ignored names in the X-Spicy-Ignored-Params response header; a value outside the model's range is changed to the nearest accepted one and listed in X-Spicy-Adjusted-Params. Other undeclared fields still return 400.
  • Tools and JSON output depend on the model. Check the supported_parameters of the model in /v1/models.
  • Reasoning models count reasoning tokens toward max_tokens. With a very small value, such as 20, a reasoning model can spend the whole budget thinking and return no text (upstream_failed: "the output budget was spent on reasoning"). Raise max_tokens or lower reasoning_effort. The values for reasoning_effort differ per model.
  • Streaming and cost. Chat is billed by tokens after the call. The text and streaming page has the details, and Chat recipes has request examples.

Cost limits and retries

Limits on spending

  • Use a separate key for n8n with a daily or monthly spend cap in the console, and a model allowlist if the workflow only needs a few models. When a cap is reached the call fails with 40202 and nothing is charged for it.
  • For media models, quote first. The node does this for you; the templates do it with the Get Quote and If nodes. The quote is the exact price of that request, including extras such as per-reference-image charges, so a price check based on a quote is reliable and one based on the catalogue table is not.
  • Ordinary failed tasks and expired tasks release the full hold. Certain content refusals are charged only when the model page explicitly says so. Read settled and cost for the final charge; see Billing.

Why a retry does not charge twice

Every task-creating call carries an Idempotency-Key. If the same key arrives again with the same request, SpicyAPI returns the task it already created instead of creating a second one, so no second hold or charge happens. This matters in n8n because a request can be sent twice without you doing anything: Retry On Fail on a node, or a timeout where the first request actually went through.

  • The community node builds the key from the execution, the node, the item and its input. A node retry reuses the same key. A new execution, a changed input or another pass through a loop is new work and gets a new key.
  • The templates build it from the execution ID and the item index, for example n8n-<execution id>-<item index>. If you copy the pattern into a loop, add the loop counter to the key, or every pass will return the first pass's task.
  • Do not use a random value that changes on every attempt, such as $now: it makes every retry look like new work.

More in Idempotency.

Long-running video tasks

Image and audio models usually finish within one request. Video can take minutes. You have three ways to deal with that, from simplest to lightest on n8n:

ApproachHowTrade-off
Wait inside the node (default)The community node polls with a growing delay until the task ends or Max Wait Time passesSimple, but the execution stays open while the video renders
Submit, then wait and checkTurn off Wait for Completion, add a Wait node, then Task > Get. The templates do the same with Wait, Get Task and If nodes in a loopOne execution slot is used only for the short calls
CallbackSet Callback URL to {{ $execution.resumeUrl }} and follow it with a Wait node set to resume on a webhook calln8n must be reachable over public HTTPS. When the call arrives, read the task with Task > Get and do not trust the callback body

If the node stops waiting, the task keeps running on SpicyAPI and is charged if it succeeds. Fetch it later with Task > Get; do not submit it again. You can also find it under Logs in the console.

Results are kept for a limited time and download links last about 20 minutes. Save the files in the workflow, for example to cloud storage, if you need them for longer. See Retention.

Troubleshooting

You seeWhat to do
Credential test fails or 401Copy the key again from the console. A revoked key stops working at once. With the OpenAI credential, check that the Base URL ends in /v1.
SpicyAPI does not appear in the nodes panelYou are probably on n8n Cloud, or n8n has not restarted after a manual install. Cloud cannot install unverified nodes; use the templates.
The Install button is missing in Community NodesCommunity packages are disabled, or you are not the owner or an admin. Ask whoever runs the instance, or install by hand in ~/.n8n/nodes.
40201Not enough balance. Add funds in the console, then run again. A retry with the same key is safe.
40202The key reached a daily, monthly or lifetime spend cap. Raise the cap or wait for it to roll over.
40310Your account's email address is not verified. Open the link in your sign-up email.
40004No deployment serves that combination of options. Change the option named in the message.
40901The quote no longer matches, usually because it expired (quotes last 5 minutes). Quote again, and resubmit with the same Idempotency-Key.
An error that the price is above your limitThe quote is higher than Max Cost per Item or maxCostUsd. Raise it or choose cheaper options. Nothing was charged.
The agent fails on a modelYou may have picked a model that is not a chat model. Use an ID that ends in /chat. Also try turning Use Responses API off.
A reasoning model returns an empty answerRaise max_tokens or lower reasoning_effort.
The download link in the output returns an error laterLinks expire after about 20 minutes. Use Task > Get to get a fresh link, or keep the binary copy.
Memory, heap or restarts while handling videoBinary data is kept in memory by default. Set N8N_DEFAULT_BINARY_DATA_MODE=filesystem.
The callback never resumes the workflowThe URL must be public HTTPS on port 443 or 80, not localhost. Check the execution's resume URL is the one your n8n shows publicly.

Errors from SpicyAPI end with a request_id or a task ID. Quote it to support and the request can be found exactly. Error codes are explained in Errors, and there is a wider checklist in Troubleshooting.

Use of the models is subject to the SpicyAPI terms and to the terms of the n8n edition you run.

On this page