@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.boolean
required
Indicates whether the content is safe.
false means prompt injection was detected.DetectedCategory[]
required
Array of detected threat categories with confidence levels. Empty array when
is_safe is true.string
required
Unique identifier for this scan request. Use this for tracking and support inquiries.
string
required
The ID of the API key used for this request.
number
required
Number of request units consumed by this scan operation.
number
required
Number of request units billed for this scan. May differ from
request_units when discounts apply.ServiceTier
required
The service tier associated with your API key.
DetectedCategory
Represents a detected threat with its confidence level.ThreatCategory
required
The type of threat detected. See Threat Categories below.
ConfidenceLevel
required
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.
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.
Service Tiers
Service tiers determine rate limits and features available to your API key:Client Configuration
Constructor Options
string
Your Centure API key. If not provided, the client reads from the
CENTURE_API_KEY environment variable.string
default:"https://api.centure.ai"
The base URL for the Centure API. Override this for testing or custom deployments.
typeof fetch
Custom fetch implementation. Use this to provide a different fetch function (e.g.,
node-fetch for older Node.js versions).RequestInit
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 handling pattern:
TypeScript Support
The SDK includes full TypeScript definitions. All types are exported for use in your application:Next Steps
Quickstart
Return to the quickstart guide for installation and basic usage
MCP Integration
Secure Model Context Protocol applications with the SDK

