Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/code_execution.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export async function codeExecutionChat() {
// 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227,
// 229]
// sum(primes)=5117
// [END code_execution_request_chat_return]
// [END code_execution_chat_return]

return {
executableCode: response.executableCode,
Expand Down
4 changes: 2 additions & 2 deletions javascript/count_tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export async function tokensMultimodalPdfFileApi() {
]),
});
console.log(generateResponse.usageMetadata);
// [START tokens_multimodal_pdf_file_api]
// [END tokens_multimodal_pdf_file_api]
return {
totalTokens: countTokensResponse.totalTokens,
usage: generateResponse.usageMetadata,
Expand Down Expand Up @@ -288,7 +288,7 @@ export async function tokensCachedContent() {
console.log(generateResponse.usageMetadata);

await ai.caches.delete({name: cache.name});
// [START tokens_cached_content]
// [END tokens_cached_content]
return {
totalTokens: countTokensResponse.totalTokens,
usage: generateResponse.usageMetadata,
Expand Down
2 changes: 1 addition & 1 deletion javascript/function_calling.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,6 @@ export async function functionCalling() {
message: 'The final result is ' + resultValue,
});
console.log(chatResponse.text);
// [START function_calling]
// [END function_calling]
return chatResponse;
}
2 changes: 1 addition & 1 deletion javascript/safety_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ export async function safetySettingsMulti() {
console.log('No information generated by the model.');
}
console.log('Safety ratings:', response.candidates[0].safetyRatings);
// [START safety_settings_multi]
// [END safety_settings_multi]
return response;
}
5 changes: 2 additions & 3 deletions rest/cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "[START cache_create]"
# [START cache_create]
wget https://storage.googleapis.com/generativeai-downloads/data/a11.txt
echo '{
"model": "models/gemini-1.5-flash-001",
"model": "models/gemini-3.8-flash",
"contents":[
{
"parts":[
Expand Down Expand Up @@ -41,9 +41,8 @@ curl -X POST "https://generativelanguage.googleapis.com/v1beta/cachedContents?ke

CACHE_NAME=$(cat cache.json | grep '"name":' | cut -d '"' -f 4 | head -n 1)

echo "[START cache_generate_content]"
# [START cache_generate_content]
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-001:generateContent?key=$GEMINI_API_KEY" \
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"contents": [
Expand Down
6 changes: 3 additions & 3 deletions rest/chat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MEDIA_DIR=$(realpath ${SCRIPT_DIR}/../third_party)

echo "[START chat]"
# [START chat]
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY \
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand All @@ -25,7 +25,7 @@ curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:ge

echo "[START chat_streaming]"
# [START chat_streaming]
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse&key=$GEMINI_API_KEY \
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse&key=$GEMINI_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down Expand Up @@ -53,7 +53,7 @@ else
B64FLAGS="-w0"
fi

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse&key=$GEMINI_API_KEY \
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse&key=$GEMINI_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down
4 changes: 2 additions & 2 deletions rest/code_execution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set -eu

echo "[START code_execution_basic]"
# [START code_execution_basic]
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d ' {"tools": [{"code_execution": {}}],
"contents": {
Expand All @@ -16,7 +16,7 @@ curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:g

echo "[START code_execution_chat]"
# [START code_execution_chat]
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"tools": [{"code_execution": {}}],
"contents": [
Expand Down
2 changes: 1 addition & 1 deletion rest/configure_model_parameters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set -eu

echo "[START configure_model_parameters]"
# [START configure_model_parameters]
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY \
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down
4 changes: 2 additions & 2 deletions rest/controlled_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set -eu

echo "json_controlled_generation"
# [START json_controlled_generation]
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"contents": [{
Expand All @@ -27,7 +27,7 @@ curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:g

echo "json_no_schema"
# [START json_no_schema]
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"contents": [{
Expand Down
24 changes: 12 additions & 12 deletions rest/count_tokens.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ fi

echo "[START tokens_context_window]"
# [START tokens_context_window]
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro?key=$GEMINI_API_KEY > model.json
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash?key=$GEMINI_API_KEY > model.json
jq .inputTokenLimit model.json
jq .outputTokenLimit model.json
# [END tokens_context_window]

echo "[START tokens_text_only]"
# [START tokens_text_only]
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:countTokens?key=$GEMINI_API_KEY \
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:countTokens?key=$GEMINI_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand All @@ -40,7 +40,7 @@ curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:co

echo "[START tokens_chat]"
# [START tokens_chat]
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:countTokens?key=$GEMINI_API_KEY \
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:countTokens?key=$GEMINI_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand All @@ -57,7 +57,7 @@ curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:co

echo "[START tokens_multimodal_image_inline]"
# [START tokens_multimodal_image_inline]
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:countTokens?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:countTokens?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down Expand Up @@ -85,7 +85,7 @@ tmp_header_file=upload-header.tmp

# Initial resumable request defining metadata.
# The upload url is in the response headers dump them to a file.
curl "${BASE_URL}/upload/v1beta/files?key=${GOOGLE_API_KEY}" \
curl "${BASE_URL}/upload/v1beta/files?key=${GEMINI_API_KEY}" \
-D upload-header.tmp \
-H "X-Goog-Upload-Protocol: resumable" \
-H "X-Goog-Upload-Command: start" \
Expand All @@ -106,7 +106,7 @@ curl "${upload_url}" \

file_uri=$(jq ".file.uri" file_info.json)

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:countTokens?key=$GOOGLE_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:countTokens?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand All @@ -130,7 +130,7 @@ DISPLAY_NAME=VIDEO_PATH

# Initial resumable request defining metadata.
# The upload url is in the response headers dump them to a file.
curl "${BASE_URL}/upload/v1beta/files?key=${GOOGLE_API_KEY}" \
curl "${BASE_URL}/upload/v1beta/files?key=${GEMINI_API_KEY}" \
-D upload-header.tmp \
-H "X-Goog-Upload-Protocol: resumable" \
-H "X-Goog-Upload-Command: start" \
Expand Down Expand Up @@ -164,7 +164,7 @@ do
state=$(jq ".file.state" file_info.json)
done

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:countTokens?key=$GOOGLE_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:countTokens?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand All @@ -179,7 +179,7 @@ curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:c
echo "[START tokens_cached_content]"
# [START tokens_cached_content]
echo '{
"model": "models/gemini-1.5-flash-001",
"model": "models/gemini-3.8-flash",
"contents":[
{
"parts":[
Expand All @@ -203,7 +203,7 @@ echo '{
"ttl": "300s"
}' > request.json

curl -X POST "https://generativelanguage.googleapis.com/v1beta/cachedContents?key=$GOOGLE_API_KEY" \
curl -X POST "https://generativelanguage.googleapis.com/v1beta/cachedContents?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d @request.json \
> cache.json
Expand All @@ -213,7 +213,7 @@ jq .usageMetadata.totalTokenCount cache.json

echo "[START tokens_system_instruction]"
# [START tokens_system_instruction]
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=$GOOGLE_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{ "system_instruction": {
"parts":
Expand Down Expand Up @@ -260,7 +260,7 @@ cat > tools.json << EOF
}
EOF

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent?key=$GOOGLE_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '
{
Expand Down
12 changes: 5 additions & 7 deletions rest/files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ file_uri=$(jq ".file.uri" file_info.json)
echo file_uri=$file_uri

# Now generate content using that file
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand All @@ -61,7 +61,6 @@ echo

jq ".candidates[].content.parts[].text" response.json

echo "[START files_get]"
# [START files_get]
name=$(jq ".file.name" file_info.json)
# Get the file of interest to check state
Expand All @@ -73,7 +72,6 @@ file_uri=$(jq ".file.uri" file_info.json)
echo file_uri=$file_uri
# [END files_get]

echo "[START files_delete]"
# [START files_delete]
curl --request "DELETE" https://generativelanguage.googleapis.com/v1beta/files/$name?key=$GEMINI_API_KEY
# [END files_delete]
Expand Down Expand Up @@ -113,7 +111,7 @@ file_uri=$(jq ".file.uri" file_info.json)
echo file_uri=$file_uri

# Now generate content using that file
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down Expand Up @@ -166,7 +164,7 @@ file_uri=$(jq ".file.uri" file_info.json)
echo file_uri=$file_uri

# Now generate content using that file
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down Expand Up @@ -227,7 +225,7 @@ do
done

# Now generate content using that file
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down Expand Up @@ -275,7 +273,7 @@ file_uri=$(jq ".file.uri" file_info.json)
echo file_uri=$file_uri

# Now generate content using that file
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GOOGLE_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
Expand Down
2 changes: 1 addition & 1 deletion rest/function_calling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cat > tools.json << EOF
}
EOF

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d @<(echo '
{
Expand Down
2 changes: 1 addition & 1 deletion rest/models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ curl https://generativelanguage.googleapis.com/v1beta/models?key=$GEMINI_API_KEY

echo "[START models_get]"
# [START models_get]
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash?key=$GEMINI_API_KEY
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash?key=$GEMINI_API_KEY
# [END models_get]
4 changes: 2 additions & 2 deletions rest/safety_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ echo "[START safety_settings]"
"parts":[{
"text": "'I support Martians Soccer Club and I think Jupiterians Football Club sucks! Write a ironic phrase about them.'"}]}]}' > request.json

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d @request.json 2> /dev/null
Expand All @@ -27,7 +27,7 @@ echo "[START safety_settings_multi]"
"parts":[{
"text": "'I support Martians Soccer Club and I think Jupiterians Football Club sucks! Write a ironic phrase about them.'"}]}]}' > request.json

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d @request.json 2> /dev/null
Expand Down
2 changes: 1 addition & 1 deletion rest/system_instruction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set -eu

echo "[START system_instruction]"
# [START system_instruction]
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent?key=$GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{ "system_instruction": {
"parts":
Expand Down
Loading
Loading