1
0
mirror of https://github.com/fumiama/deepinfra.git synced 2026-06-12 22:40:14 +08:00

feat: add Google GenAI API

This commit is contained in:
源文雨
2025-03-30 01:48:52 +09:00
parent bf0f65bcaa
commit db7712b6d2
7 changed files with 153 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"io"
"net/http"
)
const (
@@ -49,6 +50,15 @@ func NewOpenAI(model, sep string, temp, topp float32, maxn uint) *OpenAI {
return opai
}
func (*OpenAI) API(api, _ string) string {
return api
}
func (*OpenAI) Header(key string, h http.Header) {
h.Add("Content-Type", "application/json")
h.Add("Authorization", "Bearer "+key)
}
func (opai *OpenAI) Body() *bytes.Buffer {
w := bytes.NewBuffer(make([]byte, 0, 8192))
err := json.NewEncoder(w).Encode(opai)