README

#Model Package

The model package provides configuration and loading of AI model providers.

#Core Types

#Model

Configuration for connecting to an AI model.

///|
pub struct Model {
name : String
description : String?
model_name : String
model_type : Type
api_key : String
base_url : String
safe_zone_tokens : Int
supports_anthropic_prompt_caching : Bool
supports_apply_patch : Bool
access_token : String?
account_id : String?
refresh_token : String?
id_token : String?
} derive(ToJson, Eq, Show)

Key Fields:
  • name: Identifier for this configuration
  • model_name: Provider-specific model identifier
  • model_type: Provider type (OpenAI, Anthropic, etc.)
  • api_key: API authentication key
  • base_url: API endpoint URL
  • safe_zone_tokens: Token budget for context management

#Provider

Supported AI providers.

///|
pub(all) enum Provider {
OpenAI
Anthropic
CodexOAuth
Copilot
Qwen
Kimi
KimiCoding
}

#Type

Model deployment type.

///|
pub(all) enum Type {
SaaS(Provider)
}

#Model Presets

#CommonModels (OpenRouter)

///|
pub(all) enum CommonModels {
Qwen3CoderPlus
Qwen3CoderFlash
Grok4Fast
GrokCodeFast1
ClaudeHaiku4_5
ClaudeSonnet4_5
ClaudeOpus4_5
Gpt5Codex
Gpt5
Gpt5Mini
Gpt5Nano
KimiK2_0905
Glm4_6
MinimaxM2
DeepseekV3_2
}

#CopilotModels

///|
pub(all) enum CopilotModels {
Gpt4_1
Gpt4o
Gpt5
Gpt5Mini
Gpt5Codex
Gpt5_1
Gpt5_1Codex
Gpt5_1CodexMax
Gpt5_1CodexMini
Gpt5_2
O3
O3Mini
O4Mini
Claude3_5Sonnet
Claude3_7Sonnet
ClaudeHaiku4_5
ClaudeOpus4_5
Gemini2_0Flash
Gemini2_5Pro
GrokCodeFast1
// ... more models
}

#CodexModels

///|
pub(all) enum CodexModels {
Gpt5_6Sol
Gpt5_4 // Explicit legacy compatibility only
Gpt5_3Codex
}

#Key APIs

#Model Creation

pub fn Model::new(
api_key~ : String,
base_url~ : String,
name~ : String,
safe_zone_tokens~ : Int,
model_name? : String,
model_type? : Type,
description? : String,
supports_anthropic_prompt_caching? : Bool,
// OAuth fields for CodexOAuth provider
access_token? : String,
account_id? : String,
refresh_token? : String,
id_token? : String,
) -> Model

#Preset Model Constructors

// OpenRouter models
pub fn open_router_model(
api_key~ : String,
name? : CommonModels,
) -> Model

// GitHub Copilot models
pub fn copilot_model(
copilot_token~ : String,
github_token~ : String,
name? : CopilotModels,
) -> Model

// Codex OAuth models
pub fn codex_oauth_model(
access_token~ : String,
account_id~ : String,
refresh_token~ : String,
id_token? : String,
name? : CodexModels,
) -> Model

// Qwen models
pub fn qwen_model(
api_key~ : String,
name? : QwenModels,
) -> Model

// Kimi models
pub fn kimi_model(api_key~ : String, name? : KimiModels) -> Model
pub fn kimi_coding_model(api_key~ : String, name? : KimiCodingModels) -> Model

#Model Loading

pub async fn load(
home? : StringView,
cwd? : StringView,
name? : String,
) -> Model?

Loads model configuration from the MoonSuite MoonClaw product home: .moonsuite/products/moonclaw/models/models.json.

#Loader

type Loader

pub async fn Loader::new(
home? : StringView,
cwd? : StringView,
) -> Self

pub async fn Loader::get_model(Self, name? : String) -> Model?
pub async fn Loader::models(Self) -> ArrayView[Model]

#Usage Example

// Using OpenRouter

///|
let model = @model.open_router_model(
api_key="sk-or-...",
name=@model.CommonModels::ClaudeSonnet4_5,
)

// Using GitHub Copilot

///|
let model = @model.copilot_model(
copilot_token="ghu_...",
github_token="ghp_...",
name=@model.CopilotModels::Gpt5_1,
)

// Custom model configuration

///|
let model = @model.Model::new(
api_key="your-api-key",
base_url="https://api.example.com/v1",
name="custom-model",
safe_zone_tokens=128000,
model_name="custom-model-v1",
)

// Load from configuration file

///|
let model = @model.load(name="my-model")

#Configuration File Format

Models are configured in .moonsuite/products/moonclaw/models/models.json:

{ "providers": { "openrouter": { "baseUrl": "https://openrouter.ai/api/v1", "apiKey": "sk-or-...", "models": [ { "id": "claude-sonnet", "name": "anthropic/claude-sonnet-4.5" } ] } } }

#Dependencies

  • json: JSON serialization
  • uuid: Unique identifiers

#
CodexModels

pub(all) enum CodexModels {
Gpt5_6Sol
Gpt5_4
Gpt5_3Codex
}

impl Show for CodexModels

#
CommonModels

pub(all) enum CommonModels {
Qwen3CoderPlus
Qwen3CoderFlash
Grok4Fast
GrokCodeFast1
ClaudeHaiku4_5
ClaudeSonnet4_5
ClaudeOpus4_5
Gpt5Codex
Gpt5
Gpt5Mini
Gpt5Nano
KimiK2_0905
Glm4_6
MinimaxM2
DeepseekV3_2
}

#
CopilotModels

pub(all) enum CopilotModels {
Gpt4_1
Gpt4o
Gpt5
Gpt5Mini
Gpt5Codex
Gpt5_1
Gpt5_1Codex
Gpt5_1CodexMax
Gpt5_1CodexMini
Gpt5_2
O3
O3Mini
O4Mini
Claude3_5Sonnet
Claude3_7Sonnet
Claude3_7SonnetThought
ClaudeHaiku4_5
ClaudeOpus4
ClaudeOpus4_5
ClaudeOpus41
ClaudeSonnet4
ClaudeSonnet4_5
Gemini2_0Flash
Gemini2_5Pro
Gemini3FlashPreview
Gemini3ProPreview
GrokCodeFast1
}

#
CostConfig

pub struct CostConfig {
input : Double?
output : Double?
cacheRead : Double?
cacheWrite : Double?
} derive(ToJson,
Debug
)

#
KimiCodingModels

pub(all) enum KimiCodingModels {
K2P5
K2_0905
}

#
KimiModels

pub(all) enum KimiModels {
KimiK2_0905
KimiK2P5
MoonshotV1_8k
MoonshotV1_32k
MoonshotV1_128k
}

impl Show for KimiModels

#
Loader

type Loader

#
Loader::get_model

async fn Loader::get_model(self : Loader, name? : String) -> Model?

Retrieve a model from the loader's cache, optionally overriding selected fields.

Parameters:
  • name: Model name to look up. When omitted, the first cached model is returned (if any).
  • api_key: Optional API key override for the returned model.
  • base_url: Optional base URL override for the returned model.

Returns the matching model with overrides applied, or None when no model is available.

#
Loader::models

async fn Loader::models(self : Loader) -> ArrayView[Model]

Returns a read-only view of locally configured and executable models.

Parameters:

  • self : The loader instance to get models from.

Returns an ArrayView[Model] containing all cached models.

#
Loader::new

async fn Loader::new(home? : StringView, cwd? : StringView) -> Loader

Create a model loader scoped to the given MoonSuite root and current working directory.

Parameters:

  • home: Absolute path to the MoonSuite root.
  • cwd: Absolute path to the current project directory.

Returns a Loader instance with an empty model cache that can be populated by calling load.

Populate the loader's in-memory model cache by reading project and user model configuration files from the MoonSuite MoonClaw product home.

#
Model

pub struct Model {
name : String
description : String?
model_name : String
model_type : Type
api_key : String
base_url : String
safe_zone_tokens : Int
supports_anthropic_prompt_caching : Bool
supports_apply_patch : Bool
access_token : String?
account_id : String?
refresh_token : String?
id_token : String?
} derive(Eq, ToJson,
Debug
)

#
Model::new

#as_free_fn
fn Model::new(api_key~ : String, base_url~ : String, name~ : String, safe_zone_tokens~ : Int, model_name? : String, model_type? : Type, description? : String, supports_anthropic_prompt_caching? : Bool, access_token? : String, account_id? : String, refresh_token? : String, id_token? : String) -> Model

Create a new model configuration describing how to reach a provider backed language model.

Parameters:
  • api_key: API key used when issuing requests to the model service.
  • base_url: Base URL of the provider endpoint.
  • name: Identifier for this configuration, used to select models.
  • safe_zone_tokens: Token buffer reserved for internal bookkeeping.
  • model_name: Optional provider specific model identifier.
  • model_type: Optional provider and deployment metadata.
  • description: Optional human readable description.
  • supports_anthropic_prompt_caching: Enable Anthropic prompt caching support when true.

Returns a Model value ready to be passed to higher level APIs.

#
Model::selector

fn Model::selector(self : Model) -> String

Return the stable selector clients must use to choose this model.

model_name is the provider wire identifier. Built-in providers need a namespace so that listing a model and selecting it again are inverse operations.

#
ModelConfig

pub struct ModelConfig {
id : String
name : String?
reasoning : Bool?
input : Array[String]?
cost : CostConfig?
contextWindow : Int?
maxTokens : Int?
} derive(ToJson,
Debug
)

#
Provider

pub(all) enum Provider {
OpenAI
Anthropic
CodexOAuth
Copilot
Qwen
Kimi
KimiCoding
} derive(Eq,
Debug
)

#
ProviderConfig

pub struct ProviderConfig {
baseUrl : String?
api : String?
models : Array[ModelConfig]
apiKey : String?
} derive(ToJson,
Debug
)

#
QwenModels

pub(all) enum QwenModels {
Qwen3CoderPlus
Qwen3CoderFlash
Qwen3_235B_A22B
Qwen3_32B
QwenMax
QwenPlus
QwenTurbo
QwenLong
}

impl Show for QwenModels

#
Type

pub(all) enum Type {
SaaS(Provider)
} derive(Eq,
Debug
)

impl Show for Type
impl ToJson for Type

#
codex_oauth_model

fn codex_oauth_model(access_token~ : String, account_id~ : String, refresh_token~ : String, id_token? : String, name? : CodexModels) -> Model

#
copilot_model

fn copilot_model(copilot_token~ : String, github_token~ : String, name? : CopilotModels) -> Model

#
kimi_coding_model

fn kimi_coding_model(api_key~ : String, name? : KimiCodingModels) -> Model

#
kimi_model

fn kimi_model(api_key~ : String, name? : KimiModels) -> Model

#
load

async fn load(home? : StringView, cwd? : StringView, name? : String) -> Model?

#
open_router_model

fn open_router_model(api_key~ : String, name? : CommonModels) -> Model

Default to qwen3-coder-plus model on OpenRouter for testing

#
qwen_model

fn qwen_model(api_key~ : String, name? : QwenModels) -> Model