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. If you use client credentials, provide both client_id and client_secret.
Authentication
Create API credentials under Settings > API Keys in your Vijil Console deployment. Each credential consists of a client ID (vk_…) and a secret that the Console shows only once. Provide the pair through environment variables or constructor arguments:
Vijil() reads VIJIL_CLIENT_ID and VIJIL_CLIENT_SECRET from the environment. The SDK exchanges the pair for a bearer access token when it constructs the client. It does not store the client ID or secret.
Bearer Token
If you already have a bearer access token, provide it directly instead of the client ID and secret:- A complete
client_idandclient_secretpair passed toVijil() - An
api_keypassed toVijil() VIJIL_CLIENT_IDandVIJIL_CLIENT_SECRET, when you pass no authentication argumentsVIJIL_API_KEY- The token in
~/.vijil/credentials.json
The gateway determines the access token lifetime. The SDK does not store a client credential pair after its initial exchange. If that token expires, construct a new client or call
client.authenticate(client_id="<client-id>", client_secret="<client-secret>"). Your application must replace bearer tokens supplied through api_key or VIJIL_API_KEY; tokens loaded from the saved credentials file can use the SDK’s refresh flow.Gateway Configuration
By default, the SDK connects tohttps://console-api.vijil.ai. Point it at another Console deployment with the gateway argument or save the URL in ~/.vijil/config.toml:
- The
gatewayargument - The
gateway.urlvalue in~/.vijil/config.toml - The built-in default,
https://console-api.vijil.ai
Agent Aliases
Methods that support Agent aliases read them from~/.vijil/config.toml, so you can pass a memorable name instead of a UUID: