Implementation:Togethercomputer Together python CodeInterpreter Types
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Code_Execution, Type_System |
| Last Updated | 2026-02-15 16:00 GMT |
Overview
Concrete type definitions for the code interpreter API provided by the Together Python SDK.
Description
This module defines the Pydantic models for the code interpreter: FileInput (file to upload with name, encoding, content), InterpreterOutput (execution output with type and data), ExecuteResponseData (outputs list, errors, session_id, status), and ExecuteResponse (top-level wrapper).
Usage
Import these types when you need to type-hint code interpreter data structures or inspect execution response objects.
Code Reference
Source Location
- Repository: Together Python
- File: src/together/types/code_interpreter.py
- Lines: 1-57
Signature
class FileInput(TogetherJSONModel):
name: str
encoding: Literal["string", "base64"]
content: str
class InterpreterOutput(TogetherJSONModel):
type: Literal["stdout", "stderr", "error", "display_data", "execute_result"]
data: Union[str, Dict[str, Any]]
class ExecuteResponseData(TogetherJSONModel):
outputs: list[InterpreterOutput]
errors: Union[str, None] = None
session_id: str
status: str = "completed"
class ExecuteResponse(TogetherJSONModel):
data: ExecuteResponseData
Import
from together.types.code_interpreter import ExecuteResponse, FileInput, InterpreterOutput
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (constructed from API responses) | Dict[str, Any] | Yes | API JSON data parsed into typed models |
Outputs
| Name | Type | Description |
|---|---|---|
| ExecuteResponse | Pydantic Model | Wrapper containing ExecuteResponseData |
| ExecuteResponseData | Pydantic Model | outputs list, errors, session_id, status |
| InterpreterOutput | Pydantic Model | Individual output: type (stdout/stderr/error/display_data/execute_result) and data |
| FileInput | Pydantic Model | File upload spec: name, encoding, content |
Usage Examples
from together import Together
client = Together()
result = client.code_interpreter.run(
code="print('hello')",
language="python",
)
# result is ExecuteResponse
# result.data is ExecuteResponseData
print(result.data.session_id)
print(result.data.status) # "completed"
for output in result.data.outputs:
# output is InterpreterOutput
print(f"Type: {output.type}, Data: {output.data}")
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment