Direct API call
Best for server apps, workers, and low-level control.
POST /v1/chat/completions Authorization: Bearer ... X-VG-Agent: default
This is the canonical public contract for ValGuard. Fetch the live OpenAPI document at https://api.valguard.ai/openapi.json. Integration steps live in the quickstart. Contract changes are listed in the API changelog.
/v1 response includes X-VG-Request-Id and JSON errors use Content-Type: application/json.stream: true with a block, reask, or response-repair rule is buffered. ValGuard validates the full assistant text, then emits OpenAI chunks (role on the first delta, finish_reason and usage on the last) and [DONE]. That response sets X-VG-Stream-Buffered: true. Warn-only agents can use live passthrough (X-VG-Validation-Status: stream_passthrough). Stream usage comes from the provider stream_options.include_usage chunk, or a server-side estimate when the provider omits it.reasoning fields are forwarded on the completion and are not validated or stripped. Validators see choices[0].message.content only.model and no agent default returns 400 missing_model. A BYOK key whose prefix belongs to another provider (for example a Groq gsk_ key with a Gemini model) returns 400 provider_key_mismatch and is not forwarded. Upstream error text is redacted so key material, including masked fragments, is not returned.GET /v1/models returns a curated catalog. Browser CORS is not supported; OPTIONS explains that and does not send Access-Control-* headers.X-VG-Warnings. Estimated spend, when a price exists, is X-VG-Estimated-Cost-Microusd. A null provider usage_breakdown is omitted.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 Authorization: Bearer ... X-VG-Agent: default
Use playbook orchestration with deterministic branch logic.
POST /v1/chat/completions Authorization: Bearer ... 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. Sample bodies use groq/openai/gpt-oss-20b; any provider/model works, for example groq/llama-3.3-70b-versatile.
Synchronous server call with full validation headers.
POST https://api.valguard.ai/v1/chat/completions
Headers:
Authorization: Bearer vg_live_...
X-VG-Agent: support-default
Body:
{
"model": "groq/openai/gpt-oss-20b",
"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": "groq/openai/gpt-oss-20b",
"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-sdk (import valguard). PyPI valguard is an unrelated project (jhmanton/valguard); this client cannot use that name. | Python quickstart | packages/sdk-python |
| Node.js | npm install @valguard/sdk-node. Unscoped npm valguard is a placeholder, not this client. | Node quickstart | packages/sdk-node |
| Go | go get github.com/valguard-ai/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, and X-Vg-Upstream-Retries on agent and playbook completions. | 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": "groq/openai/gpt-oss-20b",
"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": "groq/openai/gpt-oss-20b",
"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 layer is chat-first. Legacy OpenAI endpoints that are not wired on the proxy return 404 with a JSON error body.
POST /v1/completions — use POST /v1/chat/completions instead.POST /v1/embeddings — not exposed on the public API.X-VG-Flow) do not support stream: true; the API returns HTTP 400 orchestration_stream_unsupported.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 | Provider-qualified slug such as groq/openai/gpt-oss-20b. |
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": "groq/openai/gpt-oss-20b",
"messages": [{"role": "user", "content": "Summarize this payload"}],
"stream": false,
"temperature": 0.2,
"max_tokens": 512
}Send the API key as Authorization: Bearer. X-VG-Api-Key is an accepted alternative. Use one header, not both. Chat completions do not honor Idempotency-Key (the response sets X-VG-Idempotency: unsupported). Playbooks dedupe X-VG-Idempotency-Key for 24 hours.
curl -X POST https://api.valguard.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-VG-Agent: default" \
-d '{"model":"groq/openai/gpt-oss-20b","messages":[{"role":"user","content":"Hello"}]}'
# Alternative: -H "X-VG-Api-Key: YOUR_API_KEY"curl -X POST https://api.valguard.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-VG-Agent: default" \
-d '{
"model": "groq/openai/gpt-oss-20b",
"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. A blocking validator returns 403 by default. Auth failures use 401. 422 is used only when an agent sets that validation status.
Completed successfully.
Accepted for asynchronous or streaming work.
Malformed payload or invalid structure.
Missing or invalid API key.
Default validation block (`validation_block`). 422 is only used when the agent sets that status.
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.