The MiniMax unofficial Go library.
go get github.com/Twacqwq/go-minimax
go-minimax requires Go version 1.18 or greater.
- Chatcompletion pro
- Chatcompletion
- Embeddings
- T2A
- T2A pro
- T2A large
- T2A Stream
- Voice Cloning
- Assistants API
- Thread
- Run
- Message
- Files
- Retrieval
- Finetune API
- Role Classification
- Role Audio Generation
package main
import (
"context"
"fmt"
minimax "github.com/Twacqwq/go-minimax"
)
func main() {
client := minimax.NewClient("your token", "your group id")
resp, err := client.CreateCompletion(context.Background(), &minimax.ChatCompletionRequest{
Model: minimax.Abab5Dot5,
TokensToGenerate: 1024,
RoleMeta: &minimax.RoleMeta{
UserName: "我",
BotName: "专家",
},
Prompt: "你是一个擅长发现故事中蕴含道理的专家,你很善于基于我给定的故事发现其中蕴含的道理。",
Messages: []minimax.Message{
{
SenderType: minimax.ChatMessageRoleUser,
Text: "Please introduce yourself.",
},
},
})
if err != nil {
panic(err)
}
fmt.Printf("%v\n", resp.Reply)
}
package main
import (
"context"
"errors"
"fmt"
"io"
minimax "github.com/Twacqwq/go-minimax"
)
func main() {
client := minimax.NewClient("your token", "your group id")
stream, err := client.CreateCompletionStream(context.Background(), &minimax.ChatCompletionRequest{
Model: minimax.Abab5Dot5,
TokensToGenerate: 1024,
RoleMeta: &minimax.RoleMeta{
UserName: "我",
BotName: "专家",
},
Prompt: "你是一个擅长发现故事中蕴含道理的专家,你很善于基于我给定的故事发现其中蕴含的道理。",
Messages: []minimax.Message{
{
SenderType: minimax.ChatMessageRoleUser,
Text: "Please introduce yourself.",
},
},
})
if err != nil {
panic(err)
}
defer stream.Close()
for {
resp, err := stream.Recv()
if err != nil {
if errors.Is(err, io.EOF) {
break
}
panic(err)
}
fmt.Printf("%#v\n", resp)
}
}
package main
import (
"context"
"errors"
"fmt"
"io"
minimax "github.com/Twacqwq/go-minimax"
)
func main() {
client := minimax.NewClient("your token", "your group id")
res, err := client.CreateCompletionPro(context.Background(), &minimax.ChatCompletionProRequest{
Model: minimax.Abab6,
TokensToGenerate: 1024,
Messages: []minimax.ProMessage{
{
SenderType: minimax.ChatMessageRoleUser,
SenderName: "Twac",
Text: "请介绍一下你自己",
},
},
})
if err != nil {
t.Fatal(err)
}
fmt.Printf("%#v\n", res)
}
package main
import (
"context"
"errors"
"fmt"
"io"
minimax "github.com/Twacqwq/go-minimax"
)
func main() {
client := minimax.NewClient("your token", "your group id")
stream, err := client.CreateCompletionProStream(context.Background(), &minimax.ChatCompletionProRequest{
Model: minimax.Abab6,
TokensToGenerate: 1024,
Messages: []minimax.ProMessage{
{
SenderType: minimax.ChatMessageRoleUser,
SenderName: "Twac",
Text: "请介绍一下你自己",
},
},
})
if err != nil {
panic(err)
}
defer stream.Close()
for {
resp, err := stream.Recv()
if err != nil {
if errors.Is(err, io.EOF) {
break
}
panic(err)
}
fmt.Printf("%#v\n", resp)
}
}
package main
import (
"context"
"fmt"
minimax "github.com/Twacqwq/go-minimax"
)
func main() {
client := minimax.NewClient("your token", "your group id")
resp, err := client.CreateEmbeddings(context.Background(), &minimax.CreateEmbeddingsRequest{
Texts: []string{"hello"},
// Type: minimax.EmbeddingsDbType,
Type: minimax.EmbeddingsQueryType,
})
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", resp)
}
package main
import (
"context"
"fmt"
minimax "github.com/Twacqwq/go-minimax"
)
func main() {
client := minimax.NewClient("your token", "your group id")
resp, err := client.CreateTextToSpeech(context.Background(), &minimax.CreateT2ARequest{
Text: "hello",
VoiceId: "female-yujie",
Path: "./",
Name: "hello.mp3",
})
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", resp)
}
package main
import (
"context"
"fmt"
minimax "github.com/Twacqwq/go-minimax"
)
func main() {
client := minimax.NewClient("your token", "your group id")
resp, err := client.CreateTextToSpeechPro(context.Background(), &minimax.CreateT2ARequest{
Text: "hello",
VoiceId: "female-yujie",
})
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", resp)
}