Skip to main content

Overview

The Valiqor SDK resolves configuration from three sources, in priority order:
  1. Programmatic — Parameters passed to ValiqorClient(...) or get_config(**overrides)
  2. Environment variablesVALIQOR_API_KEY, VALIQOR_PROJECT_NAME, etc.
  3. Config file.valiqorrc (JSON file, auto-discovered from cwd upward)
Higher-priority sources override lower-priority ones. For example, passing api_key="..." to the constructor always wins over the environment variable.

.valiqorrc File

A JSON configuration file placed in your project root (or any parent directory). The SDK walks up from the current directory to find it.
{
  "project_name": "my-ai-app",
  "api_key": "vq_...",
  "openai_api_key": "sk-...",
  "environment": "development",
  "trace_dir": "valiqor_output/traces",
  "scan_dir": "valiqor_output/scans",
  "valiqor_intelligence": true,
  "backend_url": "https://api.valiqor.com",
  "debug": false,
  "app_version": "1.0.0",
  "auto_providers": ["openai", "langchain", "anthropic"]
}
Never commit API keys to version control. Use environment variables for production deployments.

Environment Variables

VariableConfig KeyDescription
VALIQOR_API_KEYapi_keyYour Valiqor API key.
VALIQOR_PROJECT_NAMEproject_nameDefault project name.
VALIQOR_OPENAI_API_KEYopenai_api_keyOpenAI key for LLM-based metrics.
VALIQOR_BACKEND_URLbackend_urlBackend API URL.
VALIQOR_ENVIRONMENTenvironmentEnvironment label (e.g. production).
VALIQOR_TRACE_DIRtrace_dirLocal trace output directory.
VALIQOR_SCAN_DIRscan_dirLocal scan output directory.
VALIQOR_INTELLIGENCEvaliqor_intelligenceEnable cloud uploads (true/false).
VALIQOR_DEBUGdebugEnable debug logging (true/false).

Configuration Functions

get_config()

Resolve the full configuration from all sources.
from valiqor.common.config import get_config

config = get_config()
print(config["api_key"])
print(config["project_name"])
With overrides:
config = get_config(
    config_file="/path/to/.valiqorrc",
    api_key="override-key",
    project_name="override-project"
)

Config Keys & Defaults

KeyTypeDefault
project_namestr""
api_keystr""
openai_api_keystr""
trace_dirstr"valiqor_output/traces"
scan_dirstr"valiqor_output/scans"
valiqor_intelligenceboolTrue
environmentstr"development"
debugboolFalse
backend_urlstr"https://api.valiqor.com"
enabledboolTrue
app_versionstr"1.0.0"
auto_providersList[str]["openai", "langchain", "anthropic"]

find_config_file()

Find the nearest .valiqorrc file by walking up from the given path.
from valiqor.common.config import find_config_file

path = find_config_file()  # starts from cwd
if path:
    print(f"Found config at: {path}")
ParameterTypeDefaultDescription
start_pathOptional[str]NoneStarting directory. Defaults to cwd.

load_config_file()

Load and parse a .valiqorrc file.
from valiqor.common.config import load_config_file

config_data = load_config_file()  # auto-discovers

save_config()

Write configuration to a .valiqorrc file.
from valiqor.common.config import save_config

# Save specific config
save_config({
    "project_name": "my-app",
    "api_key": "vq_...",
    "environment": "production"
})

# Save current active config
save_config()
ParameterTypeDefaultDescription
configOptional[Dict[str, Any]]NoneConfiguration dict to save. If omitted, saves the current active config.
pathOptional[Path]NoneFile path. Defaults to .valiqorrc in cwd.
Returns: boolTrue if saved successfully.

ensure_output_dirs()

Create the trace and scan output directories if they don’t exist.
from valiqor.common.config import ensure_output_dirs

# With explicit config
ensure_output_dirs(config)

# Or with current active config
ensure_output_dirs()
ParameterTypeDefaultDescription
configOptional[Dict[str, Any]]NoneConfiguration dict. If omitted, uses the current active config.

should_upload()

Check if the current config enables cloud uploads.
from valiqor.common.config import should_upload

if should_upload(config):
    print("Uploads enabled")

Constants

ConstantValueDescription
CONFIG_FILE".valiqorrc"Default config filename.
DEFAULT_BACKEND_URL"https://api.valiqor.com"Default backend URL.
DEFAULT_TRACE_DIR"valiqor_output/traces"Default trace output directory.
DEFAULT_SCAN_DIR"valiqor_output/scans"Default scan output directory.

Module-Level configure()

The top-level valiqor.configure() function provides a convenient shortcut:
import valiqor

config = valiqor.configure(
    api_key="your-api-key",
    project_name="my-app",
    environment="production"
)

Example: Production Setup

# .env file (loaded by your deploy pipeline)
VALIQOR_API_KEY=vq_prod_abc123
VALIQOR_PROJECT_NAME=chatbot-v2
VALIQOR_ENVIRONMENT=production
VALIQOR_OPENAI_API_KEY=sk-prod_xyz789
VALIQOR_INTELLIGENCE=true
# app.py — no config needed, reads from env
from valiqor import ValiqorClient

client = ValiqorClient()  # All config from env vars
result = client.failure_analysis.run(dataset=my_data)