Dify + Claude and GPT: Model Provider Setup with One API Key
As of 2026-11-25, the cleanest way to run Claude and GPT models inside Dify is to install two model provider plugins and give both the same QCode key: the Anthropic plugin with API URL https://api.qcode.cc/api for Claude, and the OpenAI-API-compatible plugin with base URL https://api.qcode.cc/openai/v1 for GPT-6.2 and Chinese models such as GLM, DeepSeek, Qwen and Kimi. This guide covers a five-minute path on Dify Cloud, a self-hosted Docker setup, a sample multi-model chatflow, team configuration and the errors people actually hit.
QCode is an independent third-party API service. It is not operated by, endorsed by, or partnered with Dify (LangGenius), Anthropic, OpenAI or any model vendor. Plugin field names below come from the plugins' published source and Dify's documentation; QCode endpoint rules come from docs.qcode.cc.
Updated 2026-11-26
Key facts
- Two plugins, one key. Claude models are served only on QCode's Anthropic Messages endpoint, so they go through Dify's Anthropic plugin. GPT models are served only on the OpenAI endpoint. Chinese models work on either, and the OpenAI-API-compatible plugin is the simplest place for them.
- URLs. Anthropic plugin →
https://api.qcode.cc/api(no/v1; the Anthropic SDK inside the plugin adds/v1/messages). OpenAI-API-compatible →https://api.qcode.cc/openai/v1(no trailing slash, no/chat/completions). - Model IDs must match /models exactly, e.g.
claude-sonnet-5-5($2 / $10 per million tokens),claude-haiku-5-5($0.10 / $0.50 for prompts up to 100K tokens),claude-opus-5-5($4 / $20),gpt-6.2-sol($2 / $10). - Billing. QCode price = official API price × service multiplier, currently ×1.0 for Anthropic and OpenAI models.
- Embeddings. A Dify knowledge base needs a Text Embedding model, configured from a provider that serves one (an official embedding API you already pay for, or a local model via Ollama, for example). Check /models for what QCode currently lists, and test an embedding setup with a small request before relying on it.
Fastest path: Dify Cloud in about five minutes
If you only want to see Claude answer inside a Dify app, skip Docker:
- Sign in to Dify Cloud and open Integrations → Model Provider (in older layouts: avatar → Settings → Model Provider).
- Search Anthropic, click Install, then open the plugin's setup.
- Enter API Key = your
cr_key and API URL =https://api.qcode.cc/api. Save. Dify validates the credentials on save. - Go to Studio → Create from Blank → Chatbot, pick
claude-sonnet-5-5in the model selector, and send a message in the debug panel.
That's it for Claude. Add the OpenAI-API-compatible plugin (section 3) when you want GPT or Chinese models in the same workspace.
Prerequisites
| Item | What you need |
|---|---|
| Dify | Dify Cloud, or self-hosted with a current Docker Compose release; check Dify's install guide for the supported version |
| Hardware (self-hosted) | At least 2 CPU cores and 4 GiB RAM, per Dify's install guide |
| Permissions | Workspace Owner or Admin (only these roles manage model providers) |
| QCode key | A cr_-prefixed key from the QCode dashboard; for teams, one sub-key per workspace or app |
| Network | The Dify server must reach api.qcode.cc (or asia.qcode.cc / us.qcode.cc) over HTTPS |
Test the key once with curl before you touch Dify. If this works, every later problem is a Dify setting:
curl -sS https://api.qcode.cc/openai/v1/chat/completions \
-H "Authorization: Bearer cr_your_key" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-6.2-sol","messages":[{"role":"user","content":"ping"}]}'
Self-hosted Dify with Docker Compose
git clone --branch <release-tag> --depth 1 https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
# Dify's guide asks for a random token in .env:
openssl rand -hex 32 # paste into DIFY_AGENT_LOCAL_SANDBOX_AUTH_TOKEN
docker compose up -d
docker compose ps --all
Open http://localhost/install to create the admin account, then sign in at http://localhost (port 80 by default). On Windows, run Docker Desktop with the WSL 2 backend and keep the dify folder inside WSL for better file performance. The first start is slow while images download. Provider credentials are stored in Dify's database, so they survive restarts; deleting the data volumes deletes them along with apps and accounts.
Add Claude: the Anthropic plugin
- Integrations → Model Provider, search Anthropic, Install. The plugin comes from the Dify Marketplace.
- Open its settings and fill in the provider credentials:
| Field (plugin label) | Value |
|---|---|
| API Key | cr_your_key |
| API URL | https://api.qcode.cc/api |
| Enable request metadata | Disabled (default) |
- Save. The plugin's built-in list already includes
claude-fable-5-2,claude-opus-5-5,claude-sonnet-5-5,claude-haiku-5-5and older IDs, so the models appear without manual entry. - Only enable models you want people to pick. Fewer choices means fewer surprise bills.
Why no /v1? The plugin passes API URL straight to the official Anthropic Python SDK as base_url (trailing slashes are stripped), and the SDK appends /v1/messages itself. https://api.qcode.cc/api/v1 would become /api/v1/v1/messages and return 404. If your plugin build behaves differently, send one test message from the provider settings before rolling it out.
Want to pin a model or use a separate key for one model? The plugin also supports customizable models: add a model with Model Name claude-opus-5-5 and its own API Key / API URL. This is useful for teams (see section 6).
Add GPT and Chinese models: the OpenAI-API-compatible plugin
Search OpenAI-API-compatible (not the plain "OpenAI" plugin), install it, click Add Model, and fill in:
| Field | Value for GPT | Value for a Chinese model |
|---|---|---|
| Model Type | LLM | LLM |
| Model Name | gpt-6.2-sol |
glm-5.3 (or deepseek-v4-pro, qwen3.8-max, kimi-k3) |
| Model display name | optional, e.g. "GPT-6.2 Sol (QCode)" | optional |
| API Key | cr_your_key |
same key |
| API Base URL | https://api.qcode.cc/openai/v1 |
same |
| Completion mode | Chat | Chat |
| Model context size | the model's real limit; leave a conservative value such as 128000 if unsure | per /models |
| Upper bound for max tokens | raise from the 4096 default if you need long answers | same |
| Function Call Type | Tool Call (needed for Agent apps) | Tool Call, test first |
| Vision Support | Support, if you send images | per model |
| API Type | chat_completions (default) | chat_completions |
Click Add; Dify validates the key. Then open Show Models and confirm the row is toggled on. Repeat Add Model for each ID. Finally, set Default Models → System Reasoning Model (for example gpt-6.2-sol or claude-haiku-5-5), or apps created before that may fail with "Configure a default system model".
Do not add Claude IDs to this plugin. QCode rejects Claude on the OpenAI path with model_not_available_on_endpoint.
Sample workflow: a two-model support chatflow
A common pattern is to route cheap work to a small model and hard work to a strong one:
- Studio → Create from Blank → Chatflow.
- Start → Question Classifier using
claude-haiku-5-5, with classes "technical", "billing", "other". - Technical branch → LLM node with
claude-sonnet-5-5and a system prompt containing your product docs (or a Knowledge Retrieval node, see the embeddings note below). - Billing branch → LLM node with
gpt-6.2-solthat drafts a polite reply from a template. - Other branch → LLM node with
glm-5.3for short answers. - All branches → Answer. Publish, then call the app from your own backend:
curl -X POST 'http://localhost/v1/chat-messages' \
-H 'Authorization: Bearer app-your-dify-app-key' \
-H 'Content-Type: application/json' \
-d '{"inputs":{},"query":"How do I reset my password?","response_mode":"blocking","user":"user-001"}'
The classifier call on Haiku costs a fraction of a cent per message at $0.10 / $0.50 per million tokens (prompts up to 100K), so most of your spend goes to the branch that does real work. Check per-model usage in the QCode dashboard (usage query guide).
Embeddings note. Knowledge Retrieval needs a Text Embedding model in the knowledge base settings. Configure embeddings from a provider that serves them (an official embedding API you already pay for, or a local embedding model served by Ollama, for example) and keep QCode for the chat models. Check /models for what QCode currently lists, and test the embedding setup with a small request first. The OpenAI-API-compatible plugin can hold embedding models too, but only point it at a service that actually serves them.
Team setup: one bill, separate keys
Dify credentials live at the workspace level: every Editor in the workspace can use the models an Owner or Admin configured, without seeing the key. That matches QCode's team plan well:
- One sub-key per workspace (e.g. "support", "marketing", "R&D"). Set each workspace's provider credentials with its own sub-key, and set a credit cap per sub-key in the QCode admin console.
- Per-model keys when one model is expensive: add
claude-opus-5-5as a customizable model with a separate sub-key, so Opus usage shows up on its own line. - Rotate without downtime. Replace the API Key on the provider card and save; apps keep working because they reference the model, not the key. See shared keys for teams for rotation habits.
- Data handling. QCode states that its relay layer does not store request content. Your own Dify database still stores conversations and logs, so apply your retention rules there.
- Pick the right endpoint. Asian servers can use
asia.qcode.cc, US/EU serversus.qcode.cc, with the same key and paths. Change the URL on the provider card and save to re-validate.
Errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| 401 / "Credentials validation failed" | Key copied with spaces or quotes, or plan inactive | Re-paste the cr_ key; check plan status in the QCode console |
| 404 on the Anthropic plugin | API URL ends with /v1 or /v1/messages |
Use exactly https://api.qcode.cc/api |
| 404 on OpenAI-API-compatible | Base URL includes /chat/completions |
Use exactly https://api.qcode.cc/openai/v1 |
model_not_available_on_endpoint |
Claude ID added to the OpenAI-compatible plugin | Move Claude to the Anthropic plugin |
| "Set up api-key or add model to use" | Plugin installed, no model added | Click Add Model and fill all fields |
| "Configure a default system model to run applications" | No System Reasoning Model | Set it under Default Models |
| Model missing from the app's picker | Model toggled off in Show Models | Turn it on and reload the app |
400 on claude-opus-5-5 mentioning thinking |
The plugin version and the model disagree on the thinking parameter | Update the Anthropic plugin; use claude-sonnet-5-5 until it is fixed |
| Knowledge base asks for an embedding model | No Text Embedding provider | Add an embedding provider (see section 5) |
| Agent app never calls tools | Function Call Type left at "no_call" | Set Tool Call on the model, or use a Claude model |
| Long answers cut off or time out | Max tokens upper bound too low, or long generation | Raise the upper bound; stream responses in your client |
FAQ
Which Dify plugin should I use for Claude?
Use the Anthropic plugin with API URL https://api.qcode.cc/api. QCode serves Claude only on the Anthropic Messages protocol, so the OpenAI-API-compatible plugin cannot reach Claude models.
Can one QCode key serve both plugins?
Yes. The same cr_ key works on the Anthropic and OpenAI endpoints; the request path decides the protocol. Teams usually still create separate sub-keys per workspace for clearer usage reports.
Does QCode provide embedding models for Dify knowledge bases?
Check /models for the current list. A Dify knowledge base needs a Text Embedding model, so configure one with a provider that serves embeddings and keep QCode for chat models; test the embedding model with a small request before relying on it.
Why does Dify say "Configure a default system model"?
Some built-in features (such as conversation naming and suggested questions) need a System Reasoning Model. Set one under Default Models; a cheap model like claude-haiku-5-5 or gpt-6.2-sol is fine.
Does this work on Dify Cloud and self-hosted Dify?
Yes. The plugin fields are the same. On self-hosted Dify, make sure the server can reach api.qcode.cc over HTTPS; on Dify Cloud, plugin installation and quotas follow Dify's own plan rules.
How much will a Dify app cost on QCode?
You pay official API prices × 1.0 for Claude and GPT, per token. For example claude-sonnet-5-5 is $2 input / $10 output per million tokens. Live prices are on /models.
Can I use GPT-6.2 Sol's Responses API in Dify?
The OpenAI-API-compatible plugin has an API Type option, but we recommend the default chat_completions with QCode's /openai/v1 base URL, which is the tested path.
Run Dify for a whole team on one bill
If several people or departments build Dify apps, QCode's team plan is designed for it: each unit gives $4,000 of monthly credit and 35 concurrent requests, with sub-keys, per-key limits and usage in one admin console. Solo builders can start with a personal plan on /pricing.