Skip to content

API Reference

Valter exposes a REST API on port 8000 with API key authentication, Redis-backed rate limiting, cursor-based pagination, and structured JSON error responses.

EnvironmentURL
Developmenthttp://localhost:8000
ProductionRailway deployment URL

All versioned endpoints use the /v1/ prefix. Non-versioned endpoints (/health, /metrics) live at the root.

Terminal window
# Development
curl http://localhost:8000/v1/retrieve -X POST -H "Content-Type: application/json" ...
# Production
curl https://<railway-url>/v1/retrieve -X POST -H "Content-Type: application/json" ...

API key authentication is controlled by the VALTER_AUTH_ENABLED environment variable (required true in production).

Pass the key as a Bearer token:

POST /v1/retrieve HTTP/1.1
Authorization: Bearer vlt_k1_abc123...
Content-Type: application/json

Each API key carries one or more scopes that restrict which endpoints it can access:

ScopeAccess
readSearch, graph queries, verify, enrich, health
writeIngest workflows, memory creation
adminMetrics, dataset management, all operations
  • Keys are hashed with SHA-256 before storage (not bcrypt).
  • All API key usage is logged to a persistent audit log with timestamp, endpoint, and key fingerprint.
  • Invalid or missing keys return 401 UNAUTHORIZED.
  • Insufficient scope returns 403 FORBIDDEN.

Rate limiting uses a Redis sliding window with per-key counters (INCR).

Operation typeDefault limitEnv var
Read endpoints100 requests/minVALTER_RATE_LIMIT_READ
Write endpoints10 requests/minVALTER_RATE_LIMIT_WRITE

Every response includes rate limit headers:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 87
X-RateLimit-Reset: 1709136000

When the limit is exceeded, the API returns 429 RATE_LIMITED.

All errors return a consistent JSON envelope with an error object:

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"trace_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"details": null
}
}
CodeHTTP StatusDescription
INVALID_REQUEST400Malformed request body or parameters
UNAUTHORIZED401Missing or invalid API key
FORBIDDEN403Valid key but insufficient scope
NOT_FOUND404Resource does not exist
TIMEOUT408Backend query exceeded time limit
VALIDATION_ERROR422Pydantic validation failure
RATE_LIMITED429Rate limit exceeded
INTERNAL_ERROR500Unhandled server error
SERVICE_UNAVAILABLE503Backend service (Neo4j, Qdrant, etc.) unreachable

The trace_id field correlates with structured logs (structlog JSON format) for debugging.

List endpoints support cursor-based pagination using opaque base64-encoded cursors.

ParameterTypeDescription
cursorstringOpaque cursor from a previous response. Omit on the first request.
page_sizeintegerNumber of results per page (must be <= top_k).
FieldTypeDescription
pagination.cursorstring | nullCursor for the next page, or null if no more results.
pagination.has_morebooleanWhether additional pages exist.
pagination.total_estimateinteger | nullEstimated total result count.

Cursors encode the last score, last document ID, page number, and a query hash for validation. A cursor from one query cannot be reused with a different query.

{
"data": [...],
"meta": { "trace_id": "...", "latency_ms": 42.5 },
"pagination": {
"cursor": "eyJsYXN0X3Njb3JlIjogMC44NSwgInBhZ2UiOiAxfQ==",
"has_more": true,
"total_estimate": 156
}
}

Requests pass through the middleware stack in this order:

OrderMiddlewarePurpose
1CORSConfigurable allowed origins for cross-origin requests
2MetricsIPAllowlistRestricts /metrics access to IPs in VALTER_METRICS_IP_ALLOWLIST (CIDR supported). Reads cf-connecting-ip and x-forwarded-for for proxy-aware IP resolution.
3RequestTrackingAssigns a trace_id (UUID) to each request, records Prometheus request count and duration histograms
4RateLimitRedis sliding window rate limiting per API key
5AuthenticationAPI key validation + scope checking. Skips auth for /health, /metrics, /docs, /openapi.json, /redoc.

Audit logging runs within the authentication middleware for all endpoints except health, metrics, and documentation paths.

GroupKey endpointsDocs
SearchPOST /v1/retrieve, POST /v1/similar_cases, POST /v1/search/features, POST /v1/factual/dual-searchSearch Endpoints
GraphPOST /v1/graph/* (13 endpoints)Graph Endpoints
Verify & EnrichPOST /v1/verify, POST /v1/context/enrich, POST /v1/factual/extractVerify & Enrich
IngestPOST /v1/ingest/* (20+ endpoints)Ingest Endpoints
AdminGET /v1/health, GET /metrics, GET/POST /v1/memories, GET /v1/datasets/*Admin & Utility
MCP Tools28 tools via stdio/HTTPMCP Tools Reference