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

# Estimate a task's cost

> Get the range a task of one workflow usually costs, learned from your own finished tasks.

Before a task runs, ask what a task of its workflow usually costs. The answer is a range, the 50th, 90th and 99th percentile, learned from your organisation's own finished tasks of that workflow in the last 30 days. [Transactions](https://docs.navige.ai/concepts/transactions.md#what-a-task-will-cost-before-it-runs) explains where the figures come from.

> [!NOTE]
>
> The key field is filled with a public demo key, so you can send a request without signing up. It reaches a shared demo workspace that resets every night, so do not send anything private. To call your own workspace, replace it with your key from Agents in the console.

Which tasks count:

* Only tasks that completed, started in the last 30 days, and are not tasks Navige closed for being idle. At most the newest 2,000 are read.
* Only API spend. Model calls made on a subscription plan are not part of a task's cost here.
* A task with a step Navige could not price is left out and counted in `leftOut.unpricedTasks`. A task that cost nothing in API spend is left out and counted in `leftOut.zeroCostTasks`. Neither is read as cheap.

The range is wide while there are few tasks and narrows as more arrive. With fewer than two priced tasks there is no range, and `expected` is `null`, not zero. An answer can be up to five minutes old.

## Status codes

`200` with the fields described below. A blank workflow key gets `400` with `{ "error": "…" }`. If Navige cannot read the tasks, the answer is `503` with `{ "error": "the estimate could not be read" }`. A key that is missing or not valid gets `401`, and an agent that is inactive or expired gets `403`.

All money is in micro-USD: `1000000` is one US dollar.

```bash cURL theme={null}
curl https://api.navige.ai/v1/workflows/support.ticket.triage/estimate \
  -H "x-navige-key: $NAVIGE_KEY"
```

```powershell PowerShell theme={null}
$workflowKey = [uri]::EscapeDataString("support.ticket.triage")
Invoke-RestMethod -Uri "https://api.navige.ai/v1/workflows/$workflowKey/estimate" `
  -Headers @{ "x-navige-key" = $env:NAVIGE_KEY }
```

```python Python theme={null}
import os, requests
from urllib.parse import quote

workflow_key = quote("support.ticket.triage", safe="")
r = requests.get(
    f"https://api.navige.ai/v1/workflows/{workflow_key}/estimate",
    headers={"x-navige-key": os.environ["NAVIGE_KEY"]},
)
print(r.json()["expected"])
```

```json Range theme={null}
{
  "workflowKey": "support.ticket.triage",
  "basedOnTasks": 48,
  "windowDays": 30,
  "expected": { "p50MicroUsd": 41200, "p90MicroUsd": 118000, "p99MicroUsd": 296000 },
  "meanSteps": 6.4,
  "leftOut": { "unpricedTasks": 3, "zeroCostTasks": 5 },
  "note": "learned from 48 priced tasks in the last 30 days"
}
```

```json Few tasks theme={null}
{
  "workflowKey": "support.ticket.triage",
  "basedOnTasks": 6,
  "windowDays": 30,
  "expected": { "p50MicroUsd": 39800, "p90MicroUsd": 162000, "p99MicroUsd": 611000 },
  "meanSteps": 5.8,
  "leftOut": { "unpricedTasks": 0, "zeroCostTasks": 1 },
  "note": "learned from 6 priced tasks; the range is wide on purpose and narrows as tasks arrive"
}
```

```json No range yet theme={null}
{
  "workflowKey": "support.ticket.triage",
  "basedOnTasks": 1,
  "windowDays": 30,
  "expected": null,
  "meanSteps": 7,
  "leftOut": { "unpricedTasks": 0, "zeroCostTasks": 0 },
  "note": "one priced task so far; a range needs two"
}
```

```json Unavailable theme={null}
{ "error": "the estimate could not be read" }
```


## OpenAPI

````yaml GET /v1/workflows/{key}/estimate
openapi: 3.1.0
info:
  title: Navige API
  version: 1.0.0
  description: >-
    The gateway's public API: ask for a decision before an agent acts, report
    usage and outcomes, and read what a task usually costs.
servers:
  - url: https://api.navige.ai
security:
  - navigeKey: []
  - bearer: []
tags:
  - name: Decisions
    description: Ask before an agent acts, and read what applies to your calls.
  - name: Usage and tasks
    description: Report what happened, and read what a task costs.
paths:
  /v1/workflows/{key}/estimate:
    get:
      tags:
        - Usage and tasks
      summary: Estimate a task's cost
      description: >-
        The range a task of one workflow usually costs, learned from your
        organisation's finished tasks in the last 30 days. Money is in
        micro-USD: 1000000 is one US dollar. An answer can be up to five minutes
        old.
      operationId: estimateTaskCost
      parameters:
        - schema:
            type: string
            maxLength: 200
            x-default: support.ticket.triage
          example: support.ticket.triage
          in: path
          name: key
          required: true
          description: >-
            The workflow key, as you send it in `x-navige-workflow` or
            `transaction.workflowKey`. URL-encode it.
      responses:
        '200':
          description: >-
            The estimate. `expected` is null, not zero, until there are two
            priced tasks.
          content:
            application/json:
              schema:
                type: object
                required:
                  - workflowKey
                  - basedOnTasks
                  - windowDays
                  - expected
                  - meanSteps
                  - leftOut
                  - note
                additionalProperties: false
                properties:
                  workflowKey:
                    type: string
                  basedOnTasks:
                    type: integer
                    description: How many priced tasks the range is learned from.
                  windowDays:
                    type: integer
                    enum:
                      - 30
                  expected:
                    oneOf:
                      - type: object
                        required:
                          - p50MicroUsd
                          - p90MicroUsd
                          - p99MicroUsd
                        additionalProperties: false
                        properties:
                          p50MicroUsd:
                            type: integer
                            description: Half of tasks are expected to cost less than this.
                          p90MicroUsd:
                            type: integer
                            description: >-
                              Nine in ten tasks are expected to cost less than
                              this.
                          p99MicroUsd:
                            type: integer
                            description: >-
                              Ninety-nine in a hundred tasks are expected to
                              cost less than this.
                      - type: 'null'
                  meanSteps:
                    type:
                      - number
                      - 'null'
                    description: >-
                      Mean model and tool steps per priced task, to one decimal
                      place.
                  leftOut:
                    type: object
                    required:
                      - unpricedTasks
                      - zeroCostTasks
                    additionalProperties: false
                    properties:
                      unpricedTasks:
                        type: integer
                        description: Tasks with a step Navige could not price.
                      zeroCostTasks:
                        type: integer
                        description: Tasks that cost nothing in API spend.
                  note:
                    type: string
                    description: The basis of the answer in words.
        '400':
          description: A blank workflow key.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                additionalProperties: false
                properties:
                  error:
                    type: string
                    description: What was wrong, in words.
        '401':
          description: The key is missing (`missing`) or not valid (`invalid_key`).
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                additionalProperties: false
                properties:
                  error:
                    type: string
                    description: What was wrong, in words.
        '403':
          description: >-
            The key's agent is inactive (`agent_inactive`) or expired
            (`agent_expired`).
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                additionalProperties: false
                properties:
                  error:
                    type: string
                    description: What was wrong, in words.
        '503':
          description: Navige could not read the tasks.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                additionalProperties: false
                properties:
                  error:
                    type: string
                    description: What was wrong, in words.
components:
  securitySchemes:
    navigeKey:
      type: apiKey
      in: header
      name: x-navige-key
      description: >-
        Your agent's Navige key, from Agents in the console. The docs fill in a
        public demo key that reaches a shared demo workspace, reset every night;
        paste your own to call your workspace.
      x-default: nv_docs_demo_nuJM-1NFjNqDKAeGoZ5-QaAfFAdVXv79
    bearer:
      type: http
      scheme: bearer
      description: >-
        The same key as `Authorization: Bearer <key>`. Used only when
        `x-navige-key` is absent.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.