@centure/node-sdk package.
Client Methods
scanText
Scans text content for prompt injection attempts.text(string) - The text content to scan
Promise<ScanResponse>
Throws:
BadRequestError- Invalid request formatUnauthorizedError- Invalid or missing API keyMissingApiKeyError- No API key provided
scanImage
Scans images for text-based prompt injection attempts.image(string | Buffer) - Base64-encoded image string or Buffer object
Promise<ScanResponse>
Throws:
BadRequestError- Invalid image formatUnauthorizedError- Invalid or missing API keyPayloadTooLargeError- Image exceeds size limitMissingApiKeyError- No API key provided
Response Types
ScanResponse
The response object returned by all scan methods.Indicates whether the content is safe.
false means prompt injection was detected.Array of detected threat categories with confidence levels. Empty array when
is_safe is true.Unique identifier for this scan request. Use this for tracking and support inquiries.
The ID of the API key used for this request.
Number of request units consumed by this scan operation.
The service tier associated with your API key.
DetectedCategory
Represents a detected threat with its confidence level.The type of threat detected. See Threat Categories below.
Confidence level of the detection:
"low", "medium", or "high".Threat Categories
The SDK detects the following threat categories. Each corresponds to a specific attack pattern.See the Risk Classifications page for detailed explanations of each category.
| Category | Description |
|---|---|
behavioral_override_low | Attempts to override system behavior or instructions |
role_manipulation | Attempts to manipulate the AI’s role or identity |
context_injection | Injection of malicious context or instructions |
instruction_hierarchy_manipulation | Manipulation of instruction priority or hierarchy |
output_manipulation | Attempts to control output format or content |
data_exfiltration | Attempts to extract sensitive data |
external_actions | Attempts to trigger external actions or API calls |
safety_bypass | Attempts to bypass safety measures or content filters |
Confidence Levels
Confidence levels indicate the detection certainty:high- Strong indicators of prompt injection. Block these requests.medium- Moderate indicators. Consider additional validation or monitoring.low- Weak indicators. May require context-specific handling.
Block all
high confidence detections in production. Apply additional scrutiny to medium confidence results based on your risk tolerance.Service Tiers
Service tiers determine rate limits and features available to your API key:Client Configuration
Constructor Options
Your Centure API key. If not provided, the client reads from the
CENTURE_API_KEY environment variable.The base URL for the Centure API. Override this for testing or custom deployments.
Custom fetch implementation. Use this to provide a different fetch function (e.g.,
node-fetch for older Node.js versions).Additional options passed to all fetch requests. Use this to set custom headers, timeouts, or other request parameters.
Configuration Examples
Custom timeout:Error Classes
The SDK provides specific error classes for different failure scenarios:| Error Class | HTTP Status | Description |
|---|---|---|
MissingApiKeyError | N/A | No API key provided in options or environment |
UnauthorizedError | 401 | Invalid or expired API key |
BadRequestError | 400 | Invalid request format or parameters |
PayloadTooLargeError | 413 | Image exceeds maximum size limit |

