Skip to content

JLay2026/asksage-dify-plugin

Repository files navigation

AskSage Model Provider Plugin for Dify

A Dify plugin that integrates AskSage as a model provider, giving you access to 47+ AI models (GPT, Claude, Gemini, Llama, Groq, and more) through AskSage's FedRAMP-authorized API.

Features

  • 47+ predefined models auto-generated from AskSage's model catalog
  • Custom model support -- add any model your AskSage tenant provides
  • Dynamic model discovery -- fetches available models from the API at runtime with 5-minute caching
  • Token usage tracking -- reports prompt and completion tokens back to Dify
  • Simulated streaming -- works with Dify's streaming UI even though AskSage uses synchronous responses
  • Model generator script -- run generate_models.py to refresh model YAMLs when AskSage adds new models

Creating an AskSage Account

This plugin uses the AskSage commercial tenant at chat.asksage.com.

  1. Go to chat.asksage.com/register
  2. Fill in all required fields (first name, last name, company, email, phone, country)
  3. Submit the form -- you will receive a verification code via email
  4. Log in at chat.asksage.com with your email and password
  5. New accounts receive a free 30-day trial with 200,000 inference tokens and 200,000 training tokens

After Trial

Plan Price Tokens/Month
Bring Your Own LLMs From $15/mo/user Unlimited
Standard $30/mo/user 500K
Plus $50/mo/user 1M
Enterprise $90/mo or $990/yr 2M

Contact sales@asksage.com for enterprise pricing and volume discounts.

Getting Your API Key

  1. Sign in at chat.asksage.com
  2. Click the Settings cog (bottom left)
  3. Select the Account tab
  4. Scroll to Manage your API Keys
  5. Generate a new key -- save it securely (you will need it for the plugin)

For MFA setup, we recommend Microsoft Authenticator or Google Authenticator. Configure it in the same Account settings page.

Requirements

Component Version
Dify 1.0+ with Plugin Daemon
Dify Plugin Daemon 0.5.5+ (see known issues)
Dify Plugin SDK (dify_plugin) 0.5.x (must match daemon)
Python 3.12
AskSage Account With API key access

Important: The dify_plugin SDK version must match your Plugin Daemon version. If your daemon is 0.5.3, install dify_plugin>=0.5.0,<0.6.0. A version mismatch (e.g., SDK 0.7.x with daemon 0.5.x) will cause silent connection failures.

Installation

Option A: Install from Dify Marketplace (recommended)

The plugin is published to the Dify Marketplace. Marketplace packages are signed by Dify and install cleanly without any host-side configuration.

  1. In Dify, go to Plugins (top right)
  2. Click Explore Marketplace (or visit the listing directly)
  3. Search for AskSage and click Install
  4. Configure credentials (see below)

This is the path 99% of users want. Skip to Credential Setup below.

Option B: Install from .difypkg (offline / pre-release builds)

Use this path only when:

  • Your Dify instance is air-gapped and can't reach the Marketplace
  • You're testing an unreleased build of the plugin
  • You need to install a version that's no longer on the Marketplace

Verify Your Daemon Version First

Dify 1.13.3 ships with dify-plugin-daemon:0.5.3-local by default, which has a bug that breaks .difypkg installation. You must upgrade the daemon to 0.5.5+ before installing any local plugin package.

In your docker-compose.yaml (e.g. C:\dify\docker\docker-compose.yaml), find the plugin_daemon service and update the image:

  plugin_daemon:
    # IMPORTANT: Daemon 0.5.3 has a struct-tag bug that rejects
    # plugin_unique_identifier on the /decode/from_identifier endpoint.
    # This was fixed in 0.5.5 via dify-plugin-daemon PR #593.
    # See: https://github.com/langgenius/dify-plugin-daemon/pull/593
    image: langgenius/dify-plugin-daemon:0.5.5-local

Then restart the daemon:

cd C:\dify\docker
docker compose up -d plugin_daemon

Disable Signature Verification for Unsigned Packages

Dify rejects unsigned .difypkg files by default with the error: "plugin verification has been enabled, and the plugin you want to install has a bad signature". Local builds and GitHub Release downloads are unsigned from Dify's perspective.

To allow installation, append the following to your docker/.env:

FORCE_VERIFYING_SIGNATURE=false

Then restart Dify:

cd docker
docker compose down
docker compose up -d

Warning: This disables signature checks for all plugins on this Dify instance, not just AskSage. For shared or multi-tenant deployments, prefer Option A or set up third-party key allow-listing (THIRD_PARTY_SIGNATURE_VERIFICATION_ENABLED + THIRD_PARTY_SIGNATURE_VERIFICATION_PUBLIC_KEYS) instead.

Upload Steps

  1. Download asksage-X.Y.Z.difypkg from the Releases page
  2. In Dify, go to Plugins (top right)
  3. Click Install Plugin
  4. Upload the .difypkg file
  5. Configure credentials (see below)

Option C: Remote debugging (development)

  1. Clone this repo:

    git clone https://github.com/JLay2026/asksage-dify-plugin.git
    cd asksage-dify-plugin
    
  2. Create a virtual environment:

    py -3.12 -m venv .venv
    .\.venv\Scripts\Activate.ps1    # Windows
    source .venv/bin/activate        # Linux/Mac
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Copy .env.example to .env and fill in your debug key:

    INSTALL_METHOD=remote
    REMOTE_INSTALL_HOST=localhost
    REMOTE_INSTALL_PORT=5003
    REMOTE_INSTALL_KEY=your-debug-key-from-dify
    

    To find your debug key: Dify UI > Plugins > click the bug icon > copy Debug Key.

  5. Run the plugin:

    python -m main
    

Credential Setup

After installing the plugin, configure it in Dify:

  1. Go to Settings > Model Providers
  2. Find AskSage and click it
  3. Enter the following:
Field Description
API Key Your AskSage static API key. Find it at Settings > Account > Manage your API Keys in the AskSage app.
Email The email address associated with your AskSage account.
API Base URL Default: https://api.asksage.ai. Only change if you use a custom AskSage deployment.
  1. Click Save -- the plugin validates your credentials by calling AskSage's /server/get-models endpoint.

Refreshing Models

When AskSage adds new models to your tenant:

python generate_models.py

This calls /server/get-models, generates a YAML file for each model, and updates _position.yaml. Image-generation models are automatically filtered out. Restart the plugin or reinstall the .difypkg to pick up the changes.

Project Structure

asksage/
├── _assets/                    # Provider icons (SVG)
├── models/llm/
│   ├── _position.yaml          # Model display order
│   ├── *.yaml                  # One file per predefined model
│   └── llm.py                  # LLM implementation (core logic)
├── provider/
│   ├── asksage.yaml            # Provider config and credential schemas
│   └── asksage.py              # Credential validation
├── manifest.yaml               # Plugin manifest
├── main.py                     # Entry point
├── generate_models.py          # Model YAML generator script
├── requirements.txt            # Python dependencies
└── .env.example                # Environment template

Plugin Update Procedures

When the plugin code is updated (new features, model changes, bug fixes), the update process depends on how you installed the plugin.

Marketplace Install

If you installed via the Dify Marketplace, updates appear automatically in the Plugins page when a new version is published. Click Update to upgrade in place — credentials are preserved.

Packaged Install (.difypkg)

If you installed via a .difypkg upload, you must repackage and reinstall:

  1. Pull the latest code:

    cd C:\projects\asksage_plugin_dify\asksage
    git pull origin main
  2. Bump the version in manifest.yaml — the daemon rejects reinstalls at the same version:

    # Example: 0.1.0 → 0.2.0
    (Get-Content manifest.yaml -Raw) -replace 'version: 0.1.0', 'version: 0.2.0' |
      Set-Content manifest.yaml -NoNewline -Encoding ([System.Text.UTF8Encoding]::new($false))
  3. Repackage — run from the parent directory, not from inside the plugin folder:

    cd C:\projects\asksage_plugin_dify
    & "$HOME\bin\dify.exe" plugin package .\asksage

    This writes asksage.difypkg to C:\projects\asksage_plugin_dify\. If you get "Access is denied", you are likely in a directory you don't have write access to (e.g. C:\).

  4. Uninstall the old version in the Dify console: Plugins → find AskSage → delete/uninstall.

  5. Upload the new .difypkg: PluginsInstall Plugin → upload the new file.

  6. Re-enter credentials — API key and base URL do not carry over between installs. Go to the AskSage provider settings and re-enter them.

Debug Mode

If you are running in debug mode (local Python process), updates are simpler:

  1. Pull the latest code:

    cd C:\projects\asksage_plugin_dify\asksage
    git pull origin main
  2. Restart the plugin — stop the running process (Ctrl+C) and relaunch:

    .\.venv\Scripts\Activate.ps1
    python -m main

    Dify picks up updated model YAMLs and code on reconnect. No version bump or repackaging required.

Tip: Use debug mode during active development. Switch to .difypkg for production or team distribution.

Known Issues -- Daemon 0.5.3

Dify 1.13.3's default docker-compose.yaml pins langgenius/dify-plugin-daemon:0.5.3-local, which contains a bug in the DecodePluginFromIdentifier handler. The Go struct uses a json: tag instead of a form: tag, so Gin cannot bind the plugin_unique_identifier query parameter. The result is a 400 error on /decode/from_identifier immediately after a successful .difypkg upload:

400: Key: 'PluginUniqueIdentifier' Error: Field validation for 'PluginUniqueIdentifier' failed on the 'required' tag

Fix: Upgrade to daemon 0.5.5+ (see installation instructions above).

References:

Known Limitations

  • No native streaming -- AskSage's /server/query returns complete responses. The plugin simulates streaming by yielding the full response as a single chunk.
  • No stop sequences -- AskSage does not support stop sequence parameters.
  • Token estimation -- Uses a 4-chars-per-token heuristic for pre-invocation estimates since AskSage does not expose a tokenizer endpoint. Actual usage from responses is reported accurately.
  • No function/tool calling -- AskSage's tool calling support varies by underlying model and is not yet exposed through this plugin.

License

Apache 2.0

Links

About

AskSage AI model provider plugin for Dify

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages