Endpoint
Headers
| Header | Value |
|---|---|
| Authorization | Bearer YOUR_API_KEY |
| Content-Type | application/json |
Authentication
ReplaceYOUR_API_KEY with your actual API key.
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | The input text to be analyzed for potential prompt injection. |
zero_latency | boolean | No | If true, the request returns immediately, and processing is done asynchronously. Defaults to false. |
tag | string | No | A custom tag or identifier for the request, useful for tracking and categorization. Defaults to "unknown". |
chat_id | string | No | An identifier for the chat session or conversation. Useful for associating the analysis with a specific session. |
save_message | boolean | No | If true, the prompt message will be saved in the system for future reference or auditing. Defaults to false. |
notifications | boolean | No | If true, notifications will be sent based on the analysis result. Useful for alerting admins or triggering workflows. Defaults to false. |
strictness | integer | No | Controls the strictness level of detection. Accepts 1, 2, or 3. See Strictness Levels for details. Defaults to None. |
metadata | object | No | A JSON object containing additional data or context for the request. Defaults to {}. |
- All boolean parameters default to
falseif omitted. - The
strictnessparameter defaults toNoneif not provided, which uses the default detection behavior. - The
metadataparameter defaults to an empty object{}if not provided.
Strictness Levels
Thestrictness parameter controls when advanced detection is performed:
- Level 1 (
strictness = 1): Advanced detection is performed only if the initial detection indicates a potential prompt injection. - Level 2 (
strictness = 2): Advanced detection is always performed, regardless of the initial detection result. - Level 3 (
strictness = 3): Advanced detection is performed only if the initial detection does not indicate a prompt injection.
Example Request
Responses
Success Response (Synchronous)
- Status Code:
200 OK - Content-Type:
application/json - Body:
Accepted Response (Asynchronous)
- Status Code:
202 Accepted - Content-Type:
application/json - Body:
Error Responses
400 Bad Request
403 Forbidden
429 Too Many Requests
500 Internal Server Error
Response Fields Description
status(string): Indicates the status of the request ("success","pending", or"error").result(object): Contains the detection result (present in synchronous responses).is_prompt_injection(boolean):trueif prompt injection was detected,falseotherwise.prompt(stringornull): The analyzed prompt, included ifsave_messageistrue.timestamp(string): The timestamp when the analysis was performed, in ISO 8601 format.tag(string): The tag associated with the request.analysis_id(string): Unique identifier for the analysis; can be used to retrieve results later.chat_id(stringornull): The chat session identifier, if provided.metadata(objectornull): The metadata provided in the request, if any.notifications(boolean): Indicates whether notifications were enabled.strictness(integerornull): The strictness level used in the analysis.initial_detection_label(string): Classification label of the initial detection ("INJECTION"or"SAFE").initial_detection_score(numberornull): Confidence score of the initial classification (between0and1).advanced_detection_result(booleanornull): Result of the advanced detection (trueif injection detected,falseif not,nullif advanced detection not performed).
message(string): Additional information or error message.
Parameter Details
-
prompt: The text input that will be analyzed for potential prompt injections. This field is required. -
zero_latency: When set totrue, the endpoint will not wait for the analysis to complete. Instead, it will immediately return a response with astatusof"success"and amessageindicating that processing is occurring in the background. Use the providedanalysis_idto retrieve the analysis result later via the/analysis-resultendpoint. -
tag: A user-defined string for labeling or categorizing the request. It’s useful for tracking purposes or analytics within your application. -
chat_id: An identifier for the chat session or conversation. If provided, it can help associate the analysis result with a specific session in your application. -
save_message: Iftrue, the prompt message will be stored in the system. This is useful for auditing, compliance, or future analysis. -
notifications: Iftrue, the system will send notifications based on the analysis result. Notifications might include alerts to administrators or triggering automated workflows. -
strictness: Controls when advanced detection is performed:- Level 1 (
strictness = 1): Advanced detection is performed only if the initial detection indicates a potential prompt injection. - Level 2 (
strictness = 2): Advanced detection is always performed. - Level 3 (
strictness = 3): Advanced detection is performed only if the initial detection does not indicate a prompt injection.
strictnessis omitted or set tonull, default detection behavior is used without advanced detection. - Level 1 (
-
metadata: An optional JSON object containing additional data or context for the request. This metadata can include any information that you want to associate with the analysis, such as user identifiers, session details, or custom notes. The contents ofmetadataare not processed by the API but are stored and returned in the results for your reference.
Usage Examples
Detecting Prompt Injection with Metadata (Synchronous)
Detecting Prompt Injection with Asynchronous Processing and Metadata
Retrieving Analysis Results
If you use asynchronous processing by settingzero_latency to true, you will receive an analysis_id in the response. You can retrieve the analysis result using this ID through the /analysis-result endpoint.
Fetching Analysis Result
Additional Information
-
Rate Limiting: The API enforces rate limits to ensure fair usage. If you exceed the rate limit, you will receive a
429 Too Many Requestsresponse. Please implement appropriate retry logic with exponential backoff in your applications. -
Error Handling: Always check the
statusfield in the response. If it’s"error", refer to themessagefield for details. - Security: Keep your API key secure. Do not expose it in client-side code, public repositories, or logs.
- Support: For assistance or inquiries, contact our support team at info@glaider.it.
Notes
-
Data Privacy: If you enable
save_message, ensure you comply with data protection regulations and policies relevant to your organization and jurisdiction. - Notifications: The nature of notifications (e.g., email alerts, webhook triggers) depends on your account configuration. Contact support to set up notifications.
Example Scenario: You have a chat application and want to analyze user prompts for potential prompt injection attacks with varying levels of strictness based on the user’s role or the sensitivity of the conversation. By including the
metadata parameter, you can attach additional context to each request, such as the user’s ID, session details, or custom flags. This allows you to correlate analysis results with specific users or sessions, enhancing your security monitoring and incident response processes.
By adjusting the strictness parameter, you can control the trade-off between detection accuracy and processing time. For high-risk interactions, you might set strictness to 2 to always perform advanced detection, ensuring maximum security.
Also, by setting zero_latency to true, your application can quickly respond to the user while the analysis happens in the background. If a prompt injection is detected, and notifications is set to true, your system can receive an alert to take appropriate action, such as logging the event or notifying a moderator.