Skip to main content
Code interpreter runs can return rich notebook results, including images and JavaScript-backed outputs when the selected kernel emits them. The standard Python template configures inline Matplotlib output and includes common plotting libraries.
plot = sandbox.run_code("""
import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [1, 4, 9])
plt.show()
""")

has_png = any(result.png or (result.data and "image/png" in result.data)
              for result in plot.results)
print(has_png)
For files written during execution, use artifacts or the sandbox filesystem to download the generated output.