Skip to content
Back to skills

Gemini Code Execution Json Mode

ASecurity

Handle model-specific compatibility between Gemini code execution and structured JSON output.

  • 6 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 26, 2026
developmentpythongoapidocumentation

Works with

  • api

Security analysis

A100/100

Scanned November 26, 2026

npx -y skills add jleechanorg/jleechan-skills --skill gemini-code-execution-json-mode --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Gemini Code Execution Json Mode?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Gemini Code Execution Json Mode
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jleechanorg-gemini-code-execution-json-mode/badge)](https://www.skillsdirectory.com/skills/jleechanorg-gemini-code-execution-json-mode)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: gemini-code-execution-json-mode
description: Handle model-specific compatibility between Gemini code execution and structured JSON output.
---

# Gemini Code Execution + JSON Mode Compatibility

## CRITICAL: Model-Specific Behavior

For all new model selections, use Gemini 3.8 Flash (`gemini-3.8-flash`) or a later Flash model. Never select Gemini Pro. Older rows below document compatibility only.

### Gemini 3 (gemini-3.8-flash)
**CAN combine code_execution with JSON mode/structured outputs.**

From [Gemini 3 Developer Guide](https://ai.google.dev/gemini-api/docs/gemini-3):
> "Gemini 3 allows you to combine Structured Outputs with built-in tools, including Grounding with Google Search, URL Context, and Code Execution."

### Gemini 2.x (gemini-2.0-flash, gemini-2.5-flash)
**CANNOT combine code_execution with JSON mode/controlled generation.**

Error returned:
```
INVALID_ARGUMENT: Unable to submit request because controlled generation
is not supported with Code Execution tool.
```

## Summary Table

| Model | Code Execution | JSON Mode | Both Together |
|-------|---------------|-----------|---------------|
| gemini-3.8-flash | YES | YES | **YES** |
| gemini-2.0-flash | YES | YES | **NO** |
| gemini-2.5-flash | NO | YES | N/A |

## Architecture Implications

For Your Project dice rolling:

1. **Gemini 3**: Can use single-phase code_execution + JSON mode
2. **Gemini 2.x**: Must use two-phase JSON-first tool_requests flow
   - Phase 1: JSON mode call, LLM includes `tool_requests` array
   - Phase 2: Execute tools server-side, inject results, second JSON call

## Code Pattern

```python
# Gemini 3: Can enable code_execution with JSON mode
if model_name in GEMINI_3_MODELS:
    enable_code_execution = True  # Safe with JSON mode

# Gemini 2.x: Must disable code_execution when using JSON mode
if model_name in ["gemini-2.0-flash", "gemini-2.5-flash"]:
    enable_code_execution = False  # Would cause INVALID_ARGUMENT
```

## Sources
- [Gemini 3 Developer Guide](https://ai.google.dev/gemini-api/docs/gemini-3)
- [Code Execution Documentation](https://ai.google.dev/gemini-api/docs/code-execution)
- [Structured Outputs Documentation](https://ai.google.dev/gemini-api/docs/structured-output)

## Last Updated
2025-12-16

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.