ipyai

ipyai is a Rust terminal client for Rustygate. Run Python code and ask questions in one notebook. Rustygate runs the kernel and the AI turns and saves the results in the .ipynb file.

Run

In the fastws workspace, run cargo develop from this directory to install the native ipyai binary in the active environment. Use a running Rustygate with a Python kernelspec such as ipymini. To start a local gateway, run rustygate in the directory where you want to keep your notebooks.

ipyai demo.ipynb

The path is relative to the gateway's files root. ipyai opens that notebook or creates it. Opening a running notebook shares its variables with the other clients. On exit ipyai saves through Rustygate and leaves reused kernels running. It stops its own kernel only when idle, with no other connected client or notebook terminal visible to your account. Other users' terminals stay open.

For a fresh session, run ipyai without a path. Rustygate picks an unused filename under .ipyai/. The kernel starts in your current directory for a loopback gateway, or the gateway's files root for a remote one.

Use --gateway URL or set IPYAI_GATEWAY to change the default http://127.0.0.1:8787. Pass --token-file PATH if the gateway requires authentication. For AI prompts against the default Solve.it server, start Rustygate with AAI_USER_KEY in its environment. Setting it only for ipyai won't change a running gateway. Code and notes don't need a model key.

Use the notebook

Type Python at »»». Prefix an input with . to ask the AI about the same notebook. Use a variable reference such as $`n` in a prompt to include its current value.

»»» n = 6
»»» n * 7
««« 42
»»» .What is seven times $`n`?

Click a mode in the status line or use Alt-C (code), Alt-P (prompt), or Alt-S (shell). The prefixes ;, ., and ! switch modes for one submission. In the matching mode the prefix stays literal: .gitignore in prompt mode asks about .gitignore. Start in prompt mode with ipyai -p. Pass --thinking true or --thinking false to select the gateway's reasoning or standard model for this session's prompt turns.

Write :note Remember this to save a Markdown note without running it. A Python string literal on its own, including a triple-quoted string, also makes a note in code mode. :code "hello" explicitly executes the string. For a multiline note, type :note alone, then compose in note mode; Alt-C returns to code.

Switch to the gateway's persistent shell with Alt-S ($$$), or prefix a single command with !. Directory changes and exported variables survive across commands. The kernel follows changes to the shell's directory. ipyai records foreground command output, excluding alternate-screen drawings. Output a background job prints after the shell prompt returns is not saved. x = !pwd in code mode uses IPython's own capture. In Bash and zsh, shell mode supports job control and !! repeats the previous command.

After a prompt, ctx shows the last measured model input and the model's input limit, in tokens. It stays blank when the gateway can't report both, including when the last Responses request combined multiple provider calls. Errors from ipyai and save warnings stay in this terminal's transcript, not in the notebook.

You can also pipe one submission per line. The notebook still saves all cells; stdout contains results rather than the terminal UI.

printf '%s\n' 'x = 6' 'x * 7' | ipyai demo.ipynb

See DEV.md for the client protocol and tests.