⚙ A simple api for dify
npm install @aiapi/difyThis documentation provides an overview of the Dify service and its available functions. The Dify service offers various functionalities for interacting with the Dify App model.
shell
installation via npm
npm install @aiapi/dify --saveinstallation via yarn
yarn add @aiapi/dify --saveinstallation via pnpm
pnpm install @aiapi/dify --save
`
API List
- Dify Custom Configuration
- Dify Completion API (Experimental Version)Dify Custom Configuration
Setup dify-compatible service with custom host settings.
$3
`typescript
import { setupDifyApi, DifyAppApiConfig } from '@aiapi/dify'const config: DifyAppApiConfig = {
customHost: 'api.dify.ai'
}
setupDifyApi(config);
`$3
-
conf (DifyAppApiConfig): An object containing the following configuration parameters:
- customHost (string): The custom host URL for the Dify service.$3
-
void
Dify Completion API (Experimental Version)
Returns a Promise that resolves to a string using the provided parameters.
$3
`typescript
import { difyCompletion, DifyCompletionCallParamsExp } from '@aiapi/dify'const params: DifyCompletionCallParamsExp = {
query: 'Your query here',
bearerKey: 'Your bearer key',
inputs: { variable1: 'value1', variable2: 'value2' },
response_mode: 'blocking', // optional, default: 'blocking'
user: 'Your username', // optional, a random string will be generated if not specified
conversationId: 'Your conversation ID' // optional, a random ID will be generated if not specified
}
const response: Promise = difyCompletion(params);
`$3
-
params (DifyCompletionCallParamsExp): An object containing the following parameters:
- query (string): The text content to be supplemented.
- bearerKey (string): AIDA application AppId.
- inputs (object): Variable content, formatted as a key-value pair object.
- response_mode (string, optional): Response mode, default is 'blocking'.
- user (string, optional): Username, if not filled, a random string will be generated.
- conversationId (string, optional): Conversation ID, if not filled, a random one will be generated.$3
-
response` (Promise