> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cekura.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Metrics

> Define how runs and calls are scored

export const CopyPageButton = () => {
  if (typeof window !== 'undefined') {
    setTimeout(function () {
      if (document.getElementById('ck-tools')) return;
      var anchor = document.getElementById('content-area') || document.querySelector('.mdx-content');
      if (!anchor) return;
      if (!document.getElementById('ck-style')) {
        var s = document.createElement('style');
        s.id = 'ck-style';
        s.textContent = '#ck-tools{position:absolute;top:6px;right:0;z-index:100;font-family:inherit;}' + '.ck-row{display:inline-flex;align-items:stretch;border:1px solid rgba(0,0,0,0.15);border-radius:8px;overflow:hidden;background:#fff;}' + ':root.dark .ck-row{background:rgba(255,255,255,0.06);border-color:rgba(255,255,255,0.12);}' + '.ck-btn{padding:5px 12px;border:none;background:none;cursor:pointer;font-size:13px;font-weight:500;font-family:inherit;color:#374151;}' + ':root.dark .ck-btn{color:#d1d5db;}' + '.ck-btn:hover{background:rgba(0,0,0,0.04);}' + ':root.dark .ck-btn:hover{background:rgba(255,255,255,0.06);}' + '.ck-chevron{padding:5px 8px;border:none;background:none;cursor:pointer;font-size:14px;font-family:inherit;color:#374151;}' + ':root.dark .ck-chevron{color:#d1d5db;}' + '.ck-chevron:hover{background:rgba(0,0,0,0.04);}' + ':root.dark .ck-chevron:hover{background:rgba(255,255,255,0.06);}' + '.ck-divider{width:1px;background:rgba(0,0,0,0.12);flex-shrink:0;}' + ':root.dark .ck-divider{background:rgba(255,255,255,0.12);}' + '.ck-dd{position:absolute;top:calc(100% + 4px);right:0;min-width:180px;background:#fff;border:1px solid rgba(0,0,0,0.12);border-radius:8px;box-shadow:0 4px 12px rgba(0,0,0,0.1);padding:4px;display:none;z-index:200;}' + ':root.dark .ck-dd{background:#1f2937;border-color:rgba(255,255,255,0.1);box-shadow:0 4px 16px rgba(0,0,0,0.35);}' + '.ck-item{display:block;width:100%;padding:7px 12px;border:none;background:none;border-radius:6px;cursor:pointer;font-size:13px;font-family:inherit;text-align:left;color:#374151;}' + ':root.dark .ck-item{color:#d1d5db;}' + '.ck-item:hover{background:rgba(0,0,0,0.05);}' + ':root.dark .ck-item:hover{background:rgba(255,255,255,0.07);}';
        document.head.appendChild(s);
      }
      var wrap = document.createElement('div');
      wrap.id = 'ck-tools';
      var row = document.createElement('div');
      row.className = 'ck-row';
      var mainBtn = document.createElement('button');
      mainBtn.className = 'ck-btn';
      mainBtn.textContent = 'Copy page';
      var divider = document.createElement('span');
      divider.className = 'ck-divider';
      var chevron = document.createElement('button');
      chevron.className = 'ck-chevron';
      chevron.textContent = '▾';
      var dd = document.createElement('div');
      dd.className = 'ck-dd';
      function closeDD() {
        dd.style.display = 'none';
      }
      function openDD() {
        dd.style.display = 'block';
      }
      chevron.onclick = function (e) {
        e.stopPropagation();
        if (dd.style.display === 'block') {
          closeDD();
        } else {
          openDD();
        }
      };
      document.addEventListener('click', function (e) {
        if (!e.target.closest('#ck-tools')) {
          closeDD();
        }
      });
      document.addEventListener('keydown', function (e) {
        if (e.key === 'Escape') {
          closeDD();
        }
      });
      function makeItem(label, fn) {
        var b = document.createElement('button');
        b.className = 'ck-item';
        b.textContent = label;
        b.onclick = function () {
          fn();
          closeDD();
        };
        return b;
      }
      function getMarkdown() {
        var walk = function (node) {
          if (!node) return '';
          if (node.nodeType === 3) return node.textContent || '';
          if (node.nodeType !== 1) return '';
          var tag = node.tagName.toLowerCase();
          var skip = ['script', 'style', 'svg', 'noscript', 'button', 'iframe'];
          if (skip.indexOf(tag) !== -1) return '';
          if (node.id === 'ck-tools') return '';
          var ch = Array.from(node.childNodes).map(walk).join('');
          if (tag === 'h1') return '\n# ' + ch.trim() + '\n\n';
          if (tag === 'h2') return '\n## ' + ch.trim() + '\n\n';
          if (tag === 'h3') return '\n### ' + ch.trim() + '\n\n';
          if (tag === 'p') return '\n' + ch.trim() + '\n\n';
          if (tag === 'pre') return '\n```\n' + node.textContent.trim() + '\n```\n\n';
          if (tag === 'li') return '- ' + ch.trim() + '\n';
          if (tag === 'code') return '`' + ch.trim() + '`';
          return ch;
        };
        var content = document.querySelector('.mdx-content') || document.getElementById('content-area') || document.body;
        return walk(content).replace(/\n\n\n+/g, '\n\n').trim();
      }
      function copyMd() {
        var md = getMarkdown();
        navigator.clipboard.writeText(md).then(function () {
          mainBtn.textContent = 'Copied!';
          setTimeout(function () {
            mainBtn.textContent = 'Copy page';
          }, 2000);
        });
      }
      function viewMd() {
        var md = getMarkdown();
        var safe = md.split('&').join('&amp;').split('<').join('&lt;').split('>').join('&gt;');
        var html = '<!DOCTYPE html><html><head><meta charset="utf-8"><style>body{font-family:monospace;max-width:860px;margin:40px auto;padding:0 24px;line-height:1.7;white-space:pre-wrap;word-wrap:break-word}</style></head><body>' + safe + '</body></html>';
        window.open(URL.createObjectURL(new Blob([html], {
          type: 'text/html'
        })), '_blank');
      }
      function openClaude() {
        var prompt = 'Can you read this Cekura docs page ' + window.location.href + ' so I can ask you questions?';
        window.open('https://claude.ai/new?q=' + encodeURIComponent(prompt), '_blank');
      }
      mainBtn.onclick = copyMd;
      dd.appendChild(makeItem('Copy page', copyMd));
      dd.appendChild(makeItem('View as Markdown', viewMd));
      dd.appendChild(makeItem('Open in Claude', openClaude));
      row.appendChild(mainBtn);
      row.appendChild(divider);
      row.appendChild(chevron);
      wrap.appendChild(row);
      wrap.appendChild(dd);
      anchor.style.position = 'relative';
      anchor.insertBefore(wrap, anchor.firstChild);
    }, 50);
  }
  return null;
};

<CopyPageButton />

<Note>
  Setup steps and authentication are in the [Overview](/cli-sdk/overview). This page covers metric authoring and management.
</Note>

A **metric** scores a run or production call. Cekura supports three flavors:

* **Predefined** — platform-managed metrics like sentiment, interruption count, latency.
* **LLM judge** — you write a prompt; an LLM scores the transcript.
* **Custom code** — Python that runs against the call payload.

## Browse predefined metrics

These are read-only and shared across the platform.

<Tabs>
  <Tab title="CLI">
    ```bash theme={null}
    cekura predefined-metrics list
    ```
  </Tab>

  <Tab title="SDK">
    ```python theme={null}
    catalog = client.predefined_metrics.list()
    for m in catalog:
        print(m["slug"], m["name"], m["eval_type"])
    ```
  </Tab>
</Tabs>

## Create a metric

<Tabs>
  <Tab title="CLI">
    Prepare `metric.json`:

    ```json theme={null}
    {
      "agents": [123],
      "name": "Booking confirmed",
      "type": "llm_judge",
      "eval_type": "boolean",
      "prompt": "Did the agent confirm a booking and read back the date and time?"
    }
    ```

    Apply:

    ```bash theme={null}
    cekura metrics create --from-file metric.json
    ```
  </Tab>

  <Tab title="SDK">
    ```python theme={null}
    from cekura import Cekura

    client = Cekura()

    # LLM-judge metric
    metric = client.metrics.create(
        agents=[123],
        name="Booking confirmed",
        type="llm_judge",
        eval_type="boolean",
        prompt="Did the agent confirm a booking and read back the date and time?",
    )

    # Python (custom code) metric
    client.metrics.create(
        agents=[123],
        name="Hold duration > 30s",
        type="python",
        eval_type="boolean",
        code="""
    def evaluate(call):
    return any(seg['duration'] > 30 for seg in call.get('hold_segments', []))
    """,
    )
    ```
  </Tab>
</Tabs>

## List, update, delete

<Tabs>
  <Tab title="CLI">
    ```bash theme={null}
    cekura metrics list --agent-id 123
    cekura metrics get 55
    cekura metrics update 55 --from-file patch.json
    cekura metrics delete 55
    ```
  </Tab>

  <Tab title="SDK">
    ```python theme={null}
    client.metrics.list(agent_id=123)
    client.metrics.get(metric_id=55)
    client.metrics.update(metric_id=55, prompt="Refined judge prompt")
    client.metrics.delete(metric_id=55)
    ```
  </Tab>
</Tabs>

## Bulk operations

Manage many metrics in one call.

<Tabs>
  <Tab title="CLI">
    ```bash theme={null}
    # Create several at once
    cekura metrics bulk-create --from-file metrics.json

    # Bulk-attach metrics across agents
    cekura metrics bulk-manage-agents \
      --metric-ids 55,56 \
      --agents-to-add 123,124

    # Toggle active state on many metrics
    cekura metrics bulk-toggle-settings --metric-ids 55,56 --is-active true
    ```
  </Tab>

  <Tab title="SDK">
    ```python theme={null}
    # Create several at once
    client.metrics.bulk_create(metrics=[
        {"name": "Greeting present", "type": "llm_judge", "prompt": "...", "agents": [123]},
        {"name": "Closing present",  "type": "llm_judge", "prompt": "...", "agents": [123]},
    ])

    # Attach / detach metrics across agents
    client.metrics.bulk_manage_agents(
        metric_ids=[55, 56],
        agents_to_add=[123, 124],
        agents_to_remove=[],
    )

    # Toggle settings on many metrics at once
    client.metrics.bulk_toggle_settings(
        metric_ids=[55, 56],
        is_active=True,
    )
    ```
  </Tab>
</Tabs>

## Generate metrics with AI

Stuck on what to measure? Cekura can propose metrics from your agent's scenarios.

<Tabs>
  <Tab title="CLI">
    ```bash theme={null}
    cekura metrics generate --agent-id 123 --count 10
    cekura metrics generate-progress --progress-id <id>
    ```
  </Tab>

  <Tab title="SDK">
    ```python theme={null}
    job = client.metrics.generate(agent_id=123, count=10)
    client.metrics.generate_progress(progress_id=job["progress_id"])
    ```
  </Tab>
</Tabs>

## Critical metric scenarios & reviews

Two advanced workflows:

* **Critical metric scenarios** — scenarios flagged because their metric output drifted. Useful for triage.
* **Metric reviews (Labs pipeline)** — kick off feedback processing on metric judgments and watch progress.

<Tabs>
  <Tab title="CLI">
    ```bash theme={null}
    # Critical metric scenarios
    cekura critical-metric-scenarios list --metric-id 55
    cekura critical-metric-scenarios update 42 --json '{"is_resolved": true}'

    # Metric reviews
    cekura metric-reviews process-feedbacks --metric-id 55
    cekura metric-reviews progress --job-id <id>
    ```
  </Tab>

  <Tab title="SDK">
    ```python theme={null}
    # Critical metric scenarios
    client.critical_metric_scenarios.list(metric_id=55)
    client.critical_metric_scenarios.update(id=42, is_resolved=True)

    # Metric reviews
    job = client.metric_reviews.process_feedbacks(metric_id=55)
    client.metric_reviews.process_feedbacks_progress(job_id=job["job_id"])
    ```
  </Tab>
</Tabs>

## See also

<CardGroup cols={2}>
  <Card title="Runs & Results" icon="play" href="/cli-sdk/runs">
    Where metric scores show up after a run.
  </Card>

  <Card title="Calls" icon="phone" href="/cli-sdk/calls">
    Run metrics against production calls, not just simulations.
  </Card>

  <Card title="Metric concepts" icon="database" href="/documentation/key-concepts/metrics/overview">
    LLM judge, Python, rubric, sampling — when to use what.
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference">
    Full field reference for metric payloads.
  </Card>
</CardGroup>
