Skip to content

Commit

Permalink
Add generateContent text samples for Python and rest
Browse files Browse the repository at this point in the history
  • Loading branch information
markmcd committed Jun 21, 2024
1 parent 2fcd37c commit 998a1f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/gemini/python/api/generatecontent_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
import google.generativeai as genai

genai.configure(api_key=os.environ["GOOGLE_API_KEY"])

model = genai.GenerativeModel("gemini-1.5-flash")

response = model.generate_content("Give me python code to sort a list")
print(response.text)
8 changes: 8 additions & 0 deletions examples/gemini/rest/api/generatecontent_text.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${GOOGLE_API_KEY}" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts":[{"text": "Give me python code to sort a list."}]
}]
}'

0 comments on commit 998a1f8

Please sign in to comment.