Documentation
¶
Index ¶
- func FreeAndPreferred(all []string) (models []string, selected string)
- func IsAnonymousFree(model string) bool
- func IsFree(model string) bool
- func List(dir, bin string) ([]string, error)
- func ListContext(ctx context.Context, dir, bin string) ([]string, error)
- func ListFree(dir, bin string) (models []string, selected string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FreeAndPreferred ¶ added in v0.0.269
FreeAndPreferred is ListFree without the CLI: it keeps the free ids and picks the one to use. It is exported so the selection rule is testable against a catalogue instead of whatever the machine has installed.
func IsAnonymousFree ¶ added in v0.0.269
IsAnonymousFree reports whether a model runs with no account at all.
Only OpenCode's own `opencode/*-free` models do. `kilo/…:free` and `openrouter/…:free` need their provider's key, so a caller that runs the CLI with an empty credential directory must not pick them: it would trade a working install for a 401.
func IsFree ¶ added in v0.0.269
IsFree reports whether a model id belongs to a free tier. It is the broad answer: several providers publish `:free` models.
func List ¶ added in v0.0.269
List runs `opencode models` and returns every model id it prints, in the order the CLI prints them.
dir is where the command runs. Without it the probe inherits the caller's working directory, which for a server is not the repository being worked on: the project resolved, the config loaded and the failure reported all belong to the wrong tree. bin pins the executable so the probe and the run it feeds can never be two different installs.
func ListContext ¶ added in v0.0.273
ListContext is List with a deadline. A CLI that hangs while booting must not hold the caller forever: the catalogue is advisory, and the caller can fall back to what it already knows.
func ListFree ¶
ListFree returns the free models and the one to use when the caller has no model of its own.
The selection prefers an anonymous OpenCode free model over the first free model in the list. The CLI orders its catalogue, not our needs: the first free id may be a `kilo/…:free` that only works with that provider's key.
Types ¶
This section is empty.