Skip to content

Commit b5c47f3

Browse files
lgrammelwarmwind
andauthored
feat (docs): add Dify community provider (#4084) (#6067) (#6103)
## Background The Dify provider allows developers to easily integrate Dify's application workflow with their applications using the Vercel AI SDK. ## Summary This PR adds the Dify provider documentation to the AI SDK, enabling users to understand how to implement and use the Dify integration. ## Tasks - [x] Documentation has been added for the Dify provider - [x] Installation instructions are included - [x] Usage examples for both cloud and self-hosted instances are provided ## Related Issues [Support Dify Provider](#4084) Co-authored-by: Oscar Jiang <[email protected]>
1 parent 33f908b commit b5c47f3

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

content/docs/02-foundations/02-providers-and-models.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The open-source community has created the following providers:
7272
- [Spark Provider](/providers/community-providers/spark) (`spark-ai-provider`)
7373
- [AnthropicVertex Provider](/providers/community-providers/anthropic-vertex-ai) (`anthropic-vertex-ai`)
7474
- [LangDB Provider](/providers/community-providers/langdb) (`@langdb/vercel-provider`)
75+
- [Dify Provider](/providers/community-providers/dify) (`dify-ai-provider`)
7576
- [Sarvam Provider](/providers/community-providers/sarvam) (`sarvam-ai-provider`)
7677

7778
## Self-Hosted Models
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: Dify
3+
description: Learn how to use the Dify provider for the AI SDK.
4+
---
5+
6+
# Dify Provider
7+
8+
The **[Dify provider](https://github.com/warmwind/dify-ai-provider)** allows you to easily integrate Dify's application workflow with your applications using the AI SDK.
9+
10+
## Setup
11+
12+
The Dify provider is available in the `dify-ai-provider` module. You can install it with:
13+
14+
```bash
15+
npm install dify-ai-provider
16+
17+
# pnpm
18+
pnpm add dify-ai-provider
19+
20+
# yarn
21+
yarn add dify-ai-provider
22+
```
23+
24+
## Provider Instance
25+
26+
You can import `difyProvider` from `dify-ai-provider` to create a provider instance:
27+
28+
```ts
29+
import { difyProvider } from 'dify-ai-provider';
30+
```
31+
32+
## Example
33+
34+
### Use dify.ai
35+
36+
```ts
37+
import { generateText } from 'ai';
38+
import { difyProvider } from 'dify-ai-provider';
39+
40+
const dify = difyProvider('dify-application-id', {
41+
responseMode: 'blocking',
42+
apiKey: 'dify-api-key',
43+
});
44+
45+
const { text, providerMetadata } = await generateText({
46+
model: dify,
47+
messages: [{ role: 'user', content: 'Hello, how are you today?' }],
48+
headers: { 'user-id': 'test-user' },
49+
});
50+
51+
const { conversationId, messageId } = providerMetadata.difyWorkflowData;
52+
console.log(text);
53+
console.log('conversationId', conversationId);
54+
console.log('messageId', messageId);
55+
```
56+
57+
### Use self-hosted Dify
58+
59+
```typescript
60+
import { createDifyProvider } from 'dify-ai-provider';
61+
62+
const difyProvider = createDifyProvider({
63+
baseURL: 'your-base-url',
64+
});
65+
66+
const dify = difyProvider('dify-application-id', {
67+
responseMode: 'blocking',
68+
apiKey: 'dify-api-key',
69+
});
70+
```
71+
72+
## Documentation
73+
74+
Please refer to the **[Dify provider documentation](https://github.com/warmwind/dify-ai-provider)** for more detailed information.

0 commit comments

Comments
 (0)