Direct API call
Best for server apps, workers, and low-level control.
POST /v1/chat/completions X-VG-Api-Key: ... X-VG-Agent: default
This is the canonical public contract for ValGuard. The live spec is served directly by the API at the quickstart and can be fetched from https://api.valguard.ai/openapi.json.
Use the endpoint index for a complete route map, then jump to payload examples for request and response shapes.
API keys, bearer auth, scopes, and dashboard key lifecycle.
Unified error envelopes and the status codes clients must handle.
OpenAI-compatible request and response contract for /v1/chat/completions.
Health checks and the public OpenAPI discovery endpoint.
Jump straight to the exact part of the contract you need.
Choose the integration style that matches your stack. All paths use the same response envelope and validation headers.
Best for server apps, workers, and low-level control.
POST /v1/chat/completions X-VG-Api-Key: ... X-VG-Agent: default
Use playbook orchestration with deterministic branch logic.
POST /v1/chat/completions X-VG-Api-Key: ... X-VG-Flow: invoice-triage
Session-auth routes for workspace configuration and defaults.
GET/PATCH /api/org/features Cookie: session=...
Copy-paste flows for the most common production paths.
Synchronous server call with full validation headers.
POST https://api.valguard.ai/v1/chat/completions
Headers:
X-VG-Api-Key: vg_live_...
X-VG-Agent: support-default
Body:
{
"model": "gpt-4o-mini",
"messages": [{"role":"user","content":"Summarize order"}],
"temperature": 0.2
}
Read headers:
X-VG-Request-Id
X-VG-Validation-StatusNightly processing with deterministic flow routing.
for each record in batch:
POST https://api.valguard.ai/v1/chat/completions
Headers:
X-VG-Api-Key: vg_live_...
X-VG-Flow: invoice-triage
Body:
{
"model": "openai/gpt-4o-mini",
"messages": [{"role":"user","content":"...record payload..."}]
}
on 429/503:
exponential backoff + retryConfigure org-level self-heal defaults used by inherited agents.
GET /api/org/features
PATCH /api/org/features
{
"self_heal_preset_default": "custom",
"self_heal_rules_default": {
"tier1:fix_trailing_comma": true,
"tier2:cast_numeric": true
}
}
Result:
agents with preset=inherit use these defaultsComplete quick links for Python, Node.js, Go, and C#. Each SDK covers API auth headers, agent or flow routing, and validation metadata parsing.
| SDK | Install | Quick docs | Package source |
|---|---|---|---|
| Python | pip install valguard | Python quickstart | packages/sdk-python |
| Node.js | npm install @valguard/sdk-node | Node quickstart | packages/sdk-node |
| Go | go get github.com/valguard/valguard/packages/sdk-go | Go quickstart | packages/sdk-go |
| C# | dotnet add package ValGuard.Sdk | C# quickstart | packages/sdk-csharp |
Use this skeleton in your app-level wrapper around SDK calls.
attempt = 0
while attempt < 5:
try:
return sdk.chat_completions(payload)
except ApiError as err:
if err.status not in (429, 503):
raise
sleep(min(10, 0.5 * (2 ** attempt)) + jitter_ms(0, 250) / 1000)
attempt += 1
raise RetryExhausted()for (let attempt = 0; attempt < 5; attempt++) {
try {
return await sdk.chatCompletions(payload);
} catch (err) {
if (![429, 503].includes(err.status)) throw err;
const delayMs = Math.min(10_000, 500 * 2 ** attempt) + jitter(0, 250);
await wait(delayMs);
}
}
throw new Error("retry_exhausted");for attempt := 0; attempt < 5; attempt++ {
out, err := client.ChatCompletions(ctx, payload)
if err == nil {
return out, nil
}
if !isRetryable(err, 429, 503) {
return nil, err
}
sleep(backoff(attempt, 500*time.Millisecond, 10*time.Second) + jitter(250*time.Millisecond))
}
return nil, errors.New("retry_exhausted")for (var attempt = 0; attempt < 5; attempt++)
{
try { return await sdk.ChatCompletionsAsync(payload); }
catch (ApiException ex) when (ex.StatusCode is 429 or 503)
{
var delay = Math.Min(10000, 500 * (int)Math.Pow(2, attempt)) + Jitter(0, 250);
await Task.Delay(delay, cancellationToken);
}
}
throw new Exception("retry_exhausted");Fast runbook for the most common production integration failures.
API key missing, invalid, or sent in the wrong header.
Rate or quota limit reached.
Temporary upstream or platform unavailability.
Retry on: 429, 503 Max attempts: 5 Backoff: min(10s, base * 2^attempt) + jitter(0-250ms) Non-retryable: 400, 401, 403, 404, 422
{
"status": 429,
"code": "rate_limited",
"request_id": "from X-VG-Request-Id",
"agent_or_flow": "support-default",
"attempt": 2,
"retry_after": "2"
}What each endpoint expects on input and what it returns on success.
| Endpoint | Data load (request) | Data returned (response) | Common statuses |
|---|---|---|---|
/v1/chat/completions | Headers: X-VG-Api-Key, X-VG-Agent or X-VG-Flow.Body: model, messages[], optional stream, temperature, max_tokens. | OpenAI-style completion: id, choices[], usage.Response headers include X-VG-Request-Id, X-VG-Validation-Status. | 200, 400, 401, 403, 404, 413, 429, 503 |
/api/org/features (GET) | Session-auth cookie, admin role. | quarantine_payloads_enabled, self_heal_preset_default, self_heal_rules_default. | 200, 401, 403 |
/api/org/features (PATCH) | JSON patch for: quarantine_payloads_enabled, self_heal_preset_default, self_heal_rules_default. | Same shape as GET with normalized defaults. | 200, 400, 401, 403 |
/healthz | No body. | Plain text liveness response. | 200 |
/readyz | No body. | Plain text readiness response. | 200, 503 |
/openapi.json | No body. | OpenAPI 3.2 JSON document. | 200 |
{
"quarantine_payloads_enabled": true,
"self_heal_preset_default": "custom",
"self_heal_rules_default": {
"tier1:fix_trailing_comma": true,
"tier1:fix_missing_comma": true,
"tier2:cast_numeric": true
}
}{
"quarantine_payloads_enabled": true,
"self_heal_preset_default": "custom",
"self_heal_rules_default": {
"tier1:fix_trailing_comma": true,
"tier1:fix_missing_comma": true,
"tier2:cast_numeric": true
}
}Complete endpoint map for production use and dashboard management surfaces.
These endpoints are part of the public contract and represented in OpenAPI.
| Method | Path | Purpose | Body |
|---|---|---|---|
| POST | /v1/chat/completions | Validated chat completions | JSON request payload |
| GET | /healthz | Liveness probe | None |
| GET | /readyz | Readiness probe | None |
| GET | /openapi.json | Canonical API contract document | None |
Used by the dashboard for CRUD and orchestration management. Requires active session cookies, not API key headers.
| Area | Routes | Data operations |
|---|---|---|
| Agents | /api/agents, /api/agents/{slug}, /api/agents/bulk-delete | List, create, update, delete agents |
| Validators | /api/agents/{slug}/validators, /history, /validation-summary | Read and replace validator sets |
| Playbooks | /api/orchestration/flows, /publish, /test, /import | CRUD, publish, run tests, import/export |
| Templates | /api/templates, /api/org/templates, /api/org/playbook-templates | List, create, fork, submit, apply templates |
| Keys and org | /api/keys, /api/org/*, /api/dashboard/* | API keys, members, providers, usage and analytics |
Copy-ready request shapes for common API operations.
{
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "system", "content": "You are a safe assistant."},
{"role": "user", "content": "Summarize this payload"}
],
"stream": false,
"temperature": 0.2,
"max_tokens": 512
}{
"slug": "invoice-agent",
"name": "Invoice extraction",
"preset": "standard",
"settings": {
"default_provider": "openai",
"default_model": "gpt-4o-mini",
"max_reasks": 1,
"shadow_mode": true,
"self_heal_preset": "safe"
}
}{
"validators": [
{
"name": "required_fields",
"enabled": true,
"priority": 10,
"severity": "error",
"on_fail": "block",
"params": {"fields": ["invoice_id", "total"]}
}
]
}{
"name": "Invoice triage flow",
"slug": "invoice-triage",
"description": "Parse invoice and route for approval",
"graph": {
"nodes": [],
"edges": []
}
}Use a production API key from the dashboard or the X-VG-Api-Key header. Keys are masked in the UI, auditable, and revocable.
Every non-2xx response follows a structured JSON error envelope with a machine-readable code and a stable message.
The public completion endpoint is POST /v1/chat/completions and accepts OpenAI-style messages, with ValGuard validation and observability headers.
Common fields include model, messages, stream, temperature, and max_tokens.
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | Yes | Target model identifier such as gpt-4o-mini. |
messages | array | Yes | OpenAI-style chat turns with role and content. |
stream | boolean | No | Set to true for streaming responses. |
temperature | number | No | Controls randomness for the generation step. |
max_tokens | integer | No | Maximum output length for the completion. |
{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Summarize this payload"}],
"stream": false,
"temperature": 0.2,
"max_tokens": 512
}Send your API key in the X-VG-Api-Key header, or use a bearer token if your deployment is configured for that scheme.
curl -X POST https://api.valguard.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-VG-Api-Key: YOUR_API_KEY" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}'curl -X POST https://api.valguard.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-VG-Api-Key: YOUR_API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}]
}'{
"id": "chatcmpl-123",
"object": "chat.completion",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help?"
},
"finish_reason": "stop"
}]
}The API exposes GET /healthz, GET /readyz, and GET /openapi.json for health and discovery.
Successful requests return 200 or 202 for streamed or accepted work, while validation and auth failures use 400, 401, and 422.
Completed successfully.
Accepted for asynchronous or streaming work.
Malformed payload or invalid structure.
Missing or invalid API key.
Validation failed for the submitted content.
The canonical contract lives in the live OpenAPI document at https://api.valguard.ai/openapi.json.
/v1/chat/completionsOpenAI-compatible chat completion endpoint. Accepts a JSON body with model, messages, and optional stream, temperature, and max_tokens.
/healthzReturns the service health status for probes and uptime checks.
/readyzReturns readiness for load balancer and deployment health checks.
/openapi.jsonReturns the canonical public OpenAPI 3.2 document for clients and SDK generators.