File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ set -eu
2
+
3
+ echo " json_controlled_generation"
4
+ # [START json_controlled_generation]
5
+ curl " https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=$GOOGLE_API_KEY " \
6
+ -H ' Content-Type: application/json' \
7
+ -d ' {
8
+ "contents": [{
9
+ "parts":[
10
+ {"text": "List 5 popular cookie recipes"}
11
+ ]
12
+ }],
13
+ "generationConfig": {
14
+ "response_mime_type": "application/json",
15
+ "response_schema": {
16
+ "type": "ARRAY",
17
+ "items": {
18
+ "type": "OBJECT",
19
+ "properties": {
20
+ "recipe_name": {"type":"STRING"},
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }' 2> /dev/null | head
26
+ # [END json_controlled_generation]
27
+
28
+ echo " json_no_schema"
29
+ # [START json_no_schema]
30
+ curl " https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=$GOOGLE_API_KEY " \
31
+ -H ' Content-Type: application/json' \
32
+ -d ' {
33
+ "contents": [{
34
+ "parts":[
35
+ {"text": "List a few popular cookie recipes using this JSON schema:
36
+
37
+ Recipe = {\"recipe_name\": str}
38
+ Return: list[Recipe]"
39
+ }
40
+ ]
41
+ }],
42
+ "generationConfig": { "response_mime_type": "application/json" }
43
+ }' 2> /dev/null | head
44
+ # [END json_no_schema]
You can’t perform that action at this time.
0 commit comments