models

package
v0.0.239 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 6 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

Overview

Package models lists available Codex CLI models from on-disk files only (~/.codex/models_cache.json and config.toml). It does not spawn `codex`.

Index

Constants

View Source
const (
	// DefaultConfigFile is the Codex home config name.
	DefaultConfigFile = "config.toml"
	// ModelsCacheFile is the Codex home models cache name.
	ModelsCacheFile = "models_cache.json"
	// VisibilityList marks cache entries Codex shows in its model picker.
	VisibilityList = "list"
)

Variables

This section is empty.

Functions

func DefaultHome

func DefaultHome() string

DefaultHome returns $CODEX_HOME when set, otherwise $HOME/.codex. Empty HOME falls back to a temp-dir based path (same idea as sessions home).

func FormatJSON

func FormatJSON(cat Catalog) ([]byte, error)

FormatJSON returns indented Catalog JSON for CLI --json output.

func FormatText

func FormatText(cat Catalog) string

FormatText returns a human-readable catalog listing. The configured default model is marked with a leading "* ".

func Slugs

func Slugs(home string) ([]string, error)

Slugs returns the model ids from List(home) (legacy name; values are Model.ID).

Types

type Catalog

type Catalog struct {
	// Home is the resolved Codex data directory used for the listing.
	Home string `json:"home"`
	// Default is the top-level `model` from config.toml (empty when unset/missing).
	Default string `json:"default,omitempty"`
	// Models is the picker model list: cache entries with visibility "list",
	// plus the configured model when the cache omits it, in cache order.
	Models []Model `json:"models"`
	// FromConfig is true when config.toml was read successfully.
	FromConfig bool `json:"from_config"`
	// FromCache is true when models_cache.json was read successfully.
	FromCache bool `json:"from_cache"`
}

Catalog is the merged file-backed model list for a Codex home.

func List

func List(home string) (Catalog, error)

List returns the file-backed catalog for home. Empty home uses DefaultHome(). Missing files are soft: empty Models, no error unless a present file is unreadable/invalid.

type Model

type Model struct {
	// ID is the model id passed to codex (e.g. "gpt-5.6-sol"); for a
	// configured provider-qualified id it may look like "provider/model".
	ID string `json:"id"`
	// Source is the basename of the file that primarily contributed this id
	// (models_cache.json for cache rows; config.toml for config-only unions).
	Source string `json:"source"`
	// DisplayName is Codex's human name (cache only; empty otherwise).
	DisplayName string `json:"display_name,omitempty"`
	// DefaultReasoning is the cache's default_reasoning_level (empty when unknown).
	DefaultReasoning string `json:"default_reasoning,omitempty"`
	// Reasoning is the supported effort levels in cache order (low…ultra).
	Reasoning []string `json:"reasoning,omitempty"`
}

Model is one selectable Codex model in the unified CLI JSON shape.

Jump to

Keyboard shortcuts

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