Skip to content

Commit 454e0d4

Browse files
committed
feat: go doc added
1 parent 940600e commit 454e0d4

File tree

7 files changed

+48
-13
lines changed

7 files changed

+48
-13
lines changed

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
# Go Client - Deepseek API
1+
# Go-Deepseek -- Go Client for [Deepseek API](https://api-docs.deepseek.com/)
22

3-
### Why yet another Go client?
3+
## Demo
44

5-
We needed to call the DeepSeek API from one of our Go services but couldn't find a complete and reliable Go client, so we built our own.
5+
Left side -- https://chat.deepseek.com/
66

7-
### Why this Go client is best?
7+
Right side -- [deepseek-demo](https://github.com/go-deepseek/deepseek-demo)
88

9-
Because this Go client is not only complete and reliable but also simple and performant.
9+
https://github.com/user-attachments/assets/baa05145-a13c-460d-91ce-90129c5b32d7
10+
11+
## Why yet another Go client?
12+
13+
We needed to call the DeepSeek API from one of our Go services but couldn't find a complete and reliable Go client, so we built our own.
14+
15+
## Why this Go client is better?
1016

1117
- **Complete** – It offers full support for all APIs, including their complete request and response payloads. (Note: Beta feature support coming soon.)
1218

@@ -21,14 +27,6 @@ Because this Go client is not only complete and reliable but also simple and per
2127
go get github.com/go-deepseek/deepseek
2228
```
2329

24-
## Demo
25-
26-
Left side -- https://chat.deepseek.com/
27-
28-
Right side -- [deepseek-demo](https://github.com/go-deepseek/deepseek-demo)
29-
30-
https://github.com/user-attachments/assets/baa05145-a13c-460d-91ce-90129c5b32d7
31-
3230
## Usage
3331

3432
Here’s an example of sending a "Hello Deepseek!" message using `model=deepseek-chat` and `stream=false`
@@ -67,6 +65,23 @@ func main() {
6765
}
6866
```
6967

68+
Try above example:
69+
```
70+
First copy above code in `main.go`
71+
72+
$ go mod init
73+
$ go get github.com/go-deepseek/deepseek
74+
75+
$ go run main.go
76+
output => Hello! How can I assist you today? 😊
77+
```
78+
7079
## Examples
7180

7281
Please check the [examples](examples/) directory, which showcases each feature of this client.
82+
83+
![examples](docs/examples_directory.png)
84+
85+
## Buy me a GitHub Star ⭐
86+
87+
If you like our work then please give github star to this repo. 😊

config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package config
22

3+
// Config for deepseek client.
4+
//
5+
// ApiKey - deepseek API key.
6+
// TimeoutSeconds - http client timeout used by deepseek client.
7+
// DisableRequestValidation - disable request validation by deepseek client.
38
type Config struct {
49
ApiKey string
510
TimeoutSeconds int

deepseek.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,27 @@ const (
1717
)
1818

1919
type Client interface {
20+
// CallChatCompletionsChat calls chat api with model=deepseek-chat and stream=false.
21+
// It returns response from DeepSeek-V3 model.
2022
CallChatCompletionsChat(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error)
23+
24+
// CallChatCompletionsReasoner calls chat api with model=deepseek-reasoner and stream=false.
25+
// It returns response from DeepSeek-R1 model.
2126
CallChatCompletionsReasoner(ctx context.Context, chatReq *request.ChatCompletionsRequest) (*response.ChatCompletionsResponse, error)
2227

28+
// StreamChatCompletionsChat calls chat api with model=deepseek-chat and stream=true.
29+
// It returns response from DeepSeek-V3 model.
2330
StreamChatCompletionsChat(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error)
31+
32+
// StreamChatCompletionsChat calls chat api with model=deepseek-reasoner and stream=true.
33+
// It returns response from DeepSeek-R1 model.
2434
StreamChatCompletionsReasoner(ctx context.Context, chatReq *request.ChatCompletionsRequest) (response.StreamReader, error)
2535

36+
// PingChatCompletions is a ping to check go deepseek client is working fine.
2637
PingChatCompletions(ctx context.Context, inputMessage string) (outputMessge string, err error)
2738
}
2839

40+
// NewClient creates deeseek client with given api key.
2941
func NewClient(apiKey string) (Client, error) {
3042
config := config.Config{
3143
ApiKey: apiKey,
@@ -34,6 +46,7 @@ func NewClient(apiKey string) (Client, error) {
3446
return NewClientWithConfig(config)
3547
}
3648

49+
// NewClient creates deeseek client with given client config.
3750
func NewClientWithConfig(config config.Config) (Client, error) {
3851
return client.NewClient(config)
3952
}

docs/examples_directory.png

9.78 KB
Loading
File renamed without changes.

request/request.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const (
1212
ResponseFormatJsonObject = "json_object"
1313
)
1414

15+
// ChatCompletionsRequest is request payload for `POST /chat/completions` API.
1516
type ChatCompletionsRequest struct {
1617
Messages []*Message `json:"messages"`
1718
Model string `json:"model"`

response/response.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package response
22

3+
// ChatCompletionsResponse is response payload for `POST /chat/completions` API.
34
type ChatCompletionsResponse struct {
45
Id string `json:"id"`
56
Choices []*Choice `json:"choices"`

0 commit comments

Comments
 (0)