Skip to content

Code Execution

POST
/v1beta/models/gemini-2.5-pro:generateContent
  • Enable tools.codeExecution so the model can generate and run code
  • Suitable for calculations, data analysis, and other scenarios that require executing code
  • Execution results are incorporated into the model's reply
  • Official docs: Code execution

Authorizations

bearer
Type
HTTP (bearer)

Request Body

application/json
object
object[]
Required

Tools (including codeExecution)

Responses

Success

application/json

Playground

Authorization
Body

Samples