func main()

in cmd/proxy-to-gemini/main.go [38:71]


func main() {
	ctx := context.Background()

	flag.StringVar(&hostport, "listen", ":5555", "host and port to listen on")
	flag.StringVar(&api, "api", "openai", "API proxocol; openai or ollama")
	flag.Parse()

	apikey = os.Getenv("GEMINI_API_KEY")
	if apikey == "" {
		log.Fatal("GEMINI_API_KEY environment variable not set")
	}
	client, err := genai.NewClient(ctx, option.WithAPIKey(apikey))
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

	r := mux.NewRouter()
	r.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprint(w, "ok")
	})
	switch api {
	case "openai":
		openai.RegisterHandlers(r, client)
	case "ollama":
		ollama.RegisterHandlers(r, client)
	}
	r.HandleFunc("/", indexHandler)

	log.Printf("Starting server on %v", hostport)
	if err := http.ListenAndServe(hostport, r); err != nil {
		log.Printf("Error starting server: %v", err)
	}
}