/rampart/classifyClassify Content
Classifies the submitted content and returns its classification, a risk score and a confidence (both in basis points, 0 to 10000), any categories, and the classifier's calibration version.
The classification (clear, suspicious or malicious) is a risk signal for your own decision: malicious is not an instruction to block, and suspicious is not a reason to block automatically.
Weigh it with what you know about the request, for example route it for review or ask the user to confirm.
Body: input (an object, required) and an optional label (1 to 128 characters) naming the context.
The response also carries a signed classificationReceipt: a compact JWS with the protected-header typ k9o.rampart.classify.v1, signed with EdDSA.
It binds the SHA-256 of the input's canonical JSON (RFC 8785), the result, the project, the calibration version and windows, the number of windows scored.
Verify it against the key whose kid the receipt names, published at GET /rampart/jwks.
The receipt is advisory: a record of what the classifier answered, not an authorization.
Long input is never truncated: it is scored in overlapping windows of up to 512 tokens (128 tokens of overlap), and the result is the window with the highest risk.
Input that needs more than 16 windows (about 6,000 tokens) answers 413 K9O_RAMPART_INPUT_TOO_LONG with no classification.
If the classifier is unreachable or returns an unusable result for any window, the request fails closed with 503 K9O_RAMPART_CLASSIFIER_UNAVAILABLE; no classification is invented, and no partial result is returned.
Requires membership in the project; an organization-level role alone does not grant access.
| projectSlug * | path | The project's slug: the path segment after It is unique within the org. |
| input * | object | The content to classify, as a JSON object. Rampart scores it for prompt injection: text written to make a model ignore its instructions. Send anything you want checked in one object: a prompt, a tool call's arguments, a retrieved document, an incoming email, or a prompt together with the content it pulled in. To classify plain text, send Rules:
How it is read: the object is flattened to one Keys are sorted at every level, and keys are read as well as values, because a key can carry an injection too. Each array item is its own line under the array's key. A nested object puts its key on its own line, then its members. Numbers, booleans and null appear as their JSON literal. Long input is scored in overlapping 512-token windows, and the highest-scoring window decides. An empty object is |
| label | string | A short label naming where the content came from, such as a tool name. It is not scored. Default |
| HTTP | K9O Code | Description |
|---|---|---|
| 200 | Success | |
| 400 | K9O_INVALID_FIELD_VALUE | The request body failed validation (input must be an object; optional label 1-128 chars). |
| 401 | K9O_UNAUTHENTICATED | The caller is not signed in; authenticate before requesting a classification. |
| 403 | K9O_ACCESS_DENIED | The caller is not a member of this project. Classification is a project data surface: an organization-level role alone does not grant access. |
| 413 | K9O_RAMPART_INPUT_TOO_LONG | The input needs more than 16 windows of 512 tokens (about 6,000 tokens), or the classifier refused it as too long (reason rampart_input_too_long). No classification is made; send a shorter input. |
| 503 | K9O_RAMPART_CLASSIFIER_UNAVAILABLE | The Rampart classifier could not be reached or returned an unusable result. The request fails closed and never returns an invented classification; retry later. |
| data * | object | The classifier's verdict on the content, with its signed receipt. |
| classification * | "clear" | "suspicious" | "malicious" | The verdict on the riskiest window. It is advisory: Rampart blocks nothing, and your code decides what to do with the content. |
| riskScore * | integer | The likelihood that the content is a prompt injection, in basis points (0 to 10000, where 10000 is certain). |
| confidence * | integer | How sure the classifier is of the verdict it gave, in basis points (0 to 10000). |
| categories * | string[] | Labels for the kind of risk found. The current classifier only distinguishes injection from safe, so this is empty. |
| calibrationVersion * | string | The version of the score thresholds that produced the verdict. It is signed into the receipt. |
| projectId * | string | The project the receipt is bound to ( Verifying the receipt compares this with its signed claim. |
| classificationReceipt * | string | A signed record of this verdict: a compact EdDSA JWS with It carries the SHA-256 of the canonical input, the verdict, the scores, the project, the calibration version and how many windows were scored. Verify it against the keys at It is a record, not an authorization. |
| meta * | any |
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.rampart.classify({})Showing example in TypeScript
{
"label": "string"
}{
"data": {
"classification": "clear",
"riskScore": 0,
"confidence": 0,
"categories": [
"string"
],
"calibrationVersion": "string",
"projectId": "string",
"classificationReceipt": "string"
}
}