n8n
Connect n8n OpenAI Chat Model credentials and AI Agent nodes to Inference.net for fast tool calling and structured JSON workflows.
Last updated
Connect n8n to Inference.net by creating an OpenAI API credential pointed at https://api.inference.net/v1 with your INFERENCE_API_KEY, then attaching the OpenAI Chat Model sub-node to n8n AI Agent, Basic LLM Chain, or Information Extractor workflows. You get OpenAI-compatible streaming, tool calling, and structured JSON outputs across verified open-weight models with one key.
Connection settings
Create an account at /register and generate a project key in API keys.
| Setting | Value |
|---|---|
| n8n Credential type | OpenAI API |
| Base URL | https://api.inference.net/v1 |
| US-only Base URL | https://us.api.inference.net/v1 |
| API Key | INFERENCE_API_KEY (inf_sk_...) |
| Live model list | GET https://api.inference.net/v1/models |
export INFERENCE_API_KEY="inf_sk_..."
curl -sS https://api.inference.net/v1/models \
-H "Authorization: Bearer $INFERENCE_API_KEY" | jq '.data[].id'Set up the OpenAI Chat Model credential
Create an OpenAI API credential in n8n
In n8n, open Credentials > Add Credential and choose OpenAI.
- Paste your Inference.net key (
inf_sk_...) into API Key. - Set Base URL to
https://api.inference.net/v1(orhttps://us.api.inference.net/v1for US-only routing). - Leave Organization ID blank and click Save.
- Paste your Inference.net key (
Attach OpenAI Chat Model to an AI Agent node
Add an AI Agent node to your workflow and connect an OpenAI Chat Model sub-node to its Chat Model port:
- Select your new Inference.net credential.
- In the Model field, switch from the fixed OpenAI dropdown to Expression (or By ID) and enter an exact Inference.net model ID such as
deepseek-v4.1-flash-1017,glm-5.3, ormoonshotai/kimi-k3.1-pro. - Attach any n8n Tool sub-nodes (HTTP Request Tool, Postgres, Slack, Calculator) and run the workflow.
Example AI Agent + OpenAI Chat Model node configuration
You can paste the node definition below into an n8n workflow canvas and link your saved Inference.net OpenAI API credential:
{
"nodes": [
{
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.8,
"position": [240, 200],
"parameters": {
"promptType": "define",
"text": "={{ $json.message }}",
"options": {
"systemMessage": "You are an operations triage assistant. Use connected tools to look up order and ticket state before replying."
}
}
},
{
"name": "Inference.net Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [240, 420],
"parameters": {
"model": {
"__rl": true,
"mode": "id",
"value": "deepseek-v4.1-flash-1017"
},
"options": {
"baseURL": "https://api.inference.net/v1",
"temperature": 0.2
}
}
}
],
"connections": {
"Inference.net Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}Structured output workflows in n8n
You have two clean patterns for typed JSON outputs in n8n:
1. AI Agent or Basic LLM Chain with Structured Output Parser
Attach n8n's Structured Output Parser sub-node to your AI Agent or Basic LLM Chain node, toggle Require Specific Output Format, and define a JSON Schema. Use a model with supports_tools: true such as deepseek-v4.1-flash-1017, glm-5.3, or moonshotai/kimi-k3.1-pro.
{
"type": "object",
"properties": {
"category": {
"type": "string",
"enum": ["billing", "technical", "account"]
},
"priority": {
"type": "string",
"enum": ["low", "medium", "high"]
},
"summary": { "type": "string" }
},
"required": ["category", "priority", "summary"],
"additionalProperties": false
}2. Direct HTML-to-JSON extraction with Schematron via HTTP Request
When scraping web pages or parsing large HTML payloads in n8n, call inference-net/schematron-v2-small or inference-net/schematron-v2-turbo directly from an n8n HTTP Request node (POST https://api.inference.net/v1/chat/completions) with temperature: 0 and response_format.type = "json_schema". You can also pass x-inference-task-id and x-inference-environment headers on the HTTP Request node to filter workflow costs in Usage:
{
"model": "inference-net/schematron-v2-small",
"temperature": 0,
"messages": [
{
"role": "user",
"content": "={{ $json.html }}"
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "extracted_article",
"strict": true,
"schema": {
"type": "object",
"properties": {
"title": { "type": "string" },
"author": { "type": "string" },
"published_date": { "type": "string" }
},
"required": ["title", "author", "published_date"],
"additionalProperties": false
}
}
}
}Verified models for n8n workflows
All model IDs, limits, and per-1M-token rates below are verified against GET https://api.inference.net/v1/models (2026-12-06):
| Model ID | Context / max output | Input / cached / output (per 1M) | Tools | Best for in n8n |
|---|---|---|---|---|
deepseek-v4.1-flash-1017 | 1,040,000 / 393,216 | $0.08 / $0.007 / $0.635 | Yes | Default AI Agent and high-volume automations |
glm-5.3-flash | 1,048,576 / 262,144 | $0.10 / $0.03 / $0.35 | Yes | Low-cost multimodal classification and routing |
glm-5.3 | 1,048,576 / 943,718 | $0.084 / $0.079 / $3.00 | Yes | Multi-step reasoning and long document synthesis |
moonshotai/kimi-k3.1-pro | 1,048,576 / 1,048,576 | $1.80 / $0.198 / $9.00 | Yes | Complex multi-tool AI Agents |
inference-net/schematron-v2-small | 128,000 / 4,096 | $0.05 / $0.05 / $0.23 | No | Complex HTML-to-JSON extraction via HTTP Request |
inference-net/schematron-v2-turbo | 128,000 / 8,192 | $0.03 / $0.03 / $0.15 | No | High-throughput HTML-to-JSON scraping |
Prompt caching and data retention
Keep your AI Agent system message and connected tool definitions static across workflow executions so repeated runs reuse the cached prefix automatically on deepseek-v4.1-flash-1017 ($0.007/1M cached input) and moonshotai/kimi-k3.1-pro ($0.198/1M cached input). Do not pass prompt_cache_key to deepseek-v4.1-flash-1017. Estimate caching impact with the Prompt cache calculator.
Inference.net-hosted models listed above operate under default Zero Data Retention. External passthrough routes and ad-supported model variants have separate retention policies.
Troubleshooting
- Model not listed in dropdown: Switch the Model field on OpenAI Chat Model from
From listtoBy ID(or an expression) and enter the exact ID fromGET https://api.inference.net/v1/models. 401 Unauthorized: Check that the OpenAI API credential usesINFERENCE_API_KEY(inf_sk_...) rather than an OpenAI key.404 Not Found: Verify Base URL ishttps://api.inference.net/v1(with/v1and without/chat/completions).- AI Agent tools fail: Confirm your selected model has
supports_tools: true. Models such asinference-net/schematron-v2-smalldo not support tool calling and belong in HTTP Request extraction steps instead. - Execution timeout on long responses: Increase the Timeout setting under Options on the OpenAI Chat Model or HTTP Request node when generating long outputs.
Explore all supported editors, workflow builders, gateways, and SDKs in the Integrations hub.
Start building
One OpenAI-compatible API key for fast open-weight models.