models

package
v0.0.186 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 6 Imported by: 0

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