# Docs for v2 can be found by changing the above selector ^
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": "<unknown>",
"data": {
"outputs": [
{
"type": "stdout",
"data": "<string>"
}
],
"session_id": "ses_abcDEF123",
"status": "success"
}
}Executes the given code snippet and returns the output. Without a session_id, a new session will be created to run the code. If you do pass in a valid session_id, the code will be run in that session. This is useful for running multiple code snippets in the same environment, because dependencies and similar things are persisted between calls to the same session.
# Docs for v2 can be found by changing the above selector ^
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": "<unknown>",
"data": {
"outputs": [
{
"type": "stdout",
"data": "<string>"
}
],
"session_id": "ses_abcDEF123",
"status": "success"
}
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Execute Request
Code snippet to execute.
"print('Hello, world!')"
Programming language for the code to execute. Currently only supports Python, but more will be added.
python Files to upload to the session. If present, files will be uploaded before executing the given code.
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.
"ses_abcDEF123"
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.
Show child attributes
Identifier of the current session. Used to make follow-up calls.
"ses_abcDEF123"
Status of the execution. Currently only supports success.
success Was this page helpful?