models

package
v0.0.274 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FreeAndPreferred added in v0.0.269

func FreeAndPreferred(all []string) (models []string, selected string)

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

func IsAnonymousFree(model string) bool

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

func IsFree(model string) bool

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

func List(dir, bin string) ([]string, error)

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

func ListContext(ctx context.Context, dir, bin string) ([]string, error)

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

func ListFree(dir, bin string) (models []string, selected string, err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL