🤖 jupyter-ext-ai
IPython magic commands for chatting with LLMs — OpenAI, Gemini & Claude — right inside Jupyter notebooks.
✨ Features
| Magic | Description |
|---|---|
%ai <prompt> |
One-line prompt → LLM response |
%%ai [flags] |
Cell magic — cell body is the prompt |
%ai_config |
View / update provider, model, temperature, etc. |
%ai_models |
List models for the active provider |
%ai_history |
Print conversation history |
%ai_reset |
Clear conversation history |
Supported providers: OpenAI · Google Gemini · Anthropic Claude
📦 Installation
pip install jupyter-ext-ai
From source (development):
git clone https://github.com/novatechnolab/jupyter-ext-ai.git
cd jupyter-ext-ai
pip install -e ".[dev]"
🔑 Configuration
Set your API keys as environment variables:
# Add to your ~/.bashrc, ~/.zshrc, or .env file
export OPENAI_API_KEY="sk-..."
export GOOGLE_API_KEY="AIza..."
export ANTHROPIC_API_KEY="sk-ant-..."
# Optionally set defaults
export JUPYTER_AI_PROVIDER="openai" # openai | gemini | claude
export JUPYTER_AI_MODEL="gpt-4o-mini" # any model supported by the provider
🚀 Quickstart
# Load the extension
%load_ext jupyter_ext_ai
# Ask a question (uses default provider)
%ai What is the capital of France?
# Switch provider on the fly
%ai --provider gemini Explain recursion in one sentence.
# Use cell magic for longer prompts
%%ai --provider claude --model claude-sonnet-4-20250514
Write a Python function that computes the Fibonacci sequence
using dynamic programming. Include type hints and docstring.
# View / change config
%ai_config
%ai_config --provider gemini --model gemini-2.0-flash --temperature 0.3
# List models
%ai_models openai
# Show conversation history
%ai_history
# Clear history and start fresh
%ai_reset
🏗️ Project Structure
jupyter-ext-ai/
├── pyproject.toml # Build config & metadata
├── README.md
├── LICENSE
├── CONTRIBUTING.md
├── MANIFEST.in
├── .github/
│ └── workflows/
│ └── ci.yml # CI + PyPI publish on tag
├── src/
│ └── jupyter_ext_ai/
│ ├── __init__.py # load_ipython_extension() hook
│ ├── magic.py # IPython Magics class
│ ├── config.py # Config dataclass
│ └── providers/
│ ├── __init__.py # Provider registry
│ ├── base.py # Abstract base class
│ ├── openai_provider.py
│ ├── gemini_provider.py
│ └── claude_provider.py
└── tests/
├── conftest.py
├── test_config.py
├── test_providers.py
└── test_magic.py
🧪 Development
# Install in editable mode with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Lint
ruff check src/ tests/
# Build distribution
python -m build
# Check dist before uploading
twine check dist/*
📤 Publishing to PyPI
First time setup
- Create an account at pypi.org (and optionally test.pypi.org)
- Generate an API token under Account settings → API tokens
Publish manually
# Build
python -m build
# Upload to TestPyPI first
twine upload --repository testpypi dist/*
# Upload to PyPI
twine upload dist/*
Automated (GitHub Actions)
Push a version tag to trigger the CI workflow:
git tag v0.1.0
git push origin v0.1.0
The GitHub Action at .github/workflows/ci.yml will lint, test, build, and publish to PyPI automatically (requires a PYPI_API_TOKEN secret in your repo settings).
📄 License
MIT — use it however you like.
Metadata
Release files for jupyter-ext-ai 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 | Provenance | Actions |
|---|---|---|---|---|
| jupyter_ext_ai-0.1.0.tar.gz | 11.4 kB | Without provenance | Details for jupyter_ext_ai-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jupyter_ext_ai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for jupyter_ext_ai-0.1.0-py3-none-any.whl |
Total release size: 24.1 kB
Release files / jupyter_ext_ai-0.1.0.tar.gz
| Download URL | jupyter_ext_ai-0.1.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16ab8b2c2f139dbd2eb01a1000f2c4f775c60ede5608ed5ef4034b94b382f7f9
|
|
BLAKE2b-256 checksum How to use checksums |
db89990aaa7c1c50abbdb91a9fc6f385a0da8c329fa38cf52aa03f0c0250b6e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / jupyter_ext_ai-0.1.0-py3-none-any.whl
| Download URL | jupyter_ext_ai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9d9fd9513d0e5c62ca9d48ccc33a597d7bf72f26739fda6b831bcd613be3c53
|
|
BLAKE2b-256 checksum How to use checksums |
a8f33d202784fdb67df6d5e19f9b90cc72a8cb5da423194fceedbbd997fe6daf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for jupyter-ext-ai 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.