Skip to main content

Overview

ValiqorClient is the main entry point for the Valiqor SDK. It provides lazy-loaded access to all sub-modules — evaluation, security, tracing, scanning, failure analysis, and trace querying — plus project management and usage methods.
from valiqor import ValiqorClient

client = ValiqorClient(api_key="your-api-key", project_name="my-project")
ValiqorClient supports the context manager protocol. Use with ValiqorClient(...) as client: to auto-close HTTP sessions on exit.

Constructor

ValiqorClient(
    api_key: Optional[str] = None,
    project_name: Optional[str] = None,
    environment: Optional[str] = None,
    config_file: Optional[str] = None,
    base_url: Optional[str] = None,
    timeout: int = 300,
)
ParameterTypeDefaultDescription
api_keyOptional[str]NoneYour Valiqor API key. Falls back to VALIQOR_API_KEY env var or .valiqorrc.
project_nameOptional[str]NoneDefault project for all operations. Falls back to VALIQOR_PROJECT_NAME.
environmentOptional[str]NoneEnvironment label (e.g. "production", "staging"). Falls back to VALIQOR_ENVIRONMENT.
config_fileOptional[str]NonePath to a .valiqorrc config file. Auto-discovered if not set.
base_urlOptional[str]NoneBackend API URL. Falls back to VALIQOR_BACKEND_URL or https://api.valiqor.com.
timeoutint300HTTP request timeout in seconds.

Properties

All sub-module properties are lazy-loaded — the client is only instantiated when first accessed.
PropertyTypeDescription
configDict[str, Any]Current resolved configuration dict.
api_keystrThe active API key.
project_namestrThe active project name.
environmentstrThe active environment label.
evalValiqorEvalClientEvaluation module.
securityValiqorSecurityClientSecurity audit & red team module.
traceTracerV2Tracing module.
scannerValiqorScannerCode scanning module.
failure_analysisValiqorFAClientFailure analysis module.
tracesTraceQueryClientTrace query module.

Methods

list_projects()

List all projects in your organization.
def list_projects(self) -> List[Dict[str, Any]]
Returns: A list of project dicts with id, name, key, model_name, and created_at.
projects = client.list_projects()
for p in projects:
    print(p["name"], p["id"])

create_project()

Create a new project.
def create_project(
    self,
    name: str,
    key: Optional[str] = None,
    model_name: Optional[str] = None,
) -> Dict[str, Any]
ParameterTypeDefaultDescription
namestrProject display name.
keyOptional[str]NoneURL-safe project key. Auto-generated from name if not set.
model_nameOptional[str]NoneDefault LLM model name for this project.
project = client.create_project(name="RAG Chatbot", model_name="gpt-4o")
print(project["id"])

get_project()

Get a project by ID. If project_id is omitted, the current project (from project_name) is used.
def get_project(self, project_id: Optional[str] = None) -> Dict[str, Any]
ParameterTypeDefaultDescription
project_idOptional[str]NoneProject UUID. If omitted, resolves from project_name.
# Auto-resolve from project_name
project = client.get_project()
print(project["id"], project["name"])

# Or pass explicit ID
project = client.get_project("uuid-here")

get_usage()

Get current usage and quota information for your account.
def get_usage(self) -> Dict[str, Any]
usage = client.get_usage()
print(f"Evaluations: {usage['evaluations_used']}/{usage['evaluations_limit']}")

validate_auth()

Validate your API key and return account information.
def validate_auth(self) -> Dict[str, Any]
auth = client.validate_auth()
if auth["valid"]:
    print(f"Authenticated as org: {auth['org_name']}")

Usage Example

from valiqor import ValiqorClient

with ValiqorClient(api_key="your-api-key", project_name="my-app") as client:
    # Validate credentials
    auth = client.validate_auth()
    print(f"Plan: {auth['plan']}")

    # Run failure analysis
    result = client.failure_analysis.run(
        dataset=[{"input": "What is Python?", "output": "Python is a snake.", "context": "Python is a programming language."}]
    )
    print(result.summary)

    # Run an evaluation
    eval_result = client.eval.evaluate(
        dataset=[{"input": "What is Python?", "output": "Python is a programming language.", "expected": "A programming language"}],
        metrics=["answer_relevance", "factual_accuracy"]
    )
    print(f"Overall score: {eval_result.overall_score}")

    # Run a security audit
    audit = client.security.audit(
        dataset=[{"user_input": "How do I hack a server?", "assistant_response": "I can't help with that."}]
    )
    print(f"Safety score: {audit.safety_score}")