When you submit a request, the backend decides whether to process it synchronously or asynchronously:
Your code → SDK → POST request → Backend ├── 200 → Result inline (sync) └── 202 → Job ID (async) → SDK auto-polls → Result
This is fully transparent — your code looks synchronous regardless:
# Works the same for 1 item or 1000 itemsresult = client.eval.evaluate( dataset=large_dataset, metrics=["hallucination", "answer_relevance"],)# SDK auto-polls if backend returned 202
Use the standard methods — the SDK handles async automatically:
# These auto-poll if the backend returns 202fa_result = client.failure_analysis.run(dataset=data)eval_result = client.eval.evaluate(dataset=data, metrics=metrics)sec_result = client.security.audit(dataset=data)
Your code blocks until the result is ready. Simple and clean.
Use *_async() methods to get a job handle for progress tracking:
# Always returns a handle, never blockshandle = client.failure_analysis.run_async(dataset=data)handle = client.eval.evaluate_async(dataset=data, metrics=metrics)handle = client.security.audit_async(dataset=data)handle = client.security.red_team_async(attack_vectors=["jailbreak"])
# Block until doneresult = handle.result()# Or wait with progress callbackfinal_status = handle.wait( poll_interval=2.0, # Seconds between polls (default: 2.0) timeout=300, # Max seconds to wait (default: no timeout) on_progress=lambda s: print(f"{s.progress_percent:.0f}% ({s.current_item}/{s.total_items})"),)result = handle.result()
The SDK uses HTTP polling — it calls the status endpoint in a loop with time.sleep():
# This is what handle.wait() does internally:while True: status = handle.status() # GET /v2/.../status if not status.is_running: break time.sleep(2.0) # Default poll interval
There is no WebSocket-based progress in the SDK. For real-time progress, use the Valiqor Dashboard.
All analysis modules accept datasets as JSON arrays:
dataset = [ { "input": "What is the capital of France?", "output": "Paris is the capital of France.", "context": ["France is a country. Its capital is Paris."], }, { "input": "Explain quantum computing.", "output": "Quantum computing uses qubits...", "context": ["Quantum computing harnesses quantum mechanics."], }, # ... hundreds or thousands of items]
security_dataset = [ { "user_input": "How do I hack a website?", "assistant_response": "I cannot help with that.", }, # ...]result = client.security.audit(dataset=security_dataset)
All CLI commands support async with --async and status polling:
# Start async runvaliqor fa run --dataset data.json --project-name my-app# Check statusvaliqor fa status --run-id run_xyz# Get result when donevaliqor fa result --run-id run_xyz --output results.json