POST
/
tci
/
execute
from together import Together
import os

client = Together(
api_key=os.environ.get("TOGETHER_API_KEY"),
)

response = client.code_interpreter.run(
code="print('Hello world!')",
language="python",
)

print(response.data.outputs[0].data);
{
  "errors": null,
  "data": {
    "outputs": [
      {
        "type": "stdout",
        "data": "<string>"
      }
    ],
    "session_id": "ses_abcDEF123",
    "status": "success"
  }
}

Authorizations

Authorization
string
header
default:default
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Execute Request

code
string
required

Code snippet to execute.

Example:

"print('Hello, world!')"

language
enum<string>
default:python
required

Programming language for the code to execute. Currently only supports Python, but more will be added.

Available options:
python
files
object[]

Files to upload to the session. If present, files will be uploaded before executing the given code.

session_id
string

Identifier of the current session. Used to make follow-up calls. Requests will return an error if the session does not belong to the caller or has expired.

Example:

"ses_abcDEF123"

Response

200 - application/json

Execute Response

The result of the execution. If successful, data contains the result and errors will be null. If unsuccessful, data will be null and errors will contain the errors.

errors
null
required
data
object
required