start_within in config, so an agent key is optional here. The key is still the simpler path, because it changes without a restart.
Set this up with an agent
Copy the block below into any coding agent. It never asks for your API key: you run the one export line yourself.Copy agent setup prompt
Copy agent setup prompt
Configure OpenScience
-
Export the key in the shell that starts OpenScience.
-
Write the provider entry to
openscience.json. -
Start OpenScience with the config directory set.
start_within out of options when your key holds the deadline. We only fill a stored default in when the field is absent, so a value here would override the key on every request.
Set "start_within": "default" on every model instead when you’re not using an agent key. That’s the safe baseline, because a model picked with no session selection then routes standard rather than racing by accident.
Where the file goes
OpenScience merges config from several places, and a later source wins.- The global user config in OpenScience’s config directory.
OPENSCIENCE_CONFIG, a path to one config file.synsc.jsonc,synsc.json,openscience.jsonc, andopenscience.jsonfound walking up to the worktree root, unlessOPENSCIENCE_DISABLE_PROJECT_CONFIGis set.OPENSCIENCE_CONFIG_CONTENT, holding the JSON inline.- Those same four names inside each
.openscienceor.synscdirectory on that walk, plus any directory named byOPENSCIENCE_CONFIG_DIR.
OPENSCIENCE_CONFIG names one file. OPENSCIENCE_CONFIG_DIR names a directory and treats the whole thing as config, scanning it for commands, agents, and plugins. Use the directory form when the bundle holds more than JSON.
Load a plugin by placing it
OpenScience scans each config directory for{plugin,plugins}/*.{ts,js} and loads what it finds as a local file. Put the file at plugins/flex.js and leave plugin out of the JSON.
plugin doesn’t work. OpenScience reads every entry there without a file:// prefix as an npm package name and hands it to bun add, so "./plugins/flex.js" fails to install and takes plugin startup down with it.
The scan is one level deep, and it takes every .js and .ts sitting in plugins/ itself. Keep shared modules outside that directory, or OpenScience loads them as plugins too.
The first time OpenScience loads config from a directory it writes package.json, bun.lock, node_modules/, and a .gitignore covering them into it. Expect those, and keep them out of Git.
Troubleshooting
A plugin never loaded. Naming it inplugin sends it to bun add as a package name, which fails and takes plugin startup down. Put the file at plugins/flex.js inside the config directory and leave plugin out of the JSON.
A helper module loaded as a plugin. The scan takes every .js and .ts sitting in plugins/ itself. Move shared modules outside that directory.
Requests never reach us. The top-level model field is what selects the provider. Without it OpenScience stays on its built-in default.
401 invalid_api_key. FLEXINFERENCE_API_KEY is unset in the shell that started OpenScience. Export it before launching.
The key’s deadline never applies. A start_within in a model’s options wins over the key, because we only fill a stored default in when the field is absent. Remove it from the entry.
Anything not specific to OpenScience is on agent keys, and OpenCode holds the per-model deadline options, which OpenScience shares.