inis.run
Integrations

Python SDK

pip-installable client for sessions, exec, files, and preview URLs.

Install

pip install inis

Quick example

import inis

client = inis.Client(token="inis_...")

with client.session() as session:
    session.exec(["pip", "install", "pandas", "-q"])
    session.files.write("/workspace/data.csv", "a,b\n1,2\n")
    result = session.exec(["python3", "-c", """
import pandas as pd
print(pd.read_csv('/workspace/data.csv').sum())
"""])
    print(result.stdout)

    preview = session.expose(port=8080)
    print(preview.preview_url)

API surface

MethodDescription
Client.session()Context manager; creates and destroys a session
Client.sessions.create() / .attach(id) / .list() / .get(id)Create, reattach, list, inspect
session.exec(argv)Run a command; returns stdout/stderr/exit_code
session.exec_stream(argv)SSE stream of stdout/stderr (data is already a str)
session.run_code(code) / restart_context()Persistent Python interpreter in the session
session.read_file(path) / write_file / list_filesFile I/O (encoding="base64" on read_file for binary → bytes)
session.files.read/write/listText-only convenience aliases (no encoding= on files.read)
session.write_files / find_files / grep_filesBatch write, glob find, content grep
session.mkdir / remove / renamePath ops
session.upload_file / download_fileStream large files
session.start_process / list_processes / get_process / kill_processNamed background processes
session.get_process_logs / stream_process_logsBuffered or live process output
session.expose / unexposeHTTPS preview URLs
session.pause / resume / forkLifecycle
session.checkpoint / restore / checkpointsNamed checkpoints
session.save_as_template / client.templatesTemplates
client.execute(language=..., code=...)Stateless run via /v1/sessions/exec
session.pty(...)Interactive PTY — see below
AsyncClient / AsyncSessionFull async twin (async with, await, async for)

sessions.create / Client.session also take template, size, env, secrets, timers, and egress — see Sessions API and Environment and secrets.

Async

import asyncio
from inis import AsyncClient

async def main():
    async with AsyncClient(token="inis_...") as client:
        async with client.session(template="python") as session:
            result = await session.exec(["python3", "-c", "print(42)"])
            print(result.stdout)

asyncio.run(main())

Streaming exec

for event in session.exec_stream(["python3", "-u", "train.py"]):
    if event.stream in ("stdout", "stderr"):
        print(event.data, end="")
    elif event.stream == "exit":
        print(f"exit={event.exit_code}")

Code interpreter

with client.session(template="python") as session:
    session.run_code("x = 41")
    for r in session.run_code("x + 1"):
        if r.type == "text":
            print(r.text)  # 42
    session.restart_context()  # clear interpreter globals

Interactive terminal (PTY)

with client.session() as session:
    with session.pty(cols=80, rows=24) as term:
        term.write("python3 -c 'print(1 + 1)'\n")
        for chunk in term:
            print(chunk.decode(), end="")
            if b"2\n" in chunk:
                term.write("exit()\n")
    print(term.exit_code)

Async: async with await session.pty(...) as term: and async for chunk in term. Pass command=["python3", "-i"] for a REPL. term.resize(cols, rows) / term.kill() as needed.

Embedding a terminal in your own product. The SDK authenticates with your INIS_API_KEY on the WebSocket — never send that key to a browser. Proxy PTY frames through your backend (same pattern as the console).

Configuration

client = inis.Client(
    token="inis_...",
    base_url="https://api.inis.run",  # default
    timeout=120.0,  # seconds
)

Environment variables: INIS_API_KEY, INIS_BASE_URL.

On this page