Getting Started
- Install: Run
python -m pip install circuitgenwith Python 3.10 or newer. - Open the CLI: Run
circuit, then choose Generate, Render, or Validate. Generate needs a selected AI provider, model, and API key; Render and Validate work offline. - Use Python: Call
generate()for text prompts, orfrom_netlist(),validate(), andrender()for JSON netlists. - Diagnose setup: Run
python -m circuitgen doctorif CircuitGen or thecircuitcommand does not work.
CircuitGen is a Python library and CLI for generating circuit schematics from text descriptions or netlists.
Install
CircuitGen requires Python 3.10 or newer. Install the library and CLI together:
python -m pip install circuitgen
You can also install into a virtual environment. pipx install circuitgen is an option if you want an isolated CLI installation.
Python library or CLI?
Use the Python library when a script needs to generate, validate, or render a circuit and work with the returned netlist or SVG. Use the interactive CLI to describe a circuit, open JSON files, and choose settings in your terminal. The direct CLI commands do the same jobs from scripts or shell commands. Both interfaces share the same validation and rendering engine.
Generate your first schematic
Create a schematic from a written circuit description. This requires a configured AI provider and its API key. Though each method below uses the same prompt, AI output may vary, so check its values and connections.
- Interactive CLI
- Command Line
- Python
Open the terminal app:
circuit
Select Generate, enter the prompt below, choose an output file, and start generation. The first launch lets you set up a provider; you can also configure it in Settings.
Prompt
A 9 V battery connected to a red LED through a 360 Ω resistor.
Pass the description directly. Replace the provider and model placeholders with values available to your account:
circuit generate "A 9 V battery connected to a red LED through a 360 Ω resistor." --provider YOUR_PROVIDER --model YOUR_MODEL_ID -o led.svg
Pass the description to generate(). Set your provider's API key in an environment variable, then replace both placeholders with a provider ID and model available to your account:
from circuitgen import generate
generate(
"A 9 V battery connected in series with a 360 Ω resistor and a red LED.",
provider="YOUR_PROVIDER", # Replace with your provider.
model="YOUR_MODEL_ID", # Replace with a model available to your key.
api_key="YOUR_API_KEY", # Replace with your provider's API key.
output="led.svg"
)
The illustration shows the checked LED example netlist rendered by CircuitGen. It is a sample of the intended circuit, not a promise that every AI provider returns identical JSON.
Render and validate netlists
CircuitGen can also check and draw a JSON netlist without an API key or internet access. Download this tested file, save it as led.json, and try either action:
- Interactive CLI
- Command Line
- Python
circuit
Select Render, open led.json, and save the schematic. Then return home, select Validate, and open the same file to see its checks without creating another image.
circuit render led.json -o led.svg
circuit validate led.json
import json
from pathlib import Path
from circuitgen import from_netlist, validate
netlist = json.loads(Path("led.json").read_text(encoding="utf-8"))
result = from_netlist(netlist, output="led.svg")
check = validate(netlist)
print(check.valid, check.errors)
Troubleshooting
Start with the doctor command even if circuit will not launch:
python -m circuitgen doctor
It reports PASS, WARNING, or FAIL for Python, the installed package, the launcher, PATH, dependencies, configuration, credentials, and terminal. Read Suggested Actions under the summary. A warning can describe a limited feature, such as unavailable secure key storage; a failure needs attention.
If the circuit command still will not run, python -m circuitgen launches the same interactive app through your current Python installation. The module name is circuitgen.
circuit is not found
If Console Launcher passes but PATH Resolution fails or warns, the launcher exists but this terminal cannot find the intended one. On Windows, check before changing anything, then run setup if needed:
python -m circuitgen setup-path --check
python -m circuitgen setup-path
Restart the terminal afterward. On macOS or Linux, add the installed scripts directory to PATH or use your environment's activation steps. python -m circuitgen can launch the app while PATH is being fixed.
Wrong Python environment
If Python Version, Python Environment Type, or CircuitGen Package shows an unexpected version or location, activate the intended environment and install with its Python:
python -m pip install circuitgen
Run doctor again with that same python to confirm the package and launcher locations.
Missing dependencies or settings access
If a Dependency check fails, try python -m pip install --upgrade circuitgen; if it remains broken, try python -m pip install --force-reinstall circuitgen. If Config Directory warns, check that the reported directory is writable. If Credential Storage warns, use the provider's environment variable instead of saving a key in Settings.
Provider or generation errors
For an invalid or missing key, check the provider selected in Settings and its key or environment variable. If a model is unavailable or a quota is exhausted, check the provider account and choose an available model. If generation returns an invalid netlist, inspect the reported validation error and the generated connections; try a clearer description or a different model. Rendering and validation still work offline.