Skip to main content

Overview

Dify is an open-source LLM application development platform that provides visual orchestration, knowledge base, workflow, and API service capabilities, enabling you to rapidly build conversational assistants, Agents, knowledge base Q&A, and other AI applications. Dify Platform With UToken, you can invoke 100+ mainstream models (Claude, OpenAI, Gemini, Qwen, DeepSeek, Kimi, etc.) within Dify using a single API Key, while benefiting from unified billing, automatic failover, and enterprise-grade reliability.

Quick Integration

1. Navigate to Dify Model Provider Settings

  1. Log in to the Dify platform, click your username in the top-right corner → Settings
  2. Select Model Provider from the left-hand menu
  3. Locate the OpenAI-API-compatible plugin in the list and click to install
Model Provider
The OpenAI-API-compatible plugin supports multiple endpoint types including Chat, Embedding, TTS, and STT. UToken is fully compatible with all of them — a single plugin covers all models.

2. Add Model Configuration

After installing the plugin, click Add Model and fill in the following three core parameters: Add Model - Entry Point
The “Model Name” and “Model Name in API Endpoint” must be exactly identical. Incorrect values (e.g., Gemini 3.5 Flash with spaces as a friendly name) will result in 404 / model not found errors.

3. Configure Context Length and Parameters

Dify defaults to max_context = 4096, which is far below the actual capability of most modern models. Configure the context length according to each model’s specification: For the full model context specifications, refer to the Model Marketplace.

Core Features

1. Conversational Assistant

The simplest application type, ideal for customer service, knowledge Q&A, and role-playing scenarios:
  1. Create an application → Select the Conversational Assistant template
  2. Configure the system prompt:
  3. Select gpt-5.5 or claude-opus-4-7 as the model
  4. Recommended parameters: temperature = 0.7, max_tokens = 2000

2. Workflow Application

Orchestrate multiple steps into a DAG, supporting conditional branching, parallelism, and loops: Recommended node model selection:
  • Intent classification: gemini-3.5-flash (high throughput, low latency)
  • Knowledge base retrieval / embedding: text-embedding-3-large or gemini-embedding-001
  • Long-form summarization / reasoning: claude-opus-4-7 (1M context, strong reasoning)
  • Code generation: gpt-5.5 or qwen3-coder-plus

3. Knowledge Base Q&A (RAG)

  1. Create a Knowledge Base → Upload documents (PDF / Word / Markdown / TXT, etc.)
  2. Select an embedding model: text-embedding-3-large (OpenAI) is recommended
  3. Chunking strategy: Automatic paragraph-based splitting, averaging 500 tokens per chunk
  4. Reference the knowledge base in your application
  5. Configure retrieval parameters:
    • Top-K: 3–5
    • Similarity threshold: 0.7
    • Reranking: enabled (significantly improves retrieval relevance)

Application Types and Configuration Examples

Advanced Features

1. Calling Dify Applications via API

A Dify application can itself be exposed as an HTTP service for external consumption. The following example demonstrates a conversational assistant:

2. Multimodal (Image Input)

Models with vision capabilities (gpt-5.5, claude-opus-4-7, gemini-3.5-flash) can accept image inputs:

3. Batch Processing

For large-scale datasets (CSV imports, bulk document summarization, etc.), it is recommended to:
  1. Use low-cost, high-speed models (gemini-3.5-flash, gpt-5.4-mini)
  2. Set a concurrency limit on the Dify workflow to avoid saturating rate limits at once
  3. Enable result caching to avoid redundant calls for identical inputs

Model Selection Strategy

Full Scenario-Based Model Recommendations

View UToken’s scenario-based model recommendations: text generation, coding, fast response, long-context, image generation, and more.

Cost Optimization: Development vs. Production

UToken supports automatic failover at the platform level: if a provider becomes unavailable, the platform automatically routes to an equivalent model without requiring manual fallback configuration on the Dify side.

Best Practices

1. Structured Prompting

2. Workflow Design

3. Monitoring and Optimization

Review regularly:
  • ✅ User satisfaction feedback (collect thumbs up/down)
  • ⏱️ P95 response time
  • 💰 Per-call cost and daily/monthly usage trends
  • ❌ Error rate and failure cause distribution
The UToken Console provides real-time usage and cost statistics broken down by Key and model dimension for direct reconciliation.

4. Version Management

  • Export Dify application configurations (JSON / YAML) regularly for backup
  • Test new versions before publishing; use gradual rollout (canary deployment) to incrementally shift traffic
  • Retain at least N-1 versions for rapid rollback

Troubleshooting

Common Issues

401 / Invalid API Key on model invocation
  • Verify the API Key is correct (re-copy from the Console)
  • Confirm the account balance is sufficient
  • Check that the baseURL is https://utoken.yoostudio.ai/v1 (including the trailing /v1)
404 / Model Not Found
  • Verify the model name uses the canonical name (e.g., gpt-5.5 not GPT-5.5)
  • Confirm that “Model Name” and “Model Name in API Endpoint” are exactly identical
Slow Response / Streaming Output Stalling
  • Prefer Flash / Mini tier models
  • Reduce the max_tokens limit
  • Enable Dify’s result caching

Performance Optimization Reference

Deployment Recommendations

Production Environment (Self-hosted Dify) Docker Compose Example

Security Configuration

  • Store API Keys in environment variables or a Secret Manager — do not hardcode them in the Dify application configuration
  • Enable HTTPS with a reverse proxy (Nginx / Caddy / Traefik) in front
  • Enable SSO / two-factor authentication for the Dify admin panel
  • Regularly update base images and dependencies

Health Check

Metrics and Reconciliation

After integration, return to the UToken Console to view call volume, token consumption, cost breakdown, and per-model success rate metrics:
  • Model names must use canonical names (lowercase, exactly matching the official model ID)
  • Unified API endpoint: https://utoken.yoostudio.ai/v1
  • It is recommended to first validate the entire workflow with low-cost models such as gemini-3.5-flash in a test environment before switching to flagship models like claude-opus-4-7 / gpt-5.5 for production