nbinlineai
Write AI prompts directly in JupyterLab notebooks. Each prompt has its own OpenAI or Anthropic model choice, and its answer appears in a paired markdown cell below it. Prompts and answers stay in the notebook when you save and reopen it.
Install in JupyterLab
You need Python 3.11 or newer and JupyterLab 4.
- In JupyterLab, open Extension Manager (the puzzle icon), search for nbinlineai, and install it. Restart the Jupyter server after installation so the Python extension loads; refreshing the browser alone is insufficient.
- Open a Python notebook. Click Configure AI in the notebook toolbar and paste an OpenAI or Anthropic API key. You can add either provider or both. Keys are saved in your user configuration, outside notebooks. On macOS and Linux the default is
~/.config/nbinlineai/credentials.json; Windows uses its user configuration directory. An absoluteXDG_CONFIG_HOMEchanges the location when set. - Select a cell, click AI Prompt in the notebook toolbar, write your question, and press Shift+Enter or Run AI. You can choose a provider and model for each prompt. Blank model uses the provider default.
Your school or hosted Jupyter service may manage extensions centrally. If Extension Manager is unavailable, ask the administrator to install the package in the Python environment running Jupyter Server and restart that server. For a self-managed environment using pip, the equivalent command is:
python -m pip install nbinlineai
If you launch JupyterLab from a project managed by uv, add the extension as a project dependency so future uv sync runs keep it installed:
uv add jupyterlab nbinlineai
uv run jupyter lab
Some uv environments omit pip, which the JupyterLab Extension Manager may need for its Install button. In that case, use uv add as above, or add pip to the environment before using the panel.
API provider usage is billed by the provider separately from JupyterLab. You can replace or remove a saved key through Configure AI. A server administrator can also provide OPENAI_API_KEY or ANTHROPIC_API_KEY in the Jupyter server environment; a key you save in the UI takes precedence for that provider.
Saved keys are shared by JupyterLab environments under the same operating-system account. A Python kernel running as that account can read that account's files, including its saved keys; use a separate OS account for notebooks you do not trust.
Try it
In a Python notebook, run this code cell:
score = 7
def add_bonus(value: int) -> int:
"""Return the score plus a bonus."""
return score + value
Insert an AI Prompt cell below it and ask:
What is $`score`? Call &`add_bonus` with value 3, then explain the result.
The source distribution also includes examples/quickstart.ipynb with these cells.
$ followed by a backtick-quoted Python name uses its live value from the running kernel. This can differ from what the notebook source currently says. To let the model call a function you defined in the kernel, name it with &, for example Call &`add_bonus` with value 3. Only functions named in that prompt are made available as tools. This release supports ordinary synchronous Python functions with named parameters and simple annotations. Function calls can change notebook state; cancelling a prompt cannot undo an earlier call.
The model sees bounded code source from cells above the prompt and earlier AI turns. It does not see later cells. Only AI Prompt cells use the new Shift+Enter behavior; ordinary code cells run normally. Re-running a prompt updates its paired answer cell instead of adding another one.
This release supports text prompts and Python kernels. It does not send notebook images or rich outputs as model context, and it does not offer ChatGPT subscription sign-in.
Develop from source
This section is for contributors. Installing the published package does not require Node.js or a source checkout. Development requires Python 3.11+, Node.js 22.12+ (or 20.19+), uv, and JupyterLab 4.
uv sync --python 3.12 --group dev --no-install-project
uv run --no-sync jlpm install
uv run --no-sync jlpm build:prod
uv sync --python 3.12 --group dev
uv run --no-sync jupyter-builder develop . --overwrite
uv run jupyter lab
The backend reads provider keys saved by Configure AI. For a developer-only environment, it can also read OPENAI_API_KEY or ANTHROPIC_API_KEY from the server environment or a project-root .env file. Never put keys in a notebook.
Run tests and packaging checks:
uv run --no-sync pytest
uv run --no-sync jlpm test:unit
uv run --no-sync jlpm build:prod
uv run --no-sync jupyter-builder develop . --overwrite
uv run --no-sync jlpm test:e2e
uv build
The browser suite starts its own JupyterLab on 127.0.0.1:8897, uses a real Python kernel from the project environment, and replaces only the model provider with a deterministic test implementation. It refuses port 8888, disables port retries, and keeps notebooks, Jupyter settings, and saved fake keys in temporary directories. Use NBINLINEAI_E2E_PORT=8899 to select another free port. Install Chromium once if Playwright asks: uv run --no-sync jlpm playwright install chromium.
An optional live smoke sends one small prompt to each configured API provider and verifies variable lookup plus a function call:
NBINLINEAI_E2E_LIVE=1 uv run --no-sync jlpm test:e2e
A tool round can make multiple provider API calls within one prompt. These live requests incur provider usage.
License
GPL-3.0-only. The full license text is included in the package.
Release files for nbinlineai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nbinlineai-0.1.0.tar.gz | 202.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nbinlineai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 251.5 kB
Release files / nbinlineai-0.1.0.tar.gz
| Download URL | nbinlineai-0.1.0.tar.gz |
|---|---|
| Size | 202.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
375a95c36b528be3c17f8e4470bf7cc4befdfb0244514f4dcd04d7385a1de595
|
|
BLAKE2b-256 checksum How to use checksums |
6d930c727bc94f50cace8558760d05e92acb753698d216ebe75cd555b0cd6c41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nbinlineai-0.1.0-py3-none-any.whl
| Download URL | nbinlineai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 48.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
622a131bc8fbcfee4c7cbb9e2393c712123c9ae9120c932392b42d558042cfa7
|
|
BLAKE2b-256 checksum How to use checksums |
d8fcdf76413ce7758c2acb9459897ba96103019d52fc5485c92c59ac41f387cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|