{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aicostbudget.com/schemas/agent-cost-evidence-v0.json",
  "title": "AICostBudget Agent Cost Evidence — v0 family, profile 0.1",
  "description": "Cost metadata interchange profile. Schema family v0; trace_version 0.1. This URL pins profile 0.1. Only normalized profile JSON is accepted; no direct third-party tracing adapter is provided.",
  "type": "object",
  "required": [
    "trace_version",
    "trace_id",
    "tasks"
  ],
  "additionalProperties": false,
  "properties": {
    "trace_version": {
      "const": "0.1"
    },
    "trace_id": {
      "type": "string",
      "minLength": 1,
      "pattern": "\\S"
    },
    "tasks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "task_id",
          "success",
          "attempts"
        ],
        "additionalProperties": false,
        "properties": {
          "task_id": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "success": {
            "type": "boolean"
          },
          "acceptance_rule": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "outcome_label": {
            "type": "string"
          },
          "attempts": {
            "type": "array",
            "minItems": 1,
            "items": {
              "additionalProperties": false,
              "required": [
                "attempt_id",
                "attempt_number",
                "model_calls"
              ],
              "properties": {
                "model_calls": {
                  "minItems": 1,
                  "items": {
                    "type": "object",
                    "required": [
                      "span_id",
                      "provider",
                      "model",
                      "input_tokens",
                      "output_tokens"
                    ],
                    "additionalProperties": false,
                    "properties": {
                      "timestamp": {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])T(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|[+-](?:[01]\\d|2[0-3]):[0-5]\\d)$"
                      },
                      "provider": {
                        "type": "string",
                        "minLength": 1,
                        "pattern": "\\S"
                      },
                      "model": {
                        "type": "string",
                        "minLength": 1,
                        "pattern": "\\S"
                      },
                      "input_tokens": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "output_tokens": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "cached_input_tokens": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "cache_write_tokens": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "is_fallback": {
                        "type": "boolean"
                      },
                      "external_cost_usd": {
                        "type": "number",
                        "minimum": 0
                      },
                      "non_token_components": {
                        "minItems": 1,
                        "type": "array",
                        "items": {
                          "properties": {
                            "quantity": {
                              "minimum": 0,
                              "type": "number"
                            },
                            "price_component": {
                              "minLength": 1,
                              "type": "string",
                              "pattern": "\\S"
                            },
                            "unit": {
                              "minLength": 1,
                              "type": "string",
                              "pattern": "\\S"
                            }
                          },
                          "type": "object",
                          "additionalProperties": false,
                          "required": [
                            "quantity",
                            "unit",
                            "price_component"
                          ]
                        }
                      },
                      "span_id": {
                        "type": "string",
                        "minLength": 1,
                        "pattern": "\\S"
                      }
                    }
                  },
                  "type": "array"
                },
                "attempt_number": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "attempt_id": {
                  "type": "string",
                  "minLength": 1,
                  "pattern": "\\S"
                }
              },
              "type": "object"
            }
          }
        }
      }
    }
  },
  "$comment": "Human reference: https://aicostbudget.com/en/team-api-cost-report#agent-cost-format-reference. Synthetic example: https://aicostbudget.com/schemas/examples/agent-cost-evidence-v0-example.json. Runtime also checks identifier uniqueness, consecutive attempt numbers, and cached-token subset sums. The schema and identified synthetic example are licensed under Apache-2.0; see https://aicostbudget.com/schemas/LICENSE.txt and x-license-scope. These extension annotations do not change validation.",
  "x-license": "Apache-2.0",
  "x-license-url": "https://aicostbudget.com/schemas/LICENSE.txt",
  "x-license-assets": [
    "/schemas/agent-cost-evidence-v0.json",
    "/schemas/examples/agent-cost-evidence-v0-example.json"
  ],
  "x-license-scope": "The Apache License 2.0 applies only to the AICostBudget Agent Cost Evidence public specification assets explicitly identified under /schemas/. It does not license the rest of the AICostBudget website, application source code, pricing engine, datasets, or other content. Future related assets are covered only when explicitly declared part of this public specification."
}
