{
  "license": "CC BY 4.0",
  "licenseUrl": "https://creativecommons.org/licenses/by/4.0/",
  "recipe": {
    "slug": "accepted-ai-output-per-dollar",
    "title": "Measure Accepted AI Outputs per Dollar",
    "testedWith": "Apache DataFusion 45.2.0",
    "lastReviewed": "2026-07-27"
  },
  "contract": {
    "tableName": "llm_requests",
    "schema": [
      {
        "name": "timestamp_utc",
        "type": "Timestamp",
        "description": "When the workflow outcome was recorded."
      },
      {
        "name": "feature",
        "type": "Utf8",
        "description": "Stable product feature."
      },
      {
        "name": "model",
        "type": "Utf8",
        "description": "Provider model identifier."
      },
      {
        "name": "accepted",
        "type": "Boolean",
        "description": "Whether the user accepted or saved the result."
      },
      {
        "name": "estimated_cost_usd",
        "type": "Float64",
        "description": "Cost of the model request."
      }
    ]
  },
  "query": "SELECT\n  feature,\n  model,\n  COUNT(*) AS completed_outputs,\n  SUM(CASE WHEN accepted = true THEN 1 ELSE 0 END) AS accepted_outputs,\n  100.0 * SUM(CASE WHEN accepted = true THEN 1 ELSE 0 END)\n    / NULLIF(COUNT(*), 0) AS acceptance_rate_pct,\n  SUM(estimated_cost_usd) AS cost_usd,\n  SUM(CASE WHEN accepted = true THEN 1 ELSE 0 END)\n    / NULLIF(SUM(estimated_cost_usd), 0) AS accepted_outputs_per_dollar\nFROM llm_requests\nWHERE timestamp_utc >= now() - INTERVAL '30 days'\nGROUP BY feature, model\nHAVING COUNT(*) >= 50\nORDER BY accepted_outputs_per_dollar DESC;",
  "fixtureKind": "schema-example",
  "inputRows": [
    {
      "timestamp_utc": "2026-07-28T10:00:00Z",
      "feature": "feature_example_1",
      "model": "configured-model",
      "accepted": true,
      "estimated_cost_usd": 0.014
    },
    {
      "timestamp_utc": "2026-07-28T11:00:00Z",
      "feature": "feature_example_2",
      "model": "configured-model",
      "accepted": false,
      "estimated_cost_usd": 0.052
    },
    {
      "timestamp_utc": "2026-07-28T12:00:00Z",
      "feature": "feature_example_3",
      "model": "configured-model",
      "accepted": true,
      "estimated_cost_usd": 0.021
    }
  ],
  "illustrativeInputRows": [
    {
      "timestamp_utc": "2026-07-28T10:00:00Z",
      "feature": "feature_example_1",
      "model": "configured-model",
      "accepted": true,
      "estimated_cost_usd": 0.014
    },
    {
      "timestamp_utc": "2026-07-28T11:00:00Z",
      "feature": "feature_example_2",
      "model": "configured-model",
      "accepted": false,
      "estimated_cost_usd": 0.052
    },
    {
      "timestamp_utc": "2026-07-28T12:00:00Z",
      "feature": "feature_example_3",
      "model": "configured-model",
      "accepted": true,
      "estimated_cost_usd": 0.021
    }
  ],
  "expectedOutput": {
    "columns": [
      "feature",
      "model",
      "completed_outputs",
      "accepted_outputs",
      "acceptance_rate_pct",
      "cost_usd",
      "accepted_outputs_per_dollar"
    ],
    "rows": [
      {
        "feature": "support_draft",
        "model": "fast-small",
        "completed_outputs": 4200,
        "accepted_outputs": 3108,
        "acceptance_rate_pct": 74,
        "cost_usd": 63,
        "accepted_outputs_per_dollar": 49.33
      },
      {
        "feature": "document_summary",
        "model": "balanced-medium",
        "completed_outputs": 1700,
        "accepted_outputs": 1394,
        "acceptance_rate_pct": 82,
        "cost_usd": 78.2,
        "accepted_outputs_per_dollar": 17.83
      },
      {
        "feature": "research_report",
        "model": "reasoning-large",
        "completed_outputs": 510,
        "accepted_outputs": 464,
        "acceptance_rate_pct": 90.98,
        "cost_usd": 215,
        "accepted_outputs_per_dollar": 2.16
      }
    ]
  },
  "notes": [
    "The compact input rows demonstrate field names and JSON types; they are not claimed to generate the displayed aggregate by themselves.",
    "The expected output is deterministic synthetic review data for the documented output shape.",
    "Adapt time windows, thresholds, identities, and business definitions before operational use."
  ]
}