How to get the executed Python code from code interpreter?

When I ask to draw a cricle, the playground displays the generated python code that gets executed to draw the circle.

When I use the API asking the same prompt, I get text and image messages but I don’t find where the python code is.
(not in annotations, not in attachment not in a sepcific type content)

Any idea?

1 Like

Haven’t tried that, but it might be here: https://platform.openai.com/docs/assistants/tools/code-interpreter

good luck

thanks! that is the code I used but it says nothing about getting the python code, only how to get the result…

I have the same confusion.

From the platform I can see the code interpreter logic but when retrieving the thread messages from API the logic is missing.

Any idea why?

You’ll need to get run steps. Then parse the step details, looking for code interpreter types and their details. Here, from the expanded API reference:

1 Like

Ah, thank you! I totally overlooked that