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:
| Setting | Value |
|---|---|
| Provider plugin | OpenAI-API-compatible |
| API endpoint URL | https://api.inference.net/v1 |
| US-only endpoint URL | https://us.api.inference.net/v1 |
| API key | INFERENCE_API_KEY (inf_sk_...) |
| Completion mode | Chat |
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
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.
Register a flagship Inference.net model
Fill in the Add Model dialog with the exact values from
GET https://api.inference.net/v1/models:Field Example value ( deepseek-v4.1-flash-1017)Model Type LLMModel Name deepseek-v4.1-flash-1017Model Display Name DeepSeek V4.1 Flash (Inference.net)API Key Your INFERENCE_API_KEYAPI endpoint URL https://api.inference.net/v1Completion mode ChatModel context size 1040000Upper bound for max tokens 393216Function calling Tool CallVision support YesRepeat Add Model for any additional model you want in Dify's picker, such as
glm-5.3(1048576context, text only) ormoonshotai/kimi-k3.1-pro(1048576context, text and image).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
apiandplugin_daemoncontainers toapi.inference.net:443(andus.api.inference.net:443if you pin US-only routes). - Streaming and plugin timeouts: In your Dify
.envfile, raisePLUGIN_MAX_EXECUTION_TIMEOUTandHTTP_REQUEST_MAX_READ_TIMEOUT(for example, to300seconds) 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:
{
"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 ID | Context / max output | Input / cached / output (per 1M) | Tools | Modalities | Model page |
|---|---|---|---|---|---|
deepseek-v4.1-flash-1017 | 1,040,000 / 393,216 | $0.08 / $0.007 / $0.635 | Yes | Text, image | DeepSeek V4.1 Flash |
glm-5.3 | 1,048,576 / 943,718 | $0.084 / $0.079 / $3.00 | Yes | Text | GLM-5.3 |
glm-5.3-flash | 1,048,576 / 262,144 | $0.10 / $0.03 / $0.35 | Yes | Text, image, video | GLM-5.3 Flash |
moonshotai/kimi-k3.1-pro | 1,048,576 / 1,048,576 | $1.80 / $0.198 / $9.00 | Yes | Text, image | Kimi K3.1 Pro |
inference-net/schematron-v2-small | 128,000 / 4,096 | $0.05 / $0.05 / $0.23 | No | Text | Schematron V2 Small |
inference-net/schematron-v2-turbo | 128,000 / 8,192 | $0.03 / $0.03 / $0.15 | No | Text | Schematron 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 withinf_sk_and has no leading or trailing spaces in Dify's Model Provider settings.404 Not Foundor HTML error page: Set API endpoint URL tohttps://api.inference.net/v1, nothttps://inference.net/v1and nothttps://api.inference.net/v1/chat/completions.- Model not found: Keep exact owner prefixes from
GET https://api.inference.net/v1/models, includingmoonshotai/kimi-k3.1-proandinference-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, ormoonshotai/kimi-k3.1-pro) and set Function calling toTool Callin Dify's model settings. Do not assign Schematron models to tool-calling Agent nodes. - Timeouts on self-hosted Dify: Increase
PLUGIN_MAX_EXECUTION_TIMEOUTand reverse-proxy read timeouts when generating long outputs withglm-5.3ormoonshotai/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.