{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.anguskit.com/schema/anguscopilot/1.0.0/llm.json",
  "title": "LLM Configuration",
  "description": "LLM 提供商、模型与运行时参数。",
  "type": "object",
  "required": ["provider", "model"],
  "properties": {
    "provider": {
      "description": "LLM 提供商标识。可扩展自定义 provider，需通过 LLMProvider SPI 注册。",
      "type": "string",
      "minLength": 1,
      "examples": ["openai", "anthropic", "qwen", "doubao", "deepseek", "azure-openai", "self-hosted"]
    },
    "model": {
      "description": "模型名称。具体取值由 provider 决定（如 'gpt-4o'、'claude-3-5-sonnet-20240620'）。",
      "type": "string",
      "minLength": 1
    },
    "fallback": {
      "description": "降级模型。当主模型不可用时自动切换。",
      "type": "string",
      "minLength": 1
    },
    "temperature": {
      "description": "采样温度。",
      "type": "number",
      "minimum": 0,
      "maximum": 2
    },
    "topP": {
      "description": "Nucleus sampling 概率截断阈值。",
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 1
    },
    "maxTokens": {
      "description": "单次响应最大 token 数。",
      "type": "integer",
      "minimum": 1
    },
    "maxContextTokens": {
      "description": "上下文窗口最大 token 数（用于上下文压缩判定）。",
      "type": "integer",
      "minimum": 1
    },
    "timeout": {
      "description": "单次 LLM 调用超时。",
      "$ref": "common.json#/$defs/Duration"
    },
    "credentialRef": {
      "description": "凭证引用（不允许明文密钥）。",
      "$ref": "common.json#/$defs/SecretRef"
    },
    "endpoint": {
      "description": "自定义 endpoint URL（私有部署或代理）。",
      "type": "string",
      "format": "uri"
    },
    "router": {
      "description": "LlmRouter 路由策略，按租户预算 / 请求复杂度 / 数据敏感度自动选择模型。",
      "type": "object",
      "properties": {
        "strategy": {
          "type": "string",
          "enum": ["fixed", "budget-aware", "complexity-aware", "data-sensitivity"]
        },
        "rules": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["when", "useModel"],
            "properties": {
              "when": { "type": "string", "description": "SpEL 表达式" },
              "useModel": { "type": "string" }
            },
            "unevaluatedProperties": false
          }
        }
      },
      "unevaluatedProperties": false
    }
  },
  "patternProperties": {
    "^x-": true
  },
  "unevaluatedProperties": false
}
