forked from reVrost/go-openrouter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (28 loc) · 672 Bytes
/
main.go
File metadata and controls
36 lines (28 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/revrost/go-openrouter"
)
func main() {
ctx := context.Background()
client := openrouter.NewClient(os.Getenv("OPENROUTER_API_KEY"))
// Basic text embedding example
request := openrouter.EmbeddingsRequest{
Model: "openai/text-embedding-3-large",
Input: []string{
"Hello world",
"OpenRouter embeddings example",
},
EncodingFormat: openrouter.EmbeddingsEncodingFormatFloat,
}
res, err := client.CreateEmbeddings(ctx, request)
if err != nil {
fmt.Println("error", err)
return
}
b, _ := json.MarshalIndent(res, "", "\t")
fmt.Printf("response :\n %s\n", string(b))
}