Gemini API Code Execution with OpenAI Library in Python

How can I use the Code Execution feature of the Gemini API with the OpenAI Library in Python? Please provide step-by-step instructions and a working code example. Additionally, confirm whether Gemini supports plotting graphs (e.g., using Matplotlib) via Code Execution and highlight any limitations or requirements to be aware of.

Hey @ratchanonth_plumanut , currently, code execution tool is not available in OpenAI compatibility. To use this feature, you will need to utilize the google genai sdk. We have a cookbook available for code_execution, which also supports graph plotting with matplotlib.

For more details on limitations, please refer the doc.

Thank you

1 Like