Installation
Requires Node.js 14+. The SDK is written in TypeScript and ships with full type definitions. It has zero runtime dependencies — using only the built-in
http and https modules.Quick Start
TypeScript
JavaScript (CommonJS)
Authentication
The SDK requires an API key. You can provide it in two ways:- Direct Option
- Environment Variable
AuthenticationError is thrown immediately.
Client Reference
new PromptInspector(options?)
Creates a new SDK client instance.
string | undefined
default:"undefined"
API key for authentication. Falls back to the
PMTINSP_API_KEY environment variable if not provided.string | undefined
default:"https://promptinspector.io"
Base URL of the Prompt Inspector API server.
number | undefined
default:"30"
Default request timeout in seconds.
client.detect(text, options?)
Sends text to the detection API and returns a DetectionResult.
string
required
The text to analyze. Must be a non-empty string.
number | undefined
default:"undefined"
Per-request timeout override in seconds.
Promise<DetectionResult>
client.close()
Marks the client as closed. After calling this method, any subsequent calls to detect() will throw an error.
DetectionResult
Thedetect() method resolves to an object with these properties:
TypeScript Types
The SDK exports the following types:PromptInspectorOptions
DetectOptions
DetectionResult
Error Handling
All errors inherit fromPromptInspectorError:
Full Example
Express.js Middleware
Graceful Shutdown
View on GitHub
Find the SDK source code, report issues, and contribute.

