Skip to main content
This page documents the types, methods, and configuration options available in the @centure/node-sdk package.

Client Methods

scanText

Scans text content for prompt injection attempts.
Parameters:
  • text (string) - The text content to scan
Returns: Promise<ScanResponse> Throws:
  • BadRequestError - Invalid request format
  • UnauthorizedError - Invalid or missing API key
  • MissingApiKeyError - No API key provided

scanImage

Scans images for text-based prompt injection attempts.
Parameters:
  • image (string | Buffer) - Base64-encoded image string or Buffer object
Returns: Promise<ScanResponse> Throws:
  • BadRequestError - Invalid image format
  • UnauthorizedError - Invalid or missing API key
  • PayloadTooLargeError - Image exceeds size limit
  • MissingApiKeyError - No API key provided

Response Types

ScanResponse

The response object returned by all scan methods.
Fields:
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.
Example:

DetectedCategory

Represents a detected threat with its confidence level.
Fields:
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.
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

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:
Custom headers:
Custom fetch implementation:
Testing environment:

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