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

# AI Copilot Metrics

> API endpoints for AI copilot usage, adoption, and productivity metrics

## AI Copilot Metrics

AI Copilot metrics measure how developers interact with AI coding assistants, adoption rates, and the impact on productivity across your organization.

### Available Metrics

**Adoption & Usage**

<ParamField path="ai-adoption-rate" type="string">
  Percentage of active developers using AI tools
</ParamField>

<ParamField path="adopted-users" type="string">
  Number of users who have adopted AI tools
</ParamField>

<ParamField path="adoption-rate" type="string">
  AI tool adoption rate
</ParamField>

**Suggestions & Acceptance**

<ParamField path="suggested-lines" type="string">
  Lines of code suggested by AI
</ParamField>

<ParamField path="accepted-lines" type="string">
  Lines of code accepted from AI suggestions
</ParamField>

<ParamField path="ai-acceptance-rate" type="string">
  Percentage of AI suggestions that were accepted
</ParamField>

<ParamField path="acceptance-rate" type="string">
  AI suggestion acceptance rate
</ParamField>

<ParamField path="total-accepts" type="string">
  Total number of accepted AI suggestions
</ParamField>

<ParamField path="total-rejects" type="string">
  Total number of rejected AI suggestions
</ParamField>

**Code Volume**

<ParamField path="ai-total-loc" type="string">
  Total lines of code written with AI assistance
</ParamField>

<ParamField path="ai-percent-ai-generated-code" type="string">
  Percentage of all code that was AI-generated
</ParamField>

<ParamField path="ai-code-ratio" type="string">
  Ratio of AI-generated code to total code
</ParamField>

<ParamField path="total-lines-added" type="string">
  Total lines added with AI assistance
</ParamField>

<ParamField path="total-lines-deleted" type="string">
  Total lines deleted with AI assistance
</ParamField>

**Requests by Type**

<ParamField path="chat-requests" type="string">
  Number of AI chat requests
</ParamField>

<ParamField path="composer-requests" type="string">
  Number of AI composer requests
</ParamField>

<ParamField path="agent-requests" type="string">
  Number of AI agent requests
</ParamField>

<ParamField path="cmd-k-usages" type="string">
  Number of inline (Cmd+K) AI usages
</ParamField>

**Quality & Cost**

<ParamField path="ai-complexity-score" type="string">
  Complexity score of AI-assisted code
</ParamField>

<ParamField path="ai-pr-count" type="string">
  Number of pull requests created with AI assistance
</ParamField>

<ParamField path="ai-total-token-usage" type="string">
  Total AI token usage
</ParamField>

<ParamField path="ai-total-cost" type="string">
  Total estimated cost of AI usage
</ParamField>

**Insights**

<ParamField path="ai-favourite-model" type="string">
  Most used AI model across the organization
</ParamField>

<ParamField path="most-used-programming-language" type="string">
  Most used programming language in AI interactions
</ParamField>

## Accepted vs Suggested Lines

Retrieve both accepted and suggested lines in a single request to calculate acceptance rate over time.

<CodeGroup>
  ```bash Request theme={null}
  curl -X POST 'https://api.bilanc.co/metrics/get-multiple-metrics' \
    -H 'Authorization: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "filters": {
        "team": ["team123"],
        "start_date": "2024-01-01",
        "end_date": "2024-03-31"
      },
      "date_level": "month",
      "metrics": ["suggested-lines", "accepted-lines"],
      "date_fields": {
        "suggested-lines": "date",
        "accepted-lines": "date"
      },
      "aggregations": {
        "suggested-lines": "SUM",
        "accepted-lines": "SUM"
      }
    }'
  ```

  ```json Response theme={null}
  [
    {
      "month_date": "2024-01-01",
      "sum_suggested_lines": 4500,
      "sum_accepted_lines": 3200
    },
    {
      "month_date": "2024-02-01",
      "sum_suggested_lines": 6800,
      "sum_accepted_lines": 4900
    },
    {
      "month_date": "2024-03-01",
      "sum_suggested_lines": 8900,
      "sum_accepted_lines": 6700
    }
  ]
  ```
</CodeGroup>

## AI Adoption Rate

Track the percentage of active developers using AI tools over time.

<CodeGroup>
  ```bash Request theme={null}
  curl -X POST 'https://api.bilanc.co/metrics/ai-adoption-rate' \
    -H 'Authorization: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "filters": {
        "start_date": "2024-01-01",
        "end_date": "2024-03-31"
      },
      "group_by": ["team_name"],
      "date_level": "month",
      "date_field": "date"
    }'
  ```

  ```json Response theme={null}
  [
    {
      "month_date": "2024-01-01",
      "team_name": "Frontend",
      "ai_adoption_rate": 0.75
    },
    {
      "month_date": "2024-01-01",
      "team_name": "Backend",
      "ai_adoption_rate": 0.60
    },
    {
      "month_date": "2024-02-01",
      "team_name": "Frontend",
      "ai_adoption_rate": 0.82
    },
    {
      "month_date": "2024-02-01",
      "team_name": "Backend",
      "ai_adoption_rate": 0.71
    }
  ]
  ```
</CodeGroup>

## Most Used AI Model

Retrieve the most commonly used AI model across the organization.

<CodeGroup>
  ```bash Request theme={null}
  curl -X POST 'https://api.bilanc.co/metrics/ai-favourite-model' \
    -H 'Authorization: YOUR_API_KEY' \
    -H 'Content-Type: application/json' \
    -d '{
      "filters": {
        "start_date": "2024-01-01",
        "end_date": "2024-03-31"
      },
      "group_by": ["team_name"],
      "date_field": "date"
    }'
  ```

  ```json Response theme={null}
  [
    {
      "team_name": "Frontend",
      "ai_favourite_model": "claude-3-5-sonnet"
    },
    {
      "team_name": "Backend",
      "ai_favourite_model": "gpt-4o"
    }
  ]
  ```
</CodeGroup>

## Parameter Notes

<ResponseField name="date_field" type="string">
  For AI copilot metrics the available date field is:

  * `date`: The date of the AI interaction
</ResponseField>

<ResponseField name="aggregation" type="string">
  * For line counts and totals: `SUM`
  * For rate metrics (`ai-adoption-rate`, `ai-acceptance-rate`, `acceptance-rate`, `adoption-rate`, `ai-code-ratio`, `ai-percent-ai-generated-code`): no aggregation needed — values are pre-computed percentages/ratios
  * For cost and token usage: `SUM` or `AVG`
</ResponseField>

<ResponseField name="filters" type="object">
  Applicable filters for AI copilot metrics:

  * `ai_copilot_sources`: Filter by AI copilot source name (e.g. `cursor`, `github-copilot`)
  * `team`: Filter by team IDs
  * `squad_ids`: Filter by squad IDs
  * `squad_levels`: Filter by squad hierarchy level
  * `manager_ids`: Filter by manager user IDs
  * `departments`: Filter by department names
  * `member`: Filter by user merged user IDs
  * `locations`: Filter by employee location
  * `levels`: Filter by employee level
</ResponseField>

## Common Use Cases

* **Adoption Monitoring**: Track AI tool adoption across teams over time
* **ROI Analysis**: Compare `ai-total-cost` against productivity gains
* **Acceptance Quality**: Monitor `acceptance-rate` to gauge suggestion relevance
* **Language Insights**: Use `most-used-programming-language` to focus AI training
* **Usage Breakdown**: Compare `chat-requests`, `composer-requests`, and `agent-requests` to understand how developers use AI
