EngineNear Gateway API Reference
Real-time prompt optimization and firewall engine API specification. Provides high-throughput, low-latency endpoints for prompt inspection, context compilation, and policy enforcement.
Authentication
All /v1 endpoints require Bearer authentication. Include your API key or tenant JWT token in the Authorization HTTP header:
Authorization: Bearer <your-tenant-jwt-or-api-key>API Endpoints
6 routes registeredEvaluate prompt against real-time security policies
The hot-path firewall endpoint. Analyzes user prompts for secrets (Aho-Corasick + Shannon entropy), multi-region PII, and layered prompt injection in sub-5ms.
Response Status Codes
| Status | Description | Headers / Notes |
|---|---|---|
| 200 | Guard policy verdict with findings and masked/tokenized prompt | - |
| 400 | Input validation failure | - |
| 401 | Missing or invalid authentication token | - |
| 429 | Rate limit quota exceeded | - |
| 503 | Event-loop lag load shedding triggered with Retry-After header | Retry-After: 1 (Load shedding active) |
Score prompt health and compute actionable optimization suggestions
Evaluates clarity, specificity, and safety scores (0-100) and returns gap-filling suggestions for prompt refinement.
Response Status Codes
| Status | Description | Headers / Notes |
|---|---|---|
| 200 | Prompt health diagnostics and optimization recommendations | - |
| 400 | Invalid input | - |
| 401 | Unauthorized | - |
Compile dynamic organizational context with role-based ACL pre-filtering
Extracts intent, resolves CRM/ERP entities, enforces tenant ACLs, and formats verified context into structured XML with strict token budget limits.
Response Status Codes
| Status | Description | Headers / Notes |
|---|---|---|
| 200 | Compiled structured prompt with verifiable citations | - |
| 400 | Validation error | - |
| 401 | Unauthorized | - |
OpenAI-compatible chat completion proxy with inline prompt firewall
Drop-in replacement for OpenAI endpoints. Point any OpenAI-compatible client (Python, TypeScript, LangChain) at the gateway by setting baseURL to http://gateway-host:3000/v1.
Response Status Codes
| Status | Description | Headers / Notes |
|---|---|---|
| 200 | OpenAI-compatible chat completion with EngineNear security metadata | - |
| 403 | Request blocked by active firewall policy (secret or injection detected) | - |
| 429 | Rate limit exceeded | - |
| 503 | Gateway overloaded (load shedding) | - |
Submit telemetry feedback on false positives or rule actions
Logs user decisions (accepted, dismissed, overridden) against a prompt hash for firewall policy tuning.
Response Status Codes
| Status | Description | Headers / Notes |
|---|---|---|
| 202 | Feedback received successfully | - |
Fetch active compiled policy tree for tenant and group
Returns the versioned compiled policy rules and priority ordering currently applied to the request context.
Response Status Codes
| Status | Description | Headers / Notes |
|---|---|---|
| 200 | Active compiled policy tree | - |
Data Models & Schemas
The following Zod schemas are published in @enginenear/shared and compiled into the official OpenAPI 3.0 specification: