> This page is for Gateway.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.merge.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.merge.dev/_mcp/server.

# Preview Classifier

POST https://api-gateway.merge.dev/v1/classifiers/{classifier_id}/preview
Content-Type: application/json

Score up to 20 prompts with the classifier and the built-in scorer, side by
side. Nothing is stored and no model is called. Request-time scores can differ
slightly from these.

Reference: https://docs.merge.dev/merge-gateway/management-api/routing-policies/preview-routing-classifier

## Authentication

- `Authorization` header (bearer token, required) — A management key (`mgmt_...`), sent as `Authorization: Bearer <key>`. Reading /v1/routing-policies also accepts the organization's gateway API keys; writing there needs a management key.

## Request

### Path parameters

- `classifier_id` (string, required) — The classifier's `id`.

### Body (application/json)

This endpoint expects a ClassifierPreviewV1Request.

- `prompts` (list of string, required) — 1 to 20 prompts, each up to 50,000 characters.

## Response

### 200

Each prompt's scores

- `results` (list of ClassifierPromptScoreV1, required) — One entry per prompt.

## Errors

### 401 Unauthorized Error

The key is missing or invalid.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 403 Forbidden Error

The key lacks the scope this route needs, or the change is not allowed.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 404 Not Found Error

The resource does not exist in the key's organization.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 422 Unprocessable Entity Error

The request is invalid.

- `Preview_routing_classifierRequestUnprocessableEntityError`
  - HTTPValidationError: HTTPValidationError
  - ErrorResponse: ErrorResponse

## Types

### ClassifierPromptScoreV1

- `band` (enum, required) — simple below 0.4, complex above 0.6, moderate between.
  - Allowed values: `simple`, `moderate`, `complex`
- `generic_band` (enum, required, nullable) — For `generic_score`: simple below 0.4, complex above 0.6, moderate between.
  - Allowed values: `simple`, `moderate`, `complex`
- `generic_readout_score` (double, required, nullable) — The built-in difficulty readout.
- `generic_score` (double, required, nullable) — The built-in scorer's score.
- `prompt` (string, required) — The prompt, as sent.
- `readout_score` (double, required, nullable) — The classifier's difficulty readout, which readout routers use. null when it has none.
- `score` (double, required) — The classifier's complexity score, from 0 to 1. The default router routes on this.

### ErrorResponseDetail

A message, or an object with a `code` to branch on and a `message`.

- string
- ErrorDetail: ErrorDetail

### HTTPValidationError

- `detail` (list of ValidationError, optional)

### ErrorResponse

The body of an error response.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### ErrorDetail

A structured error. Some carry extra fields, like `count`.

- `code` (string, required) — A stable code to branch on, like `payment_method_required`.
- `message` (string, required) — A human-readable explanation.

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### ValidationErrorLocItems

- string
- integer

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "prompts": [
    "Send me the Q3 ARR waterfall file.",
    "Fix the ARR bridge so it ties to GAAP."
  ]
}
```

**Response**

```json
{
  "results": [
    {
      "band": "simple",
      "generic_band": "moderate",
      "generic_readout_score": 0.52,
      "generic_score": 0.46,
      "prompt": "Send me the Q3 ARR waterfall file.",
      "readout_score": 0.18,
      "score": 0.38
    },
    {
      "band": "complex",
      "generic_band": "moderate",
      "generic_readout_score": 0.9,
      "generic_score": 0.43,
      "prompt": "Fix the ARR bridge so it ties to GAAP.",
      "readout_score": 0.71,
      "score": 0.62
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview"

payload = { "prompts": ["Send me the Q3 ARR waterfall file.", "Fix the ARR bridge so it ties to GAAP."] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"prompts":["Send me the Q3 ARR waterfall file.","Fix the ARR bridge so it ties to GAAP."]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview"

	payload := strings.NewReader("{\n  \"prompts\": [\n    \"Send me the Q3 ARR waterfall file.\",\n    \"Fix the ARR bridge so it ties to GAAP.\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"prompts\": [\n    \"Send me the Q3 ARR waterfall file.\",\n    \"Fix the ARR bridge so it ties to GAAP.\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"prompts\": [\n    \"Send me the Q3 ARR waterfall file.\",\n    \"Fix the ARR bridge so it ties to GAAP.\"\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview', [
  'body' => '{
  "prompts": [
    "Send me the Q3 ARR waterfall file.",
    "Fix the ARR bridge so it ties to GAAP."
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"prompts\": [\n    \"Send me the Q3 ARR waterfall file.\",\n    \"Fix the ARR bridge so it ties to GAAP.\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["prompts": ["Send me the Q3 ARR waterfall file.", "Fix the ARR bridge so it ties to GAAP."]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway.merge.dev/v1/classifiers/classifier_id/preview")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```