Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here simplified to a single curl command:
- curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=YOUR-API-KEY" \
- -H 'Content-Type: application/json' \
- -X POST \
- -d '{
- "contents": [{
- "parts":[{"text": "Who is the current Chancellor of Germany?"}]
- }],
- "tools": [{
- "googleSearch": {}
- }]
- }' | grep -o '"text": "[^"]*"' | sed 's/"text": "\(.*\)"/\1/'
- Complete example (REST) from aistudio:
- #!/bin/bash
- set -e -E
- GEMINI_API_KEY="$GEMINI_API_KEY"
- MODEL_ID="gemini-2.0-flash"
- GENERATE_CONTENT_API="streamGenerateContent"
- cat << EOF > request.json
- {
- "contents": [
- {
- "role": "user",
- "parts": [
- {
- "text": "INSERT_INPUT_HERE"
- },
- ]
- },
- ],
- "generationConfig": {
- "responseMimeType": "text/plain",
- },
- "tools": [
- {
- "googleSearch": {}
- },
- ],
- }
- EOF
- curl \
- -X POST \
- -H "Content-Type: application/json" \
- "https://generativelanguage.googleapis.com/v1beta/models/${MODEL_ID}:${GENERATE_CONTENT_API}?key=${GEMINI_API_KEY}" -d '@request.json'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement