大语言模型 MiniMax API
- 全接口字段注释
- Chatcompletion 文本对话接口
- Embeddings 向量化接口
- T2A 文本转语音接口
- 无缝对接官方文档:单轮问答、历史记忆问答、流返回
- 支持Swagger文档 和 ApiFox 文档
![image](https://private-user-images.githubusercontent.com/50035229/247887184-cafe6492-2375-4b6f-9dcf-e651c06aa94a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3MjUzMDYsIm5iZiI6MTcyNTcyNTAwNiwicGF0aCI6Ii81MDAzNTIyOS8yNDc4ODcxODQtY2FmZTY0OTItMjM3NS00YjZmLTlkY2YtZTY1MWMwNmFhOTRhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA3VDE2MDMyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTUxNDRhNjZkMjlkNjhmZDA0MzI0MTBiMDA5MDdlYjU2MTcxYzc4MmQ2Mjc3NjE0YzViZjYyMjY5ZDU4NDYzZmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.m5ylH-8IuE_GCcbxjBxIXQtEUtVKSAdat-UxA5ve19Y)
package main
import (
"context"
"fmt"
"os"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
)
func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)
//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
SenderType: "USER",
Text: "hi~",
},
},
Model: "abab5-chat",
Temperature: 0.7,
}
res, _ := client.ChatCompletions(ctx, req)
fmt.Println(res.Choices) // output: 你好!有什么我可以帮助你的吗?
}
MiniMax completion
package main
import (
"context"
"fmt"
"os"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
)
func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)
//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
SenderType: "USER",
Text: "hi~",
},
},
Model: "abab5-chat",
Temperature: 0.7,
}
res, _ := client.ChatCompletions(ctx, req)
fmt.Println(res.Choices) // output: 你好!有什么我可以帮助你的吗?
}
MiniMax stream completion
package main
import (
"context"
"errors"
"fmt"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
"io"
"os"
)
func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)
//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
SenderType: "USER",
Text: "hi~",
},
},
Model: "abab5-chat",
Temperature: 0.7,
}
stream, _ := client.ChatCompletionStream(ctx, req)
defer stream.CloseSend()
for {
response, err := stream.Recv()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
fmt.Println(err)
break
}
fmt.Printf(response.Choices[0].Delta + "\n") //嗨!有什么我可以帮助您的吗?
}
}
MiniMax history stream completion
package main
import (
"context"
"errors"
"fmt"
textv1 "github.com/ConnectAI-E/go-minimax/gen/go/minimax/text/v1"
"github.com/ConnectAI-E/go-minimax/minimax"
"io"
"os"
)
func main() {
ctx := context.Background()
//init client
client, _ := minimax.New(
minimax.WithApiToken(os.Getenv("TEST_MINIMAX_API_TOKEN")),
minimax.WithGroupId(os.Getenv("TEST_MINIMAX_GROUP_ID")),
)
//chat
req := &textv1.ChatCompletionsRequest{
Messages: []*textv1.Message{
{
"sender_type": "USER",
"text": "路卡,今天在干什么呢?"
},
{
"sender_type": "BOT",
"text": "我今天在家里复习功课,准备期末考试呢!"
},
{
"sender_type": "USER",
"text": "期末考试怎么样,有把握吗?"
}
},
Model: "abab5-chat",
Temperature: 0.7,
}
stream, _ := client.ChatCompletionStream(ctx, req)
defer stream.CloseSend()
for {
response, err := stream.Recv()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
fmt.Println(err)
break
}
fmt.Printf(response.Choices[0].Delta + "\n") //放轻松,一切尽在掌握中
}
}