summaryrefslogtreecommitdiff
path: root/doConnect.go.notyet
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-08-26 11:42:51 -0500
committerJeff Carr <[email protected]>2025-08-26 11:42:51 -0500
commit5fff0c4d70f05aa409016ebdc983136ada3a7f02 (patch)
treeed09eee4cba2c2e8fc1e15fd3d5b802d0d267b97 /doConnect.go.notyet
parenta20e4e0533f1b7ef96a59274f7755ec599038298 (diff)
testingv0.0.3
Diffstat (limited to 'doConnect.go.notyet')
-rw-r--r--doConnect.go.notyet28
1 files changed, 28 insertions, 0 deletions
diff --git a/doConnect.go.notyet b/doConnect.go.notyet
new file mode 100644
index 0000000..52fdc7c
--- /dev/null
+++ b/doConnect.go.notyet
@@ -0,0 +1,28 @@
+package main
+
+import (
+ "context"
+ "fmt"
+ "os"
+
+ "github.com/google/generative-ai-go/genai"
+ "google.golang.org/api/option"
+)
+
+// doConnect initializes and returns a Gemini client.
+// It reads the API key from the GEMINI_API_KEY environment variable.
+func doConnect() (*genai.GenerativeModel, error) {
+ apiKey := os.Getenv("GEMINI_API_KEY")
+ if apiKey == "" {
+ return nil, fmt.Errorf("GEMINI_API_KEY environment variable not set")
+ }
+
+ ctx := context.Background()
+ client, err := genai.NewClient(ctx, option.WithAPIKey(apiKey))
+ if err != nil {
+ return nil, fmt.Errorf("failed to create new genai client: %w", err)
+ }
+
+ model := client.GenerativeModel("gemini-pro")
+ return model, nil
+}