Skip to main content
Together Code Interpreter (TCI) enables you to execute Python code in a sandboxed environment. At this time, the Code Interpreter only supports Python. In the future, we plan on expanding the language options.

Run your first query using the TCI

Output

Pricing information

TCI usage is billed at $0.03/session. As detailed below, sessions have a lifespan of 60 minutes and can be used multiple times.TCI is free to use until May 8, 2025.

Example Use Cases

Overview of how Together Code Interpreter can be used in a code generation, execution and improvement iteration.
  • Reinforcement learning (RL) training: TCI transforms code execution into an interactive RL environment where generated code is run and evaluated in real time, providing reward signals from successes or failures, integrating automated pass/fail tests, and scaling easily across parallel workers—thus creating a powerful feedback loop that refines coding models over many trials.
  • Developing agentic workflows: TCI allows AI agents to seamlessly write and execute Python code, enabling robust, iterative, and secure computations within a closed-loop system.

Response Format

The API returns:
  • session_id: Identifier for the current session
  • outputs: Array of execution outputs, which can include:
    • Execution output (the return value of your snippet)
    • Standard output (stdout)
    • Standard error (stderr)
    • Error messages
    • Rich display data (images, HTML, etc.) Example

Usage overview

Together AI has created sessions to measure TCI usage. A session is an active code execution environment that can be called to execute code, they can be used multiple times and have a lifespan of 60 minutes. Typical TCI usage follows this workflow:
  1. Start a session (create a TCI instance).
  2. Call that session to execute code; TCI outputs stdout and stderr.
  3. Optionally reuse an existing session by calling its session_id.

Reusing sessions and maintaining state between runs

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

Using the TCI for Data analysis

Together Code Interpreter is a very powerful tool and gives you access to a fully functional coding environment. You can install Python libraries and conduct fully fledged data analysis experiments.

Uploading and using files with TCI

Output

Pre-installed dependencies

TCI’s Python sessions come pre-installed with the following dependencies, any other dependencies can be installed using a !pip install command in the python code.

List Active Sessions

To retrieve all your active sessions:
Output:

Further reading

TCI API Reference docs Together Code Interpreter Notebook

Troubleshooting & questions

If you have questions about integrating TCI into your workflow or encounter any issues, please contact us.