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

# Debug Endpoint

> Inspect routing decisions without making a provider call or consuming credits.

# Debug Endpoint

The debug endpoint runs the routing classifier on a prompt and returns the full decision - without making any provider call or consuming any credits.

Use it to understand why a prompt was routed to a particular tier, or to verify that your tier floor and ceiling settings are working as expected.

**Endpoint:**

```
POST https://api.routor.ai/v1/routing/debug
```

***

## Request

```json theme={null}
{
  "prompt": "Prove that the square root of 2 is irrational.",
  "system_prompt": "You are a math tutor.",
  "max_output_tokens": 1024,
  "tools": [],
  "messages": [{ "role": "user", "content": "Prove that the square root of 2 is irrational." }]
}
```

| Field               | Required | Description                                                                                                                                 |
| ------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `prompt`            | Yes      | The user message to classify                                                                                                                |
| `system_prompt`     | No       | System prompt - affects context length estimate                                                                                             |
| `max_output_tokens` | No       | Expected output length - affects cost estimate                                                                                              |
| `tools`             | No       | Tool definitions - used to detect the tool-calling scenario and rerank models by function-calling accuracy                                  |
| `messages`          | No       | Full conversation. Defaults to a single user message built from `prompt`. Used for history-floor detection and tool-scenario classification |
| `profile`           | No       | Routing profile: `auto` (default)                                                                                                           |

***

## Response

```json theme={null}
{
  "decision": {
    "model":          "deepseek/deepseek-v4-pro",
    "tier":           "COMPLEX",
    "category":       "math",
    "confidence":     0.91,
    "method":         "rules",
    "reasoning":      "rules: score=0.340, confidence=0.91, signals=[reasoning (proof, theorem), ...]",
    "costEstimate":   0.0042,
    "baselineCost":   0.0280,
    "savings":        0.85,
    "filteredChain": [
      "deepseek/deepseek-v4-pro",
      "openai/gpt-5.5",
      "anthropic/claude-opus-4.8"
    ],
    "profile":        "auto",
    "historyFloor":   null,
    "toolScenario":   null,
    "bfclScore":      null
  }
}
```

***

## Response Fields

All fields are nested under a `decision` object.

| Field           | Description                                                                                                                                |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `tier`          | Assigned tier: NANO, SIMPLE, LIGHT, STANDARD, or COMPLEX                                                                                   |
| `confidence`    | How confident the classifier is, from 0 to 1                                                                                               |
| `model`         | The model that would be selected for this request                                                                                          |
| `category`      | Detected task category (e.g. `math`, `coding_general_debugging_refactoring_testing`, `simple_qa`)                                          |
| `method`        | How the tier was decided: `rules` (rule-based classifier)                                                                                  |
| `reasoning`     | Human-readable explanation of the decision, including score, signals, and any applied overrides                                            |
| `costEstimate`  | Estimated cost in USD for this request on the selected model (including the routing markup)                                                |
| `baselineCost`  | What this would cost on the baseline model (Claude Opus 4.8)                                                                               |
| `savings`       | Fraction saved vs baseline, from 0 to 1                                                                                                    |
| `filteredChain` | Ordered list of models that would be tried - primary first, fallbacks after                                                                |
| `profile`       | Routing profile used: `auto`, `tier`, or `direct`                                                                                          |
| `historyFloor`  | Tier floor applied from conversation history, if any (null when not applicable)                                                            |
| `toolScenario`  | Detected tool-calling scenario (`single`, `parallel`, `multi_turn`, `web_search`, `memory`, `optional`), or null when no tools are present |
| `bfclScore`     | The selected model's BFCL score for the detected tool scenario, or null                                                                    |

***

## Example: Debugging a Misclassification

If a prompt is routing to an unexpected tier, call the debug endpoint to inspect the decision:

```bash theme={null}
curl https://api.routor.ai/v1/routing/debug \
  -H "Authorization: Bearer sk-routor-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "What is a callback function?",
    "max_output_tokens": 512
  }'
```

Response:

```json theme={null}
{
  "decision": {
    "model":          "moonshot/kimi-k2.6",
    "tier":           "LIGHT",
    "category":       "coding_general_debugging_refactoring_testing",
    "confidence":     0.78,
    "method":         "rules",
    "reasoning":      "rules: score=0.120, confidence=0.78, signals=[code (function), ...]",
    "costEstimate":   0.0003,
    "baselineCost":   0.0062,
    "savings":        0.95,
    "filteredChain": [
      "moonshot/kimi-k2.6",
      "google/gemini-3.5-flash",
      "deepseek/deepseek-v4-flash"
    ],
    "profile":        "auto",
    "historyFloor":   null,
    "toolScenario":   null,
    "bfclScore":      null
  }
}
```

If the tier feels wrong for your use case, you can override it with a `routor_tier_floor` on the request or save a [Routing Profile](../playground/create-profile.md) with the right constraints.

***

## Authentication

Same as all other endpoints:

```
Authorization: Bearer sk-routor-YOUR_KEY_HERE
```
