Written by Stephen Condon
Published on: 2/21/2025
This one is pretty basic, I followed the Gemini quick start, which was super easy to follow. I just want to highlight some basic practices to keep things secure.
I generated the API key just following the links from the quick start guide, easy. The trick is to keep it out of source and streamline its use in my example program. Enter .env. I have used .env extensively in node & python, and was wondering if there was a dotenv/pipenv equivalent in go. There isn’t, but I found a package, github.com/joho/godotenv, that does nicely, sample code to use it below:
.env
GEMINI_KEY=<secret>
main.go
func loadEnv() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
}
This pulls in .env, I added a .env.example to source with the expected keys to help others out. Basically at this point, you just throw together a request as below:
loadEnv()
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_KEY")))
if err != nil {
log.Fatal(err)
}
defer client.Close()
model := client.GenerativeModel("gemini-1.5-flash")
resp, err := model.GenerateContent(ctx, genai.Text("Write a recipe for brisket only using salt as a seasoning and a candle for the heat source."))
if err != nil {
log.Fatal(err)
}
for _, candidate := range resp.Candidates {
log.Println(candidate.Content)
}
This recipe is purely theoretical and extremely impractical. It would take an extraordinarily long time and the results would likely be disappointing. A candle’s heat output is far too low to properly cook a brisket. This is more of a conceptual exercise than a genuine cooking method.
Theoretical Candle-Cooked Salt-Brined Brisket (Do Not Attempt)
Ingredients:
Equipment:
Instructions (Theoretical and Extremely Dangerous):
Salt Brine (Theoretical): Generously salt the brisket all over, ensuring even coverage. The salt will act as the only seasoning and also draw out some moisture. You might even need to consider a heavier salting than usual. Leave it brined for at least several hours, potentially overnight in the refrigerator (if possible).
Candle Heat Source Setup (Extremely Dangerous): This is the most crucial and dangerous step. You need to create a safe and contained system to generate sufficient heat, without risking a fire. This is highly unlikely to be feasible with only candles.
Cooking (Extremely Slow and Possibly Unsuccessful): Place the salted brisket in the pot. Cover the pot with the lid. Arrange candles beneath the pot, distributing the heat as evenly as possible. The cooking process will be incredibly slow, potentially taking days, even weeks. Regularly monitor the candles and make adjustments as needed to maintain an extremely low, consistent heat, which is itself a significant challenge.
Checking for Doneness (Highly Problematic): There’s no easy way to check for doneness. You would need to rely on extremely infrequent temperature checks with a probe thermometer (being extremely careful about approaching the flame) if you manage to get the heat at all.
Resting (If Achieved): Once (if) you achieve tenderness (this is a big “if”), let the brisket rest in the pot, still covered, for a very long time to allow the juices to redistribute.
Important Safety Considerations: This is incredibly dangerous and not recommended. The risk of fire is extremely high, and the resulting heat will likely be uneven and unpredictable. Do not attempt this recipe. This is a thought experiment, not a practical cooking method. Use appropriate fuel sources and equipment for cooking brisket.
I really don’t understand why Gemini is so skeptical of this.
Tags: