vijil Python SDK measures and improves Agent trustworthiness from your own code. Use it in scripts, notebooks, and pipelines to run Evaluations, configure protection, and read results programmatically.
This reference covers the Python SDK. For interactive, natural-language access from Claude Code, see MCP. For terminal commands, see the CLI Reference.
Installation
Installvijil-sdk with pip or add it to your project with Poetry:
The Vijil Client
Vijil is the entry point for every SDK operation. Construct it once and reuse it:
The constructor raises
VijilAuthError if no API key can be resolved from any source.
Authentication
Create an API key in your Vijil Console deployment under Settings > API Keys — a client ID (vk_…) plus a one-time secret shown only at creation. Export the pair; the SDK exchanges it for a short-lived access token automatically:
Vijil() reads these from the environment on construction.
Bearer Token
If you already have a bearer access token, provide it directly instead of the client ID and secret:api_key argument takes precedence over VIJIL_API_KEY, which takes precedence over the saved credentials file.
A bearer access token is a JWT that expires 24 hours after it is issued. For long-lived automation, authenticate with the client ID and secret instead — the SDK exchanges them for a fresh token automatically whenever the current one expires.
Gateway Configuration
By default the SDK connects tohttps://api.vijil.ai. Point it at your own Console deployment (enterprise or VPC) with the gateway argument or the VIJIL_GATEWAY environment variable:
- The
gatewayargument - The
VIJIL_GATEWAYenvironment variable - The
gateway.urlvalue in~/.vijil/config.toml - The built-in default,
https://api.vijil.ai
Agent Aliases
The SDK resolves short aliases defined in~/.vijil/config.toml anywhere an Agent ID is expected, so you can pass a memorable name instead of a UUID:
Next Steps
Lifecycle Methods
Evaluate, test, adapt, and protect Agents with high-level methods
Resources
Low-level CRUD accessors for Agents, Evaluations, Harnesses, and more
Models and Errors
Return types, the exception hierarchy, and error-handling patterns
Quickstart
Run your first Evaluation end to end