[Integrations](https://spiral.ai/integrations) › [n8n](https://spiral.ai/integrations/n8n) › [Phi-4](https://spiral.ai/integrations/n8n/phi-4)

# How to Use Phi-4 in n8n

Phi-4 suits math problems, logic checks, and Python code tasks. Its 14-billion-parameter model has a 16K-token context window; use English prompts and check factual claims against supplied sources.

|  |  |
| --- | --- |
| Model | Phi-4 |
| Available through | OpenRouter |
| Category | LLM |
| Price | Up to $0.000749 per run at the default inputs. $0.091 per 1M input tokens, $0.182 per 1M output tokens. |
| Returns | text, json |
| Runs | In the background |
| Setup | About 2 minutes, with a Spiral API key |

## Prompts to try with Phi-4 in n8n

- Each morning, use Phi-4 to review the supplied daily metrics. Recalculate percentage changes from the provided current and previous values, flag zero denominators, and report only discrepancies with the formula used.
- Every Monday, use Phi-4 to check the supplied weekly task plan against its dependencies and working-hour limits. List conflicts with the exact rule each breaks, and propose changes without inventing availability.
- Each evening, use Phi-4 to check the supplied inventory arithmetic. Compare opening stock plus receipts minus shipments with closing stock, list mismatches, and mark any missing quantity as unknown.
- Each weekday, use Phi-4 to create one English algebra practice problem at the difficulty described in the supplied learning plan. Include a separate answer key with a brief check, and keep the complete response under 300 words.
- Each Friday, use Phi-4 to review the supplied numerical summary for inconsistent totals, averages, and units. Explain each suspected error using only the supplied figures and keep the report under 400 words.

## How to set up Phi-4 in n8n

Pick the way that suits you. Each takes about two minutes.

### Use the Spiral skill

1. **Send n8n this message**: Your agent reads Spiral's skill and sets itself up.

```
set up https://spiral.ai/SKILL.md
```

2. **Sign in or paste a key**: Approve Spiral in the browser, or give the agent a key from the console.

### Use Spiral's MCP server

1. **Create a key**: Create a key under API keys in the console.

2. **Add an MCP Client node**: In a workflow, add an MCP Client node (or, under an AI Agent node, an MCP Client Tool) and set:

```text
https://api.spiral.ai/mcp
```

3. **Pick a tool**: The node lists Spiral's tools. In an MCP Client node pick one, such as `run`, and give it its arguments:

```json
{
  "provider": "fal",
  "model": "fal-ai/flux/schnell",
  "input": { "prompt": "a lighthouse at dawn" },
  "wait": true
}
```

4. **Run Phi-4 in a workflow step**: Give the step an instruction like the ones below and run it on your trigger or schedule. Spiral finds Phi-4, prices it and runs it each time the step fires.

### Use the Spiral CLI

1. **Install and sign in**: Installs the Spiral CLI, signs you in and adds its skill to your coding agents.

```bash
npx -y spiral-cli@latest init
```

### Call the Spiral API

1. **Create an API key**: In the console, under API keys.

2. **Run Phi-4**: One request; the result comes back by polling or a webhook.

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "openrouter",
    "model": "microsoft/phi-4",
    "input": {
      "messages": [
        {
          "role": "system"
        }
      ]
    }
  }'
```

Then paste one of the prompts above: n8n finds Phi-4 on Spiral, shows the price and runs it.

Setup guide in the docs: https://spiral.ai/docs/quickstarts/n8n

## Phi-4 tools and prices

- [Microsoft: Phi 4](https://spiral.ai/tools/openrouter/microsoft/phi-4) (OpenRouter): Up to $0.000749 per run at the default inputs. $0.091 per 1M input tokens, $0.182 per 1M output tokens.

## Settings you can ask for

| Setting | Allowed values | Default | Description |
| --- | --- | --- | --- |
| seed |  | — |  |
| stop |  | — |  |
| min_p | 0 to 1 | — |  |
| top_k | 0 to … | — |  |
| top_p | 0 to 1 | — |  |
| max_tokens | 1 to 14745 | — | The most output tokens to generate. |

## What can you do with Phi-4 in n8n?

Use Phi-4 to repeat calculation checks and constraint reviews on supplied daily inputs. Make each run self-contained and check its conclusions before acting on them.

### Check business calculations

Ask Phi-4 to review percentage changes, weighted averages, and unit conversions using supplied numbers. Request the formula and a short calculation you can verify.

### Draft small Python utilities

Use Phi-4 to draft focused functions for counting records, grouping values, or calculating summary statistics. Specify the input, expected result, and edge cases.

### Review Python logic

Give Phi-4 a function and its intended behavior. Ask for a failing example and a proposed correction, then run the example yourself.

### Propose Python test cases

Ask Phi-4 for normal, boundary, and invalid-input cases for a small function. Review the expected results before adding the tests.

### Explain math mistakes

Provide a problem and an attempted solution. Ask Phi-4 to identify the first incorrect step and explain a correction at the learner's level.

### Check plans against constraints

Supply scheduling rules, dependencies, and resource limits. Ask Phi-4 to identify conflicts and propose a plan that satisfies the stated constraints.

### Work through science exercises

Provide an exercise, its assumptions, and any required reference material. Ask Phi-4 for a concise explanation with equations, units, and a check of the result.

## Overview

- [OpenRouter](https://spiral.ai/providers/openrouter)
- [All n8n guides](https://spiral.ai/integrations/n8n)

## Phi-4 in other agents

- [Amp](https://spiral.ai/integrations/amp/phi-4)
- [ChatGPT](https://spiral.ai/integrations/chatgpt/phi-4)
- [Claude](https://spiral.ai/integrations/claude-desktop/phi-4)
- [Claude Code](https://spiral.ai/integrations/claude-code/phi-4)
- [Cline](https://spiral.ai/integrations/cline/phi-4)
- [Codex](https://spiral.ai/integrations/codex/phi-4)
- [Cursor](https://spiral.ai/integrations/cursor/phi-4)
- [Devin](https://spiral.ai/integrations/devin/phi-4)
- [dots](https://spiral.ai/integrations/dots/phi-4)
- [Factory Droid](https://spiral.ai/integrations/factory-droid/phi-4)
- [Gemini](https://spiral.ai/integrations/gemini/phi-4)
- [Gemini CLI](https://spiral.ai/integrations/gemini-cli/phi-4)
- [Google Antigravity](https://spiral.ai/integrations/antigravity/phi-4)
- [goose](https://spiral.ai/integrations/goose/phi-4)
- [Grok](https://spiral.ai/integrations/grok/phi-4)
- [Grok Build](https://spiral.ai/integrations/grok-build/phi-4)
- [Hermes](https://spiral.ai/integrations/hermes/phi-4)
- [Instinct](https://spiral.ai/integrations/instinct/phi-4)
- [Manus](https://spiral.ai/integrations/manus/phi-4)
- [Muse](https://spiral.ai/integrations/muse/phi-4)
- [Muse Code](https://spiral.ai/integrations/muse-code/phi-4)
- [Notion](https://spiral.ai/integrations/notion/phi-4)
- [OpenClaw](https://spiral.ai/integrations/openclaw/phi-4)
- [opencode](https://spiral.ai/integrations/opencode/phi-4)
- [Perplexity](https://spiral.ai/integrations/perplexity/phi-4)
- [Raycast](https://spiral.ai/integrations/raycast/phi-4)
- [VS Code](https://spiral.ai/integrations/vscode/phi-4)
- [Windsurf](https://spiral.ai/integrations/windsurf/phi-4)
- [Zapier](https://spiral.ai/integrations/zapier/phi-4)

## More n8n guides

- [Perceptron Mk1.5](https://spiral.ai/integrations/n8n/perceptron-mk1-5)
- [Pixtral Large 2502](https://spiral.ai/integrations/n8n/pixtral-large-2502)
- [Perceptron Mk1](https://spiral.ai/integrations/n8n/perceptron-mk1)
- [Qwen Plus](https://spiral.ai/integrations/n8n/qwen-plus)
- [Particle-1](https://spiral.ai/integrations/n8n/particle-1)
- [Qwen2.5 72B Instruct](https://spiral.ai/integrations/n8n/qwen2-5-72b-instruct)

## Questions about Phi-4 in n8n

**Can n8n use Phi-4?**

Yes. Add Spiral to n8n as an MCP server, and n8n can find and run Phi-4 like any built-in tool.

**How much does Phi-4 cost in n8n?**

Up to $0.000749 per run at the default inputs. $0.091 per 1M input tokens, $0.182 per 1M output tokens. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your n8n plan is separate.

**Do I need an OpenRouter account to use Phi-4 in n8n?**

You need no OpenRouter account. n8n uses one Spiral API key for every tool, and Spiral runs Phi-4 on its own OpenRouter account.

**How long does it take to set up Phi-4 in n8n?**

About two minutes: create a key, then add an MCP Client node, then pick a tool.

**Does n8n wait while Phi-4 runs?**

Phi-4 runs in the background. n8n starts the run, checks on it and gives you the text, json when it's ready.

**What is Phi-4 good at?**

Mathematical reasoning is a documented strength. Try it for checking calculations, solving constrained problems, and explaining a mathematical solution.

**How much text can Phi-4 handle?**

Phi-4 has a 16K-token context window. Keep the instructions, relevant conversation, source material, and requested response within that budget.

**Which language should I use with Phi-4?**

Use English when possible. Microsoft says performance is worse in other languages, so evaluate your actual tasks before relying on multilingual output.

**Is Phi-4 useful for coding?**

Python is the best-supported starting point in its documented code training. Check generated code against tests, and verify unfamiliar packages or APIs against their documentation.

**Can I trust Phi-4's factual answers and formatting?**

Phi-4 can invent factual details and miss strict formatting requirements. Supply the evidence you want it to use, check claims against that evidence, and validate outputs before a program consumes them.

