Gemini code execution

by GoogleCode execution

Code execution is Google's Gemini tool for writing and running Python while it answers. Gemini runs the code, reads the result and, when it errors, can rewrite it up to five times, with libraries such as NumPy, pandas and Matplotlib already installed. Each run is capped at 30 seconds, and it combines with Google Search grounding. On Opper it works on the Gemini generateContent endpoint, passed through as Google defines it.

UseGemini code executionwithin

Add Gemini code execution on Opper

Set up with agents

Paste this into your coding agent (Claude Code, Cursor, Codex, and more) and it will set up and build with Opper for you.

Get your API key

Key info

Tool
codeExecution
Endpoint
generateContent

In your code

curl "https://api.opper.ai/v3/compat/v1beta/models/gemini/gemini-4-argon:generateContent" \
-H "Authorization: Bearer $OPPER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "Sum the first 50 primes and show your working."}]}],
"tools": [{"codeExecution": {}}]}'

Use Gemini code execution with these models

Step-by-step setup for Gemini code execution on each of these models through Opper.

More tools on Opper

Use Gemini code execution through Opper

One key, 700+ models, a choice of region, and zero data retention. Tools run in the same request, with every call in your traces.

Get startedView Documentation