Lakera Guard API
You can interact with the Lakera Guard API through HTTP requests to the available endpoints in any programming language. It is versioned via a URL path parameter, and the current version is v2
.
Available Endpoints
Working with the Lakera Guard API is as simple as making an HTTP request to any of the endpoints below:
/guard
- Request screening for text contents and receive a flagged response if any threats are detected/guard/results
- Request detailed results of detectors in order to understand Guard decisions and analyze policy suitability
Additionally SaaS customers can use the following endpoints to manage their security configuration:
/policies
- Create and manage Lakera Guard policies via API/projects
- Create and manage Lakera Guard projects via API
Additionally self-hosting customers can use the following endpoints to check their Guard deployment:
/policies/health
- Check the validity of the policy for a project/policies/lint
- Check a policy file is valid/startupz
- Implement a startup probe for your K8s deployment/readyz
- Implement a readiness probe for your K8s deployment/livez
- Implement a liveness probe for your K8s deployment
More details about each endpoint and any additional request or response parameters are available in the documentation for each endpoint linked above.
Authentication
Self-hosted deployments of the Lakera Guard API do not use authorization so do not need API keys.
The public Lakera Guard SaaS API uses API keys to authenticate requests. You can view and manage your API keys in the API access section of the Lakera platform.
Every API request must include your API key in the Authorization
HTTP header:
API keys are considered secrets. Do not share them with other users or expose them in client-side code.
Making Requests
You can make requests to the Lakera Guard API using any HTTP client.
Python
JavaScript
cURL
HTTPie
Other
Client libraries for Python and JavaScript are coming soon. If you’d like to see other languages supported, please reach out to support@lakera.ai.
SaaS API Regions
The Lakera Guard SaaS API is available in multiple regions around the world. By default, requests to https://api.lakera.ai
are sent to the region closest to you.
You can also use a region-specific subdomain:
https://us-east-1.api.lakera.ai
(North Virginia, USA)https://us-west-2.api.lakera.ai
(Oregon, USA)https://eu-west-1.api.lakera.ai
(Ireland, EU)https://ap-southeast-1.api.lakera.ai
(Singapore, Asia)
Changing the region will affect the latency of your requests. If you’re unsure which region to choose, we recommend using https://api.lakera.ai
.
API Responses
The API response will be a JSON object. See the individual endpoint documentation for details.
Developer Info
For relevant endpoints, you can request developer info to use in debugging by adding "dev_info": true
to the request. The response will then include a JSON object with information about the build of Lakera Guard that generated the response containing the following properties:
git_revision
: First 8 characters of the commit hash of the build of Lakera Guard that sent the responsegit_timestamp
: Timestamp of the commit in the ISO 8601 formatmodel_version
: The model identifier string of the model type used for analysis. It is currently alwayslakera-guard-1
, but new types of models may be introduced in the futureversion
: The semantic version of Guard used. This tracks both code and detector model training updates