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.
Entersubmits complete code.Alt-Enterinserts a newline.Alt-UpandAlt-Downrecall inputs of the current kind.Ctrl-A/Emove to the start or end of the draft,Alt-B/Fmove by word,Ctrl-Wcuts the previous word, andCtrl-Yyanks.F2opens the idle draft in$EDITOR.Tabopens or cycles the completion menu;Enteraccepts a choice.Shift-Tabcycles backward, or inspects the code at the cursor when the menu is closed.Alt-.requests an inline completion.Alt-Shift-Winserts all runnable code fences from the last reply.Alt-Shift-1throughAlt-Shift-9insert one fence by number. Rustygate identifies runnable blocks, including shell and kernel magic, and skips Markdown notes.- Click a transcript gutter to fold or unfold that block.
Ctrl-Otoggles the latest foldable block.Alt-0throughAlt-9toggle the numbered gutters. Ctrl-Topens the transcript browser. Click a block or use Up and Down to select it, the wheel or Page Up/Down to scroll, and/or?to search.ycopies the block's source. Type or pressito compose with the transcript still visible;Escreturns to browsing. Use your terminal's mouse override (usually Shift-drag) for ordinary text selection.- In the browser,
htoggles whether the model skips that cell. On a prompt reply,eedits the answer; on an input, it edits the source.Erevises and reruns a cell, discarding later cells.Alt-Rrecalls the latest runnable input. PressEscto keep the recalled text as a new draft without replacing anything. - A spinner beside the mode shortcuts means a cell or prompt is running. Press
Ctrl-Cto interrupt it. Interrupt a prompt before its first reply and ipyai puts it back in an empty composer. Rustygate keeps the interrupted turn in the shared notebook. At an idle composerCtrl-Cclears the draft, andCtrl-Don an empty draft exits once, including when the persistent shell is open.
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.