🤖 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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyter_ext_ai-0.1.0.tar.gz.
File metadata
- Download URL: jupyter_ext_ai-0.1.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16ab8b2c2f139dbd2eb01a1000f2c4f775c60ede5608ed5ef4034b94b382f7f9
|
|
| MD5 |
c16142a8b41e13b4ed5fa2c24bc874b4
|
|
| BLAKE2b-256 |
db89990aaa7c1c50abbdb91a9fc6f385a0da8c329fa38cf52aa03f0c0250b6e5
|
File details
Details for the file jupyter_ext_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jupyter_ext_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9d9fd9513d0e5c62ca9d48ccc33a597d7bf72f26739fda6b831bcd613be3c53
|
|
| MD5 |
ffb5edb4daf814b55302f33d72f6580c
|
|
| BLAKE2b-256 |
a8f33d202784fdb67df6d5e19f9b90cc72a8cb5da423194fceedbbd997fe6daf
|