You can check for Prompt Injections from the /injection
or Injection
class in the Python client. This endpoint/Class takes two parameters:
prompt
- The prompt you would like to check for potential injections.detect
- A boolean for whether you would like any injection to be scored and blocked. (Mainly used in the Completions/Chat endpoints).
The output will include a score from 0.0 to 1.0. The higher the score, the higher the probability of the checked prompt being an injection.
Check for Prompt Injection
To check for prompt injections, you can use the following code examples. Depending on your preference or requirements, select the appropriate method for your application.
This approach provides a straightforward way for readers to choose and apply the code example that best suits their needs for checking prompt injections using either Python or cURL.