#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")/../../.." source scripts/lib.sh MODEL="${MODEL:-gemini-3.5-flash-lite}" # Interactions API: create (stateful), stream (SSE), chain with previous_interaction_id, get, delete. # STATUS: LIVE_VERIFIED 2026-09-18 (same requests as tmp-live/gemini-tools/h1..h9*.json via the Python runner; script itself not re-executed). R=$(gemini POST /v1beta/interactions -d "$(jq -n --arg m "$MODEL" '{model:$m,input:"Reply with OK.",generation_config:{max_output_tokens:16}}')") log_request gemini POST /v1beta/interactions "${GEMINI_STATUS:-200}" 0.0001 "interactions/create.sh create" ID=$(echo "$R" | jq -r .id); echo "$R" | jq -c '{id, status, steps: [.steps[].type], usage: .usage.total_tokens}' # streaming: SSE lines "event: " / "data: {…, event_type}" curl -sN https://generativelanguage.googleapis.com/v1beta/interactions -H "x-goog-api-key: $GEMINI_API_KEY" -H "Content-Type: application/json" \ -d "$(jq -n --arg m "$MODEL" --arg p "$ID" '{model:$m,input:"Reply with OK.",stream:true,previous_interaction_id:$p,generation_config:{max_output_tokens:16}}')" | grep '^event:' | tr '\n' ' '; echo log_request gemini POST /v1beta/interactions 200 0.0001 "interactions/create.sh stream" gemini GET "/v1beta/interactions/$ID" | jq -c '{id, status, model, created}' log_request gemini GET "/v1beta/interactions/{id}" "${GEMINI_STATUS:-200}" 0 "interactions/create.sh get" gemini DELETE "/v1beta/interactions/$ID" > /dev/null; echo "delete: ${GEMINI_STATUS:-200}" log_request gemini DELETE "/v1beta/interactions/{id}" "${GEMINI_STATUS:-200}" 0 "interactions/create.sh delete"