Inference
POST /v1/inference - the core orchestration endpoint.
The core endpoint. Send a prompt, get a response. Eridian handles schema normalization, routing across GPT and Gemini, caching, RAG, PII redaction, and observability before a token leaves the gateway.
Request
POST /v1/inference
Host: api.geteridian.com
Authorization: Bearer eridian_sk_...
Content-Type: application/json
Idempotency-Key: contract-summary-4821-v1
X-Eridian-Project: prj_legal_001
Required scope: inference:write
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | "auto", "gpt", or "gemini" |
messages | array | Yes | OpenAI-compatible message objects |
project_id | string | Yes | Project that owns budget, residency, and policy |
features | array | No | semantic_cache, pii_redaction, rag, structured_output |
max_tokens | integer | No | Maximum completion tokens |
temperature | float | No | Sampling temperature (0.0 to 2.0) |
stream | boolean | No | Enable SSE streaming |
metadata | object | No | Custom keys stored on the audit event (max 16 pairs) |
routing_policy | string | No | cost_optimized, latency_optimized, quality_optimized, or a custom policy ID |
fallback_chain | array | No | Ordered model IDs used if the primary hop fails |
timeout_ms | integer | No | Total gateway timeout including fallback hops |
cache_config | object | No | Override default caching |
pii_config | object | No | Override default PII entities and strategy |
rag_config | object | No | Override retrieval for this call |
structured_output | object | No | JSON schema for validated output |
template_id | string | No | Published template instead of raw messages |
template_variables | object | No | Values injected into the template |
region | string | No | Override project residency for this request if policy allows |
project_id may be supplied in the body or as X-Eridian-Project. If both are present they must match.
Example Request
{
"model": "auto",
"project_id": "prj_legal_001",
"messages": [
{ "role": "user", "content": "Summarize the key risks in this contract." }
],
"features": ["pii_redaction", "semantic_cache", "rag"],
"routing_policy": "quality_optimized",
"metadata": {
"matter_id": "MTR-4821",
"desk": "legal-ops"
}
}
Response
{
"id": "axm_resp_8f3a2b1c",
"object": "eridian.inference.response",
"model": "gpt",
"created": 1718400000,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The contract contains three key risks:..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1247,
"completion_tokens": 382,
"total_tokens": 1629
},
"eridian": {
"request_id": "axm_req_8f3a2b1c",
"route": "gpt",
"route_fallback": false,
"cache_hit": false,
"cache_similarity": 0.78,
"rag_injected": true,
"rag_chunks": 3,
"pii_redacted": 2,
"pii_entities": ["name", "account_number"],
"latency_ms": 1247,
"cost_usd": 0.0042,
"project_id": "prj_legal_001",
"region": "eu-west-1",
"template_id": "tpl_contract_summary_v3",
"template_version": "3.2.1",
"routing_policy": "quality_optimized",
"structured_output_valid": true
}
}
Retrieve a Response
GET /v1/inference/axm_resp_8f3a2b1c
Authorization: Bearer eridian_sk_...
Required scope: inference:read. Returns the original eridian.inference.response if retention policy still holds the record. Zero-data-retention projects return HTTP 404 with error.code: record_not_retained after the request completes.
Eridian Headers
Every inference response includes these headers:
| Header | Description |
|---|---|
X-Eridian-Request-Id | Unique request ID for support and audit |
X-Eridian-Route | Model that handled the request (gpt or gemini) |
X-Eridian-Cache-Hit | true or false |
X-Eridian-Cache-Similarity | Cosine similarity of the cached match |
X-Eridian-RAG-Injected | true or false |
X-Eridian-PII-Redacted | Number of PII entities redacted |
X-Eridian-Latency-Ms | End-to-end latency in milliseconds |
X-Eridian-Cost-Usd | Cost of this inference in USD |
X-Eridian-Project | Project ID |
X-Eridian-Region | Residency region that processed the call |
X-Eridian-Template | Template ID and version, if used |
X-Eridian-RateLimit-Limit | Requests-per-minute ceiling for this key |
X-Eridian-RateLimit-Remaining | Remaining requests in the current window |
X-Eridian-RateLimit-Reset | Unix timestamp when the window resets |
Streaming
Set "stream": true to receive Server-Sent Events. First-token latency targets p99 under 500ms on Enterprise. Each event is an eridian.inference.chunk object. The terminal event is data: [DONE].
POST /v1/inference
Authorization: Bearer eridian_sk_...
Content-Type: application/json
Accept: text/event-stream
event: chunk
data: {"id":"axm_resp_8f3a2b1c","object":"eridian.inference.chunk","choices":[{"delta":{"content":"The "}}]}
event: chunk
data: {"id":"axm_resp_8f3a2b1c","object":"eridian.inference.chunk","choices":[{"delta":{"content":"contract"}}]}
event: done
data: [DONE]
The final non-done chunk includes eridian metadata (route, cost, cache, PII counts). Do not treat intermediate chunks as complete for audit export.
Feature Flags
The features array activates pipeline stages. Order of execution is fixed: PII redaction → RAG retrieval → semantic cache lookup → routing → model inference → structured output validation.
| Feature | Pipeline stage | Typical use |
|---|---|---|
pii_redaction | Pre-inference | Regulated workloads with client data |
rag | Pre-inference | Grounded answers over uploaded documents |
semantic_cache | Pre-inference | Repetitive enterprise prompts |
structured_output | Post-inference | JSON schema validation with retry |
Status Codes
| HTTP | Code | When |
|---|---|---|
| 200 | - | Non-streaming success |
| 400 | invalid_request | Schema, missing project_id, or conflicting region |
| 401 | invalid_api_key | Missing or malformed eridian_sk_ key |
| 403 | insufficient_scope | Key lacks inference:write |
| 408 | routing_timeout | Fallback chain exceeded timeout_ms |
| 409 | idempotency_conflict | Same key, different body |
| 422 | structured_output_failed | Schema validation exhausted retries |
| 429 | rate_limit_exceeded | Request or token budget for the window |
| 429 | budget_exceeded | Project or key monthly hard stop |
| 503 | model_unavailable | No GPT, Gemini, or private hop in the pool meets policy |
Error bodies always include error.code, error.message, and error.request_id. See Errors.
Idempotency
Include Idempotency-Key on mutating calls that must not double-spend. Eridian stores keys for 24 hours per project. Replays with the same key and the same body return the original eridian.inference.response without a second provider hop. See Idempotency.
Cost Attribution
Every response includes eridian.cost_usd from GPT or Gemini token rates plus Eridian platform overhead. Costs roll up to project, API key, template, desk (metadata.desk), and routing policy. Use metadata to attach internal ticket IDs for finance reconciliation.
Timeouts and Retries
Configure per-project defaults for connect, read, and total timeouts. The routing engine retries transient provider errors once per model in the fallback chain before surfacing a 503. Set client-side timeouts above the sum of fallback chain worst-case latency.
SDK Examples
Python
from eridian import Eridian
client = Eridian(api_key="eridian_sk_...", project_id="prj_legal_001")
response = client.inference.create(
model="auto",
messages=[{"role": "user", "content": "Review this clause for termination risk."}],
features=["semantic_cache", "pii_redaction"],
)
print(response.object)
print(response.eridian.route)
print(response.eridian.cost_usd)
TypeScript
import { Eridian } from "@eridian/sdk";
const client = new Eridian({ apiKey: process.env.ERIDIAN_API_KEY! });
const response = await client.inference.create({
model: "auto",
projectId: "prj_legal_001",
messages: [{ role: "user", content: "Summarize incident timeline." }],
features: ["semantic_cache"],
});
console.log(response.object);
console.log(response.eridian.route);
Compliance Notes
Inference requests are logged to the immutable audit trail with actor, project, model route (gpt or gemini), PII entity counts, region, and cost. Export logs via Audit Log and Evidence Export.
Production API credentials are issued with an institution workspace. Contact sales if you need access.