Skip to contentNewKimi K3.1 Pro is now availableTry it now
Docs / n8n

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.

SettingValue
n8n Credential typeOpenAI API
Base URLhttps://api.inference.net/v1
US-only Base URLhttps://us.api.inference.net/v1
API KeyINFERENCE_API_KEY (inf_sk_...)
Live model listGET https://api.inference.net/v1/models
bash
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

  1. Create an OpenAI API credential in n8n

    In n8n, open Credentials > Add Credential and choose OpenAI.

    1. Paste your Inference.net key (inf_sk_...) into API Key.
    2. Set Base URL to https://api.inference.net/v1 (or https://us.api.inference.net/v1 for US-only routing).
    3. Leave Organization ID blank and click Save.
  2. 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:

    1. Select your new Inference.net credential.
    2. 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, or moonshotai/kimi-k3.1-pro.
    3. 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:

json
{
  "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.

json
{
  "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:

json
{
  "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 IDContext / max outputInput / cached / output (per 1M)ToolsBest for in n8n
deepseek-v4.1-flash-10171,040,000 / 393,216$0.08 / $0.007 / $0.635YesDefault AI Agent and high-volume automations
glm-5.3-flash1,048,576 / 262,144$0.10 / $0.03 / $0.35YesLow-cost multimodal classification and routing
glm-5.31,048,576 / 943,718$0.084 / $0.079 / $3.00YesMulti-step reasoning and long document synthesis
moonshotai/kimi-k3.1-pro1,048,576 / 1,048,576$1.80 / $0.198 / $9.00YesComplex multi-tool AI Agents
inference-net/schematron-v2-small128,000 / 4,096$0.05 / $0.05 / $0.23NoComplex HTML-to-JSON extraction via HTTP Request
inference-net/schematron-v2-turbo128,000 / 8,192$0.03 / $0.03 / $0.15NoHigh-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 list to By ID (or an expression) and enter the exact ID from GET https://api.inference.net/v1/models.
  • 401 Unauthorized: Check that the OpenAI API credential uses INFERENCE_API_KEY (inf_sk_...) rather than an OpenAI key.
  • 404 Not Found: Verify Base URL is https://api.inference.net/v1 (with /v1 and without /chat/completions).
  • AI Agent tools fail: Confirm your selected model has supports_tools: true. Models such as inference-net/schematron-v2-small do 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.