DifySDK.Extensions 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DifySDK.Extensions --version 0.2.0
                    
NuGet\Install-Package DifySDK.Extensions -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DifySDK.Extensions" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DifySDK.Extensions" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="DifySDK.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DifySDK.Extensions --version 0.2.0
                    
#r "nuget: DifySDK.Extensions, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DifySDK.Extensions@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DifySDK.Extensions&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=DifySDK.Extensions&version=0.2.0
                    
Install as a Cake Tool

DifySDK.Extensions

Registers all Dify Service API Refit clients with source-generated JSON serialization and Authorization: Bearer API-key authentication.

Install

dotnet add package DifySDK.Extensions

Register with dependency injection

using DifySDK.Extensions;

services.AddDifyApi(configuration);
{
  "DifyApi": {
    "BaseAddress": "https://api.dify.ai/v1/",
    "ApiKey": "app-your-api-key"
  }
}

Then inject a typed API interface and make requests:

using DifySDK.Chats;
using DifySDK.Models;

public sealed class ChatService(IDifyChatApi chat)
{
    public async Task<string?> AskAsync(string question, CancellationToken cancellationToken)
    {
        var response = await chat.SendAsync(new ChatMessageRequest
        {
            Query = question,
            User = "user-123"
        }, cancellationToken: cancellationToken);

        return response.Answer;
    }
}

Select an application per request

When one process calls multiple Dify applications, register an IDifyApplicationCredentialResolver. Passing DifyRequestContext through the Refit [Property] parameter selects that application's base address and API key for only this request.

using DifySDK;
using DifySDK.Chats;
using DifySDK.Models;

var response = await chat.SendAsync(
    new ChatMessageRequest
    {
        Query = "Hello",
        User = "user-123"
    },
    context: new DifyRequestContext { ApplicationId = "support-bot" },
    cancellationToken: cancellationToken);

Create a client set for one application

IDifyClientFactory creates an isolated set of all typed API clients for an application:

using DifySDK.Extensions;

var client = await clientFactory.CreateAsync("support-bot", cancellationToken);
var info = await client.Application.GetInfoAsync(cancellationToken: cancellationToken);
var answer = await client.Chat.SendAsync(new ChatMessageRequest
{
    Query = "Hello",
    User = "user-123"
}, cancellationToken: cancellationToken);
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DifySDK.Extensions:

Package Downloads
DifySDK.ConsoleApi.Extensions

A typed .NET client for the Dify API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.1 120 7/13/2026
0.2.0 116 7/11/2026
0.1.1 109 7/11/2026