This website uses cookies to anonymously analyze website traffic using Google Analytics.

Together Code Interpreter

Execute LLM-generated code seamlessly with a simple API call.

Fast, secure code execution for LLM-generated code


Together Code Interpreter allows you to execute LLM-generated Python code securely and feed the output back to the LLM for richer responses.

  • Build agentic workflows

    Build coding agents that can run code to make decisions by calling APIs, processing data & performing calculations.

  • Data analysis & visualization

    Analyze datasets to provide on-the-fly insights and visualizations like charts and graphs.

  • Reinforced learning

    Bring code execution into interactive RL environments with real-time feedback, pass/fail signals, and easy scaling.

"Together Code Interpreter has dramatically accelerated our RL post-training cycles, enabling us to reliably scale to over 100 concurrent coding sandboxes and run thousands of code evaluations per minute. Its reliable and scalable infrastructure has proven invaluable."

- Michael Luo & Sijun Tan, Project lead at Agentica

Configure powerful workflows with our Python library

Seamlessly execute Python code in a sandboxed environment.

Create a session

Create a Together Code Interpreter session that you can use to execute code. Each session is billed at $0.03/session.

code_interpreter = client.code_interpreter

Execute Python code in an active session

Execute code in a secure sandboxed environment, install Python libraries, upload files, and conduct fully fledged data analysis experiments.

# Simple print statement
print("Example 1: Simple print")
response = code_interpreter.run(
    code='print("Hello from Together!")',
    language="python"
)
print(f"Status: {response.data.status}")
for output in response.data.outputs:
    print(f"{output.type}: {output.data}")
if response.data.errors:
    print(f"Errors: {response.data.errors}")
print("\n")

Maintain the state between runs

The session_id can be used to access a previously initialized session. All packages, variables and memory will be retained.

session_id = response1.data.session_id

response2 = code_interpreter.run(
    code='print(f"The value of x is {x}")',
    language="python",
    session_id=session_id
)

for output in response2.data.outputs:
    print(f"{output.type}: {output.data}")
if response2.data.errors:
    print(f"Errors: {response2.data.errors}")
print("\n")

Bring Code Execution to Your AI Applications

Get started