NetLogo / NetLogo/Netlogo-LLM-Extension
feat: read API keys from environment variables as a fallback
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1
- Forks
- 0
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 4
Description
Summary
Fall back to environment variables for API keys when none is set in config. Small change, removes a real setup step for workshops and keeps keys out of files that get committed.
Research/context only; design still to be done.
Problem
API keys can only come from a config file or llm:set-api-key (BaseHttpProvider.scala:141-146 looks up <provider>_api_key, then generic api_key). There is no environment-variable fallback and no keychain integration.
For workshops this means every participant edits a config file before anything works. It also means keys live in files inside model directories — .gitignore entries for config.txt and config-*.txt were added in #42 precisely because of this.
Prior art
mesa-llm reads os.environ[f"{PROVIDER}_API_KEY"] by convention and calls load_dotenv() at import, so a .env file works with no configuration. Their model string openai/gpt-4o implies OPENAI_API_KEY.
We already have the provider naming convention needed for the same thing — ProviderRegistry.apiKeyConfigKey gives openai_api_key, anthropic_api_key, etc.
Possible direction
Lookup order, first match wins:
- Runtime command (
llm:set-api-key) - Config file
- Environment variable —
OPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY,OPENROUTER_API_KEY,TOGETHER_API_KEY
Deriving the env var name from the existing descriptor keeps this data-driven — no per-provider code.
Open questions
- Env var naming: uppercase the descriptor's
apiKeyConfigKey, or hardcode conventional names per provider? (The conventional names are what users already have set for other tools, which argues for matching them.) - Should
llm:provider-statusshow where a key came from? Useful for debugging "it works on my machine", but must never print the key itself. .envfile support, or environment only? NetLogo is launched from Finder as often as from a shell, where the environment may not carry through — worth checking before assuming env vars are reliably visible.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading BaseHttpProvider.scala:141-146 and ProviderRegistry.apiKeyConfigKey to understand the existing key lookup and provider naming. Resolve the open questions about environment naming, .env support, and status reporting before implementation; done means the fallback behavior and precedence are agreed and documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- authentication, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100