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

Dify

Connect Dify Cloud or self-hosted Dify to Inference.net via OpenAI-API-compatible models for workflows, chatflows, and JSON extraction.

Last updated

Connect Dify Cloud or self-hosted Dify to Inference.net through Dify's OpenAI-API-compatible model provider using https://api.inference.net/v1 and your INFERENCE_API_KEY. You can run fast open-weight models (deepseek-v4.1-flash-1017, glm-5.3, and moonshotai/kimi-k3.1-pro) across Dify Chatflows, Workflows, and Agents, or extract strict JSON from HTML using inference-net/schematron-v2-small.

Shared connection settings

Create an account at /register and generate a project key in API keys. Verify your key and inspect live model IDs before adding models in Dify:

SettingValue
Provider pluginOpenAI-API-compatible
API endpoint URLhttps://api.inference.net/v1
US-only endpoint URLhttps://us.api.inference.net/v1
API keyINFERENCE_API_KEY (inf_sk_...)
Completion modeChat
bash
export INFERENCE_API_KEY="inf_sk_..."
curl -sS https://api.inference.net/v1/models \
  -H "Authorization: Bearer $INFERENCE_API_KEY" | jq '.data[].id'

Configure Inference.net in Dify

  1. Install the OpenAI-API-compatible provider plugin

    In Dify Cloud or self-hosted Dify v1.0+, open Settings > Model Provider. Locate OpenAI-API-compatible (install it from the Dify Marketplace if it is not enabled yet) and click Add Model.

  2. Register a flagship Inference.net model

    Fill in the Add Model dialog with the exact values from GET https://api.inference.net/v1/models:

    FieldExample value (deepseek-v4.1-flash-1017)
    Model TypeLLM
    Model Namedeepseek-v4.1-flash-1017
    Model Display NameDeepSeek V4.1 Flash (Inference.net)
    API KeyYour INFERENCE_API_KEY
    API endpoint URLhttps://api.inference.net/v1
    Completion modeChat
    Model context size1040000
    Upper bound for max tokens393216
    Function callingTool Call
    Vision supportYes

    Repeat Add Model for any additional model you want in Dify's picker, such as glm-5.3 (1048576 context, text only) or moonshotai/kimi-k3.1-pro (1048576 context, text and image).

  3. Assign the model in a Workflow or Chatflow

    Open any Dify LLM or Agent node, select your registered Inference.net model, and click Run to test a prompt. Dify streams tokens directly from https://api.inference.net/v1/chat/completions.

Self-hosted Dify configuration

When running self-hosted Dify via Docker Compose, verify outbound connectivity and request timeouts for long-context or reasoning models (glm-5.3, moonshotai/kimi-k3.1-pro):

  • Outbound HTTPS: Allow egress from the api and plugin_daemon containers to api.inference.net:443 (and us.api.inference.net:443 if you pin US-only routes).
  • Streaming and plugin timeouts: In your Dify .env file, raise PLUGIN_MAX_EXECUTION_TIMEOUT and HTTP_REQUEST_MAX_READ_TIMEOUT (for example, to 300 seconds) when running long-context reasoning steps so Dify does not cut off active streams.
  • Data retention: Inference.net-hosted US serverless models listed in the table below operate under default Zero Data Retention. External passthrough and ad-supported model variants have different retention terms; review Data retention before sending sensitive payloads.

JSON extraction with Schematron

For scraping and document ingestion pipelines in Dify, use inference-net/schematron-v2-small (highest extraction accuracy on complex schemas) or inference-net/schematron-v2-turbo (lowest cost at scale). Schematron models accept raw or pre-cleaned HTML in the user message with a strict JSON Schema in response_format and do not require a system prompt.

In a Dify Workflow, add an HTTP Request node configured as POST https://api.inference.net/v1/chat/completions with Authorization: Bearer <INFERENCE_API_KEY>, Content-Type: application/json, and the JSON body below:

json
{
  "model": "inference-net/schematron-v2-small",
  "temperature": 0,
  "messages": [
    {
      "role": "user",
      "content": "{{#fetch_page.body#}}"
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "product_record",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "price": { "type": "number" },
          "currency": { "type": "string" },
          "in_stock": { "type": "boolean" }
        },
        "required": ["name", "price", "currency", "in_stock"],
        "additionalProperties": false
      }
    }
  }
}

Pass the HTTP Request node's JSON response into a downstream Dify Code or Variable Assigner node. See the Schematron guide for HTML preprocessing tips.

Verified models and live rates

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)ToolsModalitiesModel page
deepseek-v4.1-flash-10171,040,000 / 393,216$0.08 / $0.007 / $0.635YesText, imageDeepSeek V4.1 Flash
glm-5.31,048,576 / 943,718$0.084 / $0.079 / $3.00YesTextGLM-5.3
glm-5.3-flash1,048,576 / 262,144$0.10 / $0.03 / $0.35YesText, image, videoGLM-5.3 Flash
moonshotai/kimi-k3.1-pro1,048,576 / 1,048,576$1.80 / $0.198 / $9.00YesText, imageKimi K3.1 Pro
inference-net/schematron-v2-small128,000 / 4,096$0.05 / $0.05 / $0.23NoTextSchematron V2 Small
inference-net/schematron-v2-turbo128,000 / 8,192$0.03 / $0.03 / $0.15NoTextSchematron V2 Turbo

Prompt caching tips for Dify workflows

Dify Chatflows and Knowledge Retrieval workflows frequently send a large static system prompt before dynamic user variables. Place static instructions and reference schemas first and append dynamic variables ({{#sys.query#}}, retrieved chunks) at the end so prefix caching triggers automatically on deepseek-v4.1-flash-1017 and moonshotai/kimi-k3.1-pro. Do not pass prompt_cache_key to deepseek-v4.1-flash-1017. Estimate your workflow savings with the Prompt cache calculator.

Troubleshooting

  • 401 Unauthorized: Confirm your API key starts with inf_sk_ and has no leading or trailing spaces in Dify's Model Provider settings.
  • 404 Not Found or HTML error page: Set API endpoint URL to https://api.inference.net/v1, not https://inference.net/v1 and not https://api.inference.net/v1/chat/completions.
  • Model not found: Keep exact owner prefixes from GET https://api.inference.net/v1/models, including moonshotai/kimi-k3.1-pro and inference-net/schematron-v2-small.
  • Agent node fails to invoke tools: Select a model with supports_tools: true (deepseek-v4.1-flash-1017, glm-5.3, glm-5.3-flash, or moonshotai/kimi-k3.1-pro) and set Function calling to Tool Call in Dify's model settings. Do not assign Schematron models to tool-calling Agent nodes.
  • Timeouts on self-hosted Dify: Increase PLUGIN_MAX_EXECUTION_TIMEOUT and reverse-proxy read timeouts when generating long outputs with glm-5.3 or moonshotai/kimi-k3.1-pro.

Browse all supported editors, workflow builders, gateways, and SDKs in the Integrations hub.

Start building

One OpenAI-compatible API key for fast open-weight models.