LIVE
Anthropic files IPO prospectus, with risk disclosures taking center stage26/10/26 · Anthropic|Robot policy trained only in simulation matches top real-world systems26/10/26|OpenAI unveils GPT-6.1 Terra, a model built for computer use26/10/26 · OpenAI|OpenAI models are coming to Google Cloud21/10/26 · OpenAI|OpenAI details ChatGPT's new advertising infrastructure21/10/26 · OpenAI|Liquid AI unveils LFM3, a base for specialized multimodal models27/10/26 · Liquid AI|US Police Departments Use AI to Flag 'Suspicious' Driving Behavior27/10/26|AllenAI questions whether LLMs can judge research novelty27/10/26 · AllenAI|Open-Source AI Tools Aim to Speed Up Dementia Research27/10/26 · NVIDIA|Solid-state transformers eyed as a fix for AI's power grid bottleneck27/10/26|OpenAI expands Oracle partnership to bring business apps into ChatGPT27/10/26 · OpenAI|OpenAI publishes a page announcing 'GPT-6.1 Terra', with no technical details available26/10/26 · OpenAI|Anthropic files IPO prospectus, with risk disclosures taking center stage26/10/26 · Anthropic|Robot policy trained only in simulation matches top real-world systems26/10/26|OpenAI unveils GPT-6.1 Terra, a model built for computer use26/10/26 · OpenAI|OpenAI models are coming to Google Cloud21/10/26 · OpenAI|OpenAI details ChatGPT's new advertising infrastructure21/10/26 · OpenAI|Liquid AI unveils LFM3, a base for specialized multimodal models27/10/26 · Liquid AI|US Police Departments Use AI to Flag 'Suspicious' Driving Behavior27/10/26|AllenAI questions whether LLMs can judge research novelty27/10/26 · AllenAI|Open-Source AI Tools Aim to Speed Up Dementia Research27/10/26 · NVIDIA|Solid-state transformers eyed as a fix for AI's power grid bottleneck27/10/26|OpenAI expands Oracle partnership to bring business apps into ChatGPT27/10/26 · OpenAI|OpenAI publishes a page announcing 'GPT-6.1 Terra', with no technical details available26/10/26 · OpenAI|
Toolofficial publisher

code_execution (Gemini)

Tool : A precise action the AI can call · requires gemini-api

Python executed on Google's side, results returned to the model.

Practical and included; isolated execution at Google.

Overall score
7.0 /10
Security: one caveat, see the card
Utility
8.0
Reliability
6.0
Security
One caveat
Ease
1 click · Comfortable

Security reflects where data goes, requested permissions and incidents on record at the verification date. It is not a guarantee of zero risk: check the deployment mode and the connections you enable.

What it does, concretely

When a language model needs to perform precise calculations, process files, or solve equations, text generation alone is not enough. The code_execution tool in the Gemini API allows the model to generate Python code, run it in an isolated environment hosted by Google, and then use the results to iteratively refine its response.

In practice, when you enable the tool in your request, Gemini can write a Python script, send it to a secure runtime environment, retrieve the output, and continue reasoning from it. The model can repeat this cycle up to five times if an error occurs. Execution is limited to 30 seconds per call.

This tool is aimed at developers integrating the Gemini API who need reliable calculations, CSV or text file processing, or Matplotlib chart generation directly within the model's response. It also works in multi-turn conversations through the previous_interaction_id parameter.

However, it is not suitable for those who want to execute code in a language other than Python: Gemini can generate code in other languages, but cannot run it through this tool. It is also not intended for end users without API access.

What it offers

  • ·Python code execution in an isolated environment hosted by Google, at no additional cost beyond the tokens consumed.
  • ·Iterative reasoning: the model can re-run execution up to five times to correct errors before providing a final response.
  • ·Support for file input (CSV, text) and Matplotlib chart generation returned as inline images in the response.
  • ·Image processing with Gemini 3 Flash: the model can write and execute Python code to crop, annotate, or analyze images passed as input.
  • ·Use in multi-turn conversations via the previous_interaction_id parameter to chain exchanges with context memory.
  • ·Compatibility with Python, JavaScript SDKs and the REST API for flexible integration depending on the development environment.
  • ·Maximum execution time of 30 seconds per call, with automatic error return if this limit is exceeded.

In practice

Price
Freemium
Commercial use
Commercial use: yes
Available on
api
Host
gemini-api
FR interface
No

Security and data

Rating
Security: one caveat, see the card
Capabilities
readswritesexecutesnetwork
Your data
Data with the vendor
Maintenance
Active

Links and repository checked on 25 October 2026 · added on 1 June 2024

How to install code_execution (Gemini)

1. Obtain a Gemini API key from Google AI Studio and store it in an environment variable (GEMINI_API_KEY) rather than hard-coding it. 2. Install the Python SDK with: pip install google-genai 3. In your script, import the client: from google import genai 4. Instantiate the client: client = genai.Client() 5. Add the tool to your request by passing tools=[{"type": "code_execution"}] when calling client.interactions.create(). 6. Iterate over interaction.steps to separately retrieve the text, generated code, and execution results.
pip install google-genai

Official documentation ↗

In the same category

Whole category Feed (memory, context) →