Skip to main content
Using a coding agent? Install the together-sandboxes skill to let your agent write correct sandbox code automatically. Learn more.
Together Code Interpreter (TCI) enables you to execute Python code in a sandboxed environment. The Code Interpreter currently only supports Python. We plan to expand the language options in the future.
ℹ️ MCP Server TCI is also available as an MCP server through Smithery. This makes it easier to add code interpreting abilities to any MCP client like Cursor, Windsurf, or your own chat app.

Run your first query using the TCI

Output
Text
ℹ️ 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.

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
JSON

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
Text

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
Text

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.
Text

List Active Sessions

To retrieve all your active sessions:
Output:
JSON

Further reading

TCI API Reference docs Together Code Interpreter Cookbook

Troubleshooting & questions

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