PSDify is a PowerShell module designed to enable workspace management for Dify from the command line.
Here are some examples of what you can do with PSDify:
- ✨ Export and import apps
- ✨ Create knowledge and upload files
- ✨ Manage members: retrieve, invite, remove, and change roles
- ✨ Add models and update system models
- ✨ Search and install plugins
- ✨ Initialize instances for the Community Edition
For a full list of available cmdlets, refer to the 📚Documentation.
Warning
- 🚨 This is an unofficial project. LangGenius does not provide any support for this module.
- 🚨 It uses undocumented APIs of Dify, which means it may break with future updates to Dify.
- 🚨 The Enterprise Edition of Dify (multi-workspace environments) is not supported.
- 🚨 Currently, the focus is on "making it work." This means error handling and documentation are incomplete, and it does not strictly follow PowerShell best practices.
Note
- This module has been tested mainly against the latest version of Dify of the Community Edition and the Cloud Edition, with Windows PowerShell (PowerShell 5.1) and PowerShell 7.4.
- The Enterprise Edition of Dify (multi-workspace environments) is not supported.
For a full list of available cmdlets, refer to the 📚Documentation.
Install-Module -Name PSDify
# Authenticate with a password (for Community Edition)
Connect-Dify -AuthMethod "Password" -Server "https://dify.example.com" -Email "[email protected]"
# Authenticate with a code (for Cloud Edition)
Connect-Dify -AuthMethod "Code" -Server "https://dify.example.com" -Email "[email protected]"
# Retrieve apps
Get-DifyApp
# Export apps (as .\DSLs\*.yml)
Get-DifyApp | Export-DifyApp
# Import apps
Get-Item -Path "DSLs/*.yml" | Import-DifyApp
# Retrieve knowledge
Get-DifyKnowledge
# Create knowledge
New-DifyKnowledge -Name "My New Knowledge"
# Upload files to knowledge and wait for indexing to complete
$Knowledge = Get-DifyKnowledge -Name "My New Knowledge"
Get-Item -Path "Docs/*.md" | Add-DifyDocument -Knowledge $Knowledge -Wait
# Retrieve members
Get-DifyMember
# Invite a new member
New-DifyMember -Email "[email protected]" -Role "normal"
# Change a member's role
Get-DifyMember -Email "[email protected]" | Set-DifyMemberRole -Role "editor"
# Retrieve models
Get-DifyModel
# Add a predefined model
New-DifyModel -Provider "openai" -From "predefined" `
-Credential @{
"openai_api_key" = "sk-proj-****************"
}
# Add a customizable model
New-DifyModel -Provider "openai" -From "customizable" `
-Type "llm" -Name "gpt-4o-mini" `
-Credential @{
"openai_api_key" = "sk-proj-****************"
}
# Update the system model
Set-DifySystemModel -Type "llm" -Provider "openai" -Name "gpt-4o-mini"
# Search plugins
Find-DifyPlugin -Id "langgenius/openai"
# Install a plugin and wait for it to be installed
Find-DifyPlugin -Id "langgenius/openai" | Install-DifyPlugin -Wait
# Get installed plugins
Get-DifyPlugin
# Start a Dify instance with Docker Compose
docker compose up -d
# Wait for the instance to be ready
Wait-Dify -Server "https://dify.example.com"
# Initialize the instance
Initialize-Dify -Server "https://dify.example.com" -Email "[email protected]" -Name "Dify"