Last active
February 12, 2026 15:03
-
-
Save ftnext/c041707004c1dc346df9674186009a7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "faraday" | |
| require "json" | |
| api_key = ENV["GEMINI_API_KEY"] | |
| conn = Faraday.new( | |
| url: "https://generativelanguage.googleapis.com" | |
| ) | |
| response = conn.post( | |
| "/v1beta/models/gemini-3-flash-preview:generateContent" | |
| ) do |req| | |
| req.headers["Content-type"] = "application/json" | |
| req.headers["x-goog-api-key"] = api_key | |
| req.body = { | |
| contents: [ | |
| { | |
| parts: [ | |
| { text: "What's a good name for a flower shop that specializes in selling bouquets of dried flowers?" } | |
| ] | |
| } | |
| ] | |
| }.to_json | |
| end | |
| json = JSON.parse(response.body) | |
| puts json["candidates"][0]["content"]["parts"][0]["text"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment