https://github.com/taadis/dify-sdk-go
dify-sdk-go
https://github.com/taadis/dify-sdk-go
dify dify-client dify-client-go dify-sdk dify-sdk-go go
Last synced: 6 months ago
JSON representation
dify-sdk-go
- Host: GitHub
- URL: https://github.com/taadis/dify-sdk-go
- Owner: taadis
- Created: 2025-06-11T15:28:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-30T02:07:05.000Z (12 months ago)
- Last Synced: 2025-06-30T03:23:27.011Z (12 months ago)
- Topics: dify, dify-client, dify-client-go, dify-sdk, dify-sdk-go, go
- Language: Go
- Homepage: https://pkg.go.dev/github.com/taadis/dify-sdk-go
- Size: 19.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dify-sdk-go
This is the Go SDK for the Dify API, which allows you to easily integrate Dify into your Go applications.
## API Docs
[Dify - API Access](https://docs.dify.ai/en/openapi-api-access-readme)
## Install
```
go get github.com/taadis/dify-sdk-go
```
## Usage
After installing the SDK, you can use it in your go project like this:
```go
package main
import (
"context"
"log"
"strings"
"github.com/taadis/dify-sdk-go"
)
func main() {
ctx = context.Background()
client = dify.NewClient("your-dify-api-host", "your-api-key")
req := &dify.ChatMessageRequest{
Query: "your-question",
User: "your-user",
}
var ch chan dify.ChatMessageStreamChannelResponse
var err error
ch, err = c.Api().ChatMessagesStream(ctx, req); err != nil {
return
}
var strBuilder strings.Builder
for {
select {
case <-ctx.Done():
return
case streamData, isOpen := <-ch:
if err = streamData.Err; err != nil {
log.Println(err.Error())
return
}
if !isOpen {
log.Println(strBuilder.String())
return
}
strBuilder.WriteString(streamData.Answer)
}
}
}
```
## License
This SDK is released under the MIT License.