REST Ingestion API
Send LLM exchange data to Ingate asynchronously, from sidecars, background jobs, or any application that doesn't use the proxy.
Overview
The proxy captures exchanges automatically, but some architectures can't route through a proxy. The Ingestion API lets you send exchange data to Ingate after the fact via REST. Uncontrolled legacy intake queues exchanges for extraction and logging, subject to capture policy and pipeline capacity. Evaluation hooks require configuration; acceptance is not completion.
Single Exchange
/api/v1/ingestIngest a single LLM exchange. Requires member role.
curl -X POST https://api.ingateai.com/api/v1/ingest \
-H "X-Ingate-Key: $INGATE_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"path": "/v1/chat/completions",
"method": "POST",
"status_code": 200,
"latency_ms": 432,
"request_body": {
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}]
},
"response_body": {
"choices": [{"message": {"content": "Hi there!"}}],
"usage": {"prompt_tokens": 10, "completion_tokens": 5}
}
}'{
"request_id": "generated-uuid",
"status": "accepted"
}Reported cache-write lifetimes
The matching collector and service version prerequisite applies to nullable cache_write_5m_input_tokens and cache_write_1h_input_tokens. These subdivide cache_write_input_tokens; do not add them to token totals. Missing/null is unknown and zero remains observed. Negative, fractional, string, boolean or overflowing lifetime values refuse HTTP 400 before dispatch. Partial/mismatched partitions preserve observations but can leave pricing unavailable.
curl --fail-with-body -X POST "$INGATE_URL/api/v1/ingest" \
-H "X-Ingate-Key: $INGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"provider":"anthropic","model":"claude-fable-5","request_id":"reported-ttl-example",
"input_tokens":1000,"output_tokens":500,"cache_write_input_tokens":9000,
"cache_write_5m_input_tokens":1000,"cache_write_1h_input_tokens":8000}'Set INGATE_URL to your verified service origin and INGATE_API_KEY to an issued app-bound key. Use a fresh stable request identity for a new observation; preserve it for recovery. Typed lifetimes are labelled client_reported; captured provider usage takes priority. Caller tags and metadata cannot supply pricing lifetimes. This example sends reported metadata only; acceptance is not proof of storage. See cost interpretation for estimates, missing values and fallback assumptions. It does not establish subscription billing or savings.
Batch Ingestion
/api/v1/ingest/batchIngest multiple exchanges in one call.
curl -X POST https://api.ingateai.com/api/v1/ingest/batch \
-H "X-Ingate-Key: $INGATE_KEY" \
-H "Content-Type: application/json" \
-d '{
"exchanges": [
{
"provider": "openai",
"path": "/v1/chat/completions",
"method": "POST",
"status_code": 200,
"latency_ms": 350,
"request_body": {"model": "gpt-4o-mini"},
"response_body": {"usage": {"prompt_tokens": 10, "completion_tokens": 5}}
},
{
"provider": "anthropic",
"path": "/v1/messages",
"method": "POST",
"status_code": 200,
"latency_ms": 520,
"request_body": {"model": "claude-sonnet-4-20250514"},
"response_body": {"usage": {"input_tokens": 10, "output_tokens": 5}}
}
]
}'{
"accepted": 2,
"rejected": 0,
"items": [
{ "index": 0, "request_id": "uuid-1", "accepted": true },
{ "index": 1, "request_id": "uuid-2", "accepted": true }
]
}Admission modes and recovery
Legacy 202 means queue admission, not durable storage. Single queue refusal returns 503; legacy batch 202 requires inspecting each item's accepted/error, including pipeline full.
Only explicitly operator-enrolled, active telemetry_only organizations with no budget and matching writer configuration use durable REST admission. It commits the log, receipt and accounting fact together, not durable evaluation or export execution. Capture policy still applies. Use an app-bound database key with current member-or-higher access.
{
"request_id": "example-stable-id", "status": "accepted",
"receipt_id": "11111111-1111-4111-8111-111111111111",
"persistence": "durable", "duplicate": false,
"accounting_status": "unknown_price", "micro_usd": null
}Supply and retain a stable request_id and identical input for retries. A generated ID lost with the response cannot recover that response. A 503 admission_outcome_unknown with outcome: unknown may have committed: look up the receipt or retry identical input, never invent a new ID. Changed input conflicts.
/api/v1/ingest/receipts?request_id=example-stable-idCurrent identity required; app-bound member access, or org-wide admin access.
Durable batch 202 is not atomic success: inspect every item's status, accepted, attempted, retryable and outcome. Invalid envelopes can fail before any item is attempted. Bound retries for 503/408; honor Retry-After where present. Fix authentication or provisioning explicitly. For content_conflict, receipt_expired or legacy_unverifiable, stop and reconcile with the operator.
Operator-controlled activation
Legacy Server-Side Extraction
When full request_body and response_body are provided, Ingate runs server-side extraction to automatically populate:
model: extracted from the request bodyprompt: user message textcompletion: assistant response texttoken_count: from response usage objectmetadata: finish reason, stop reason, etc.
Pre-extracted fields
model, prompt, completion,input_tokens, output_tokens, token_count) directly. In the legacy pipeline, counts reconcile independently: an extracted observation wins, including zero; otherwise the supplied count survives. Neither observed means null. Conflicts are recorded. A bare total cannot establish an input/output split or a known price.Durable admission instead selects the whole explicit input/output/total snapshot if any of those counts is present; only with none present can it use the whole extracted snapshot. Missing halves stay absent. For example, supplied 20/7 with a complete body reporting 10/5 yields legacy 10/5 but durable 20/7. Non-2xx or an incomplete/unrecognized final response makes durable accounting usage absent even with supplied counts. With bodies, both must be present and non-streaming with a recognized final signal. The stored total must be observed and equal both present splits; other totals remain metadata, never an invented split.
Supported API Shapes
Server-side extraction supports:
- OpenAI Chat Completions (
/v1/chat/completions) - OpenAI Responses API (
/v1/responses) - Anthropic Messages (
/v1/messages)