AI Providers
- Choose provider and model: Python requires
providerandmodelon everygenerate()call. The interactive CLI saves a selection in Settings; direct CLI flags override saved values. CircuitGen does not choose a default provider or model. - Provide a key: Python accepts
api_key=or the provider's environment variable; the explicit parameter wins. Python does not read CLI-saved keys. The CLI checks the environment first, then its OS credential store. - Shell examples: In PowerShell, set
$env:PROVIDER_KEY_VARIABLE="YOUR_API_KEY"; in Bash, useexport PROVIDER_KEY_VARIABLE="YOUR_API_KEY". Replace the variable name with the one listed for your provider. - Other Python options: Load a project
.envfile withpython-dotenv, or pass a key from a secret manager withapi_key=. CircuitGen does not load.envfiles itself. - Request defaults: Timeout is 120 seconds. Python retries and clarifications are off by default; CLI Settings enable both. CircuitGen does not switch models automatically and makes at most two netlist correction attempts.
Supported Providers
Each provider needs its own account and API key. Select a provider name to open its official key page.
| Provider | ID | Key variable | API keys |
|---|---|---|---|
| Google Gemini | gemini | GEMINI_API_KEY | Google AI Studio |
| OpenAI | openai | OPENAI_API_KEY | OpenAI Platform |
| Anthropic | anthropic | ANTHROPIC_API_KEY | Anthropic Console |
| DeepSeek | deepseek | DEEPSEEK_API_KEY | DeepSeek Platform |
| Groq | groq | GROQ_API_KEY | Groq Console |
| Mistral | mistral | MISTRAL_API_KEY | Mistral Console |
| xAI | xai | XAI_API_KEY | xAI Console |
| OpenRouter | openrouter | OPENROUTER_API_KEY | OpenRouter |
| Together AI | together | TOGETHER_API_KEY | Together AI |
| Fireworks AI | fireworks | FIREWORKS_API_KEY | Fireworks AI |
| Cerebras | cerebras | CEREBRAS_API_KEY | Cerebras Cloud |
Configure a provider
CircuitGen does not pick a provider or model automatically. Choose both for each Python call, or save them in CLI Settings. Use a model ID returned by the provider's model list or shown in its API documentation. A model appearing in the list does not guarantee that your account can use it for every request.
- Interactive CLI
- Direct CLI
- Python
- Run
circuitand open Settings → AI Providers. On first launch, choose Set up AI generation instead. - Select a provider.
- Choose Manage API key to enter a key. Select Verify and save key to test it, or Save without verification to store it in the operating system's secure credential store.
- Choose Browse models to list models available to the key, or enter a model ID and save it.
- Use Test connection to check the key. This tests authentication; it does not guarantee every model request will work.
If a provider environment variable is set, CircuitGen uses it before a key saved in the secure store. Keys entered in CLI Settings are not used by the Python library.
Set a key in the provider's environment variable or save it through the interactive CLI's Settings. When both are available, the environment variable takes precedence over the saved key.
Windows PowerShell:
$env:OPENAI_API_KEY = "YOUR_API_KEY"
circuit generate "A battery powering an LED through a resistor." --provider openai --model YOUR_MODEL_ID -o led.svg
macOS or Linux Bash:
export OPENAI_API_KEY="YOUR_API_KEY"
circuit generate "A battery powering an LED through a resistor." --provider openai --model YOUR_MODEL_ID -o led.svg
--providerand--modeloverride the saved provider and model for this run.- If either is omitted, CircuitGen uses its saved value for the selected provider. A new configuration has no provider or model selected, so choose them in Settings or pass both flags.
- If you choose a provider different from the saved one, provide
--modeltoo. - The API key comes from that provider's environment variable first, then the CLI's secure credential store.
- The CLI does not load
.envfiles. To use one, load its value into your shell environment first, or save the key through Settings.
Python does not read keys saved by the CLI. Choose one of these ways to provide a key. The examples use OpenAI; replace the variable with the one listed for your provider. If you pass both api_key= and an environment variable, api_key= takes precedence.
Option 1: Set an environment variable in your shell. Start your Python script from the same terminal; CircuitGen reads the provider variable automatically, so you can omit api_key=. Replace OPENAI_API_KEY with the variable listed for your provider.
Windows PowerShell:
$env:OPENAI_API_KEY = "YOUR_API_KEY"
macOS or Linux Bash:
export OPENAI_API_KEY="YOUR_API_KEY"
Option 2: Put the key in a .env file. Create a plain text file named .env in your project folder, next to your Python script. Add one line using your provider's environment variable name:
OPENAI_API_KEY=YOUR_API_KEY
Do not commit this file to Git. Install python-dotenv, then call load_dotenv() before generate(). This loads the .env value into the process environment:
python -m pip install python-dotenv
from dotenv import load_dotenv
from circuitgen import generate
load_dotenv()
result = generate(
"A battery powering an LED through a resistor.",
provider="openai",
model="YOUR_MODEL_ID",
output="led.svg",
)
Option 3: Pass a key directly. This is useful when your application gets the key from a secret manager. Prefer this to writing a real key in source code:
from circuitgen import generate
result = generate(
"A battery powering an LED through a resistor.",
provider="openai",
model="YOUR_MODEL_ID",
api_key=api_key,
)
In Python, provider and model are required. CircuitGen does not choose them automatically.
Request settings
- Timeout:
timeoutdefaults to 120 seconds and must be greater than 0 and at most 600 seconds. Change it withtimeout=60, for example. CLI Settings use the same 120-second default. - Retry temporary errors: Python's
retry_transientdefaults toFalse; CLI Settings default to on. When enabled, CircuitGen makes one extra request for eligible temporary errors. - Clarifications: Python's
clarifydefaults toFalse; CLI Settings default to on. When enabled, the provider may ask one short question when essential wiring details are unclear. - Model fallback: CircuitGen does not automatically switch to another model. Select a model available to your account.
- Netlist correction: If a generated netlist fails validation, CircuitGen can make up to two correction attempts after the initial response. This limit is fixed.
Review generated values and connections before using a schematic. Validation and rendering do not guarantee that a circuit will operate as intended.