config

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseURL   = "https://api.runware.ai/v1"
	DefaultWSBaseURL = "wss://ws-api.runware.ai/v1"
	MaskedKeySuffix  = "•••••"
	DefaultOutputDir = "./outputs"
	DefaultFormat    = "table"
	// DefaultTransport matches transport.SchemeWS; kept as a literal so the
	// config package stays free of internal imports.
	DefaultTransport = "ws"
)

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the config directory path.

func ConfigPath

func ConfigPath() string

ConfigPath returns the full path to the config file.

func DeletePreset

func DeletePreset(name string) error

DeletePreset removes a named preset.

func EnsureConfigDir

func EnsureConfigDir() error

EnsureConfigDir creates the config directory if it doesn't exist.

func GetAPIKey

func GetAPIKey() string

GetAPIKey returns the API key.

func GetBaseURL

func GetBaseURL() string

GetBaseURL returns the HTTP API base URL. RUNWARE_BASE_URL overrides the default; this is not exposed in the user-facing config file and is intended for internal testing only.

func GetWSBaseURL added in v0.7.0

func GetWSBaseURL() string

GetWSBaseURL returns the WebSocket API base URL. RUNWARE_WS_BASE_URL overrides the default; this is not exposed in the user-facing config file and is intended for internal testing only.

func Init

func Init() error

Init locates the config directory (~/.runware) and validates that the config file, if present, parses cleanly so startup fails loudly on a corrupt file.

func ListPresets

func ListPresets() []string

ListPresets returns all preset names.

func MaskKey

func MaskKey(key string) string

MaskKey masks an API key for display, showing the first 16 characters followed by "•••••". If the key is shorter than 16 characters, only "•••••" is shown.

func RemoveAPIKey

func RemoveAPIKey() error

RemoveAPIKey clears the stored API key.

func Save

func Save(cfg *Config) error

Save writes the config to disk. Subsequent Get() calls re-read the file, so they reflect the change.

func SavePreset

func SavePreset(name string, preset Preset) error

SavePreset saves a named preset.

func SetAPIKey

func SetAPIKey(key string) error

SetAPIKey saves the API key.

func ValidDefaultsKeys added in v0.10.0

func ValidDefaultsKeys() map[string]struct{}

ValidDefaultsKeys returns the set of config keys that live under the "defaults" namespace and can be set via `config set`.

Types

type Config

type Config struct {
	APIKey   string            `yaml:"api_key,omitempty"`
	Defaults Defaults          `yaml:"defaults"`
	Presets  map[string]Preset `yaml:"presets,omitempty"`
}

Config is the full configuration structure.

func FileConfig added in v0.11.0

func FileConfig() (*Config, error)

FileConfig returns the config exactly as stored on disk, without applying environment overrides or default fallbacks. Use this for read-modify-write operations so env-only secrets are never persisted to the file. A missing file yields a zero config.

func Get

func Get() *Config

Get returns the current merged config: file values with fallback defaults applied and the RUNWARE_API_KEY environment variable taking precedence over the file's API key.

type Defaults

type Defaults struct {
	OutputDir string `yaml:"output_dir"`
	Format    string `yaml:"format"`
	Transport string `yaml:"transport"`
}

Defaults holds default values for commands.

type Preset

type Preset struct {
	Model  string            `yaml:"model,omitempty"`
	Params map[string]string `yaml:"params,omitempty"`
}

Preset is a named set of inference parameters for use with the run command. Model is stored separately because it is structurally special: it is needed to fetch the JSON Schema during shell completion and is passed as the first positional argument to client.Run. All other parameters are stored as arbitrary key=value string pairs, consistent with how the run command accepts them on the command line.

func GetPreset

func GetPreset(name string) *Preset

GetPreset returns a named preset, or nil if not found.

Jump to

Keyboard shortcuts

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