Skip to main content

Concept Execution

Endpoints that evaluate a concept against an entity and return a Result (Rₜ). All are deterministic when timestamp is provided. The LLM is never involved.


Execute Concept

POST /execute

Evaluates a compiled concept for a single entity. The primary execution endpoint for the SDK hot path. Implicitly executes the concept graph, fetches primitives via the data resolution layer, and returns a typed Result (Rₜ).

Request — ExecuteRequest

FieldTypeRequiredDescription
idstrRequiredFully qualified concept id (namespace.id).
versionstrRequiredExplicit version. HTTP 400 if missing or 'latest'.
entitystrRequiredEntity to evaluate.
timestampstrOptionalISO 8601 UTC. Deterministic execution when set. Snapshot mode when absent.
explainboolOptionalDefault False. Include Explanation in response.
explain_modestrOptional'summary' | 'full' | 'debug'. Default 'full'.
cacheboolOptionalDefault True. Set False to force recomputation.
missing_data_policystrOptional'null' | 'zero' | 'forward_fill' | 'backward_fill'.

Response — Result (Rₜ)

FieldTypeRequiredDescription
valuefloat|bool|strAlwaysComputed output. Type matches the concept's declared output type.
typestrAlways'float' | 'boolean' | 'categorical'.
entitystrAlwaysThe entity evaluated.
versionstrAlwaysConcept version used.
deterministicboolAlwaysTrue when timestamp was provided.
timestampstr|NoneAlwaysEcho of the request timestamp, or None in snapshot mode.
explanationdict|NoneOptionalPopulated when explain=True. Contains contributions, nodes[], trace[].

Response Codes

StatusDescription
200Result (Rₜ) produced.
400Validation error — missing required field, or version='latest' rejected.
401Unauthorised — missing or invalid X-API-Key.
404Concept not found at this id and version.
408Execution timed out (30s). Switch to POST /execute/async for heavy workloads.
422Execution error — primitive fetch failed, null propagation, or data source unavailable.
429Rate limit exceeded. Respect the Retry-After header.

Python Example

import memintel

client = memintel.AsyncClient()

result = await client.execute(
id='org.churn_risk',
version='1.2',
entity='user_abc123',
timestamp='2024-03-15T09:00:00Z',
explain=True,
)

print(result.value) # 0.87
print(result.deterministic) # True

Execute via Precompiled Graph

POST /execute/graph

Executes a previously compiled ExecutionGraph directly by graph_id, bypassing the compilation step. This is the highest-throughput execution path — compile once at startup, call this in the hot path. Optionally supply ir_hash to verify the graph has not changed since compilation (audit trail mechanism).

Request — ExecuteGraphRequest

FieldTypeRequiredDescription
graph_idstrRequiredID returned by POST /compile.
entitystrRequiredEntity to evaluate.
ir_hashstrOptionalIf provided, server verifies stored graph's ir_hash matches. Returns HTTP 409 on mismatch.
timestampstrOptionalISO 8601 UTC. Deterministic when provided.
explainboolOptionalDefault False.
cacheboolOptionalDefault True.
missing_data_policystrOptional'null' | 'zero' | 'forward_fill' | 'backward_fill'.

Response Codes

StatusDescription
200Result (Rₜ) — same schema as POST /execute.
400Validation error.
401Unauthorised.
404Graph not found.
408Execution timed out.
409ir_hash mismatch — stored graph has changed. Re-compile and update your graph_id.
422Execution error.
429Rate limit.

Execute Batch

POST /execute/batch

Evaluates a concept for a list of entities in parallel. Independent entities are evaluated concurrently. Shared subgraph computations are deduplicated. Partial failure is possible — always inspect each item's status field. The response is always HTTP 200.

Request — BatchExecuteRequest

FieldTypeRequiredDescription
idstrRequiredFully qualified concept id.
versionstrRequiredExplicit version.
entitieslist[str]RequiredEntity IDs to evaluate in parallel. Max 500 per batch.
timestampstrOptionalShared evaluation timestamp. All results deterministic when set.
explainboolOptionalDefault False.
missing_data_policystrOptional'null' | 'zero' | 'forward_fill' | 'backward_fill'.

Response — BatchExecuteResult

FieldTypeRequiredDescription
resultslist[BatchResultItem]AlwaysOne item per entity in request order. Each has entity, value, status ('ok'|'error'), error?.
succeededintAlwaysCount of successfully evaluated entities.
failedintAlwaysCount of failed entities.

Response Codes

StatusDescription
200Always 200. Inspect results[].status per entity.
400Validation error on the batch request itself.
401Unauthorised.
404Concept not found.
429Rate limit.

Execute Time Range

POST /execute/range

Evaluates a concept at each point in a time range for a single entity. Produces a time-ordered array of Result objects. All results use deterministic (timestamped) execution — result.deterministic is always True.

Request — ExecuteRangeRequest

FieldTypeRequiredDescription
idstrRequiredFully qualified concept id.
versionstrRequiredExplicit version.
entitystrRequiredEntity to evaluate across the time range.
startstrRequiredRange start timestamp (ISO 8601 UTC, inclusive).
endstrRequiredRange end timestamp (ISO 8601 UTC, inclusive).
intervalstrOptionalEvaluation interval. Examples: '1d', '1h', '7d'. Defaults to daily.
missing_data_policystrOptional'null' | 'zero' | 'forward_fill' | 'backward_fill'.

Response Codes

StatusDescription
200Time-ordered list[Result]. All have deterministic=True.
400Validation error.
401Unauthorised.
404Not found.
408Timeout — use POST /execute/async for large ranges.
422Execution error.
429Rate limit.

Execute Async

POST /execute/async

Submits a concept execution as an async job. Returns HTTP 202 immediately with a Job object. Poll GET /jobs/{job_id} for status and result. Cancel with DELETE /jobs/{job_id}. Use for workloads expected to exceed 30 seconds.

Request: Same schema as POST /execute (ExecuteRequest).

Response — Job

FieldTypeRequiredDescription
job_idstrAlwaysUnique job identifier.
statusstrAlways'queued' | 'running' | 'completed' | 'failed' | 'cancelled'.
poll_interval_secondsintOptionalSuggested polling interval in seconds.

Response Codes

StatusDescription
202Job accepted. Poll /jobs/{job_id} for result.
400Validation error.
401Unauthorised.
404Concept not found.
429Rate limit.

Get Async Job

GET /jobs/{job_id}

Polls a job for its current status and result.

Path Parameters

FieldTypeRequiredDescription
job_idstrRequiredjob_id returned by POST /execute/async.

Response — JobResult

FieldTypeRequiredDescription
job_idstrAlwaysJob identifier.
statusstrAlways'queued' | 'running' | 'completed' | 'failed' | 'cancelled'.
resultResultOptionalPopulated when status='completed'.
errordictOptionalPopulated when status='failed'. Has type, message, location.

Response Codes

StatusDescription
200JobResult.
401Unauthorised.
404Job not found.

Cancel Async Job

DELETE /jobs/{job_id}

Cancels a job in 'queued' or 'running' state. Returns HTTP 409 if the job has already completed or failed.

Response Codes

StatusDescription
200Job cancelled. Returns final JobResult with status='cancelled'.
401Unauthorised.
404Job not found.
409Cannot cancel — job already completed or failed.