ℹ️ 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
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

- 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 sessionoutputs
: 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:- Start a session (create a TCI instance).
- Call that session to execute code; TCI outputs
stdout
andstderr
. - Optionally reuse an existing session by calling its
session_id
.
Reusing sessions and maintaining state between runs
Thesession_id
can be used to access a previously initialized session. All packages, variables, and memory will be retained.
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
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:cURL
JSON