{"openapi":"3.1.0","info":{"title":"leCore Agent Memory & Routing API","description":"Hosted, tenant-scoped agent memory, capability routing, and\nreadiness data over HTTPS, with x402 payment on each protected request.\n\n## Request flow\n\n1. Read `GET /pricing` for the network, asset, price, and protected-route manifest.\n2. Call a protected `/v1/*` route. An unsigned request returns `402 Payment Required`.\n3. Decode the `Payment-Required` response header with an x402 v2 client.\n4. Sign the selected payment option and retry with the resulting `Payment-Signature` header.\n5. Decode the successful `Payment-Response` header for settlement details.\n\nThe interactive reference describes the contract but does not sign payments. See the\n[x402 buyer quickstart](https://docs.x402.org/getting-started/quickstart-for-buyers)\nfor wallet and client setup.\n`GET /health`, `GET /pricing`, `/docs`, `/redoc`, and `/openapi.json`\nare free. Private tenant calls additionally require `X-leCore-Tenant` and\n`X-leCore-Tenant-Token`; payment proves payment, not tenant authorization.\n","version":"0.2.10"},"servers":[{"url":"https://lecore.rati.foundation","description":"Public API"}],"paths":{"/health":{"get":{"tags":["Discovery"],"summary":"Check service health","description":"Free liveness, memory-state, backend, and tenancy summary. No x402 payment is required.","operationId":"getHealth","responses":{"200":{"description":"Service health and deployment state returned.","content":{"application/json":{"schema":{"properties":{"ok":{"type":"boolean","const":true},"name":{"type":"string"},"paid":{"type":"boolean"},"memory":{"properties":{"entries":{"type":"integer","minimum":0.0},"dim":{"type":"integer","minimum":1.0},"index_method":{"anyOf":[{"type":"string"},{"type":"null"}]},"query_mutates_store":{"type":"boolean"}},"additionalProperties":false,"type":"object","required":["entries","dim","index_method","query_mutates_store"]},"memory_backend":{"properties":{"backend":{"type":"string","enum":["core","nosqlite"]},"nosqlite_shadow":{"type":"boolean"},"nosqlite_configured":{"type":"boolean"},"durable_transactions":{"type":"boolean"}},"additionalProperties":false,"type":"object","required":["backend","nosqlite_shadow","nosqlite_configured","durable_transactions"]},"tenancy":{"properties":{"default_tenant":{"type":"string"},"loaded_tenants":{"type":"integer","minimum":1.0},"private_tenants_enabled":{"type":"boolean"}},"additionalProperties":false,"type":"object","required":["default_tenant","loaded_tenants","private_tenants_enabled"]}},"additionalProperties":false,"type":"object","required":["ok","name","paid","memory","memory_backend","tenancy"],"title":"Response Gethealth"},"example":{"ok":true,"name":"leCore Agent Memory & Routing API","paid":true,"memory":{"entries":3,"dim":512,"index_method":"exact","query_mutates_store":false},"memory_backend":{"backend":"core","nosqlite_shadow":false,"nosqlite_configured":false,"durable_transactions":true},"tenancy":{"default_tenant":"public","loaded_tenants":1,"private_tenants_enabled":true}}}}}}}},"/pricing":{"get":{"tags":["Discovery"],"summary":"Discover pricing and protected routes","description":"Free discovery document for the x402 network, payment asset, price, tenant headers, documentation URLs, and protected-route manifest.","operationId":"getPricing","responses":{"200":{"description":"Pricing and x402 discovery manifest returned.","content":{"application/json":{"schema":{"properties":{"ok":{"type":"boolean","const":true},"documentation":{"properties":{"swagger_ui":{"type":"string","format":"uri"},"reference":{"type":"string","format":"uri"},"openapi_schema":{"type":"string","format":"uri"}},"additionalProperties":false,"type":"object","required":["swagger_ui","reference","openapi_schema"]},"x402":{"properties":{"pay_to":{"type":"string"},"price":{"type":"string"},"network":{"type":"string"},"facilitator_url":{"type":"string","format":"uri"},"scheme":{"type":"string"},"public_url":{"type":"string","format":"uri"}},"additionalProperties":false,"type":"object","required":["pay_to","price","network","facilitator_url","scheme","public_url"]},"pricing":{"additionalProperties":{"type":"string"},"type":"object"},"tenancy":{"properties":{"default_tenant":{"type":"string"},"tenant_header":{"type":"string"},"tenant_token_header":{"type":"string"},"private_tenants_enabled":{"type":"boolean"}},"additionalProperties":false,"type":"object","required":["default_tenant","tenant_header","tenant_token_header","private_tenants_enabled"]},"memory_backend":{"properties":{"backend":{"type":"string","enum":["core","nosqlite"]},"nosqlite_shadow":{"type":"boolean"},"nosqlite_configured":{"type":"boolean"},"durable_transactions":{"type":"boolean"}},"additionalProperties":false,"type":"object","required":["backend","nosqlite_shadow","nosqlite_configured","durable_transactions"]},"routes":{"items":{"properties":{"route":{"type":"string"},"description":{"type":"string"},"mime_type":{"type":"string"},"accepts":{"items":{"properties":{"scheme":{"type":"string"},"price":{"type":"string"},"network":{"type":"string"},"pay_to":{"type":"string"}},"additionalProperties":false,"type":"object","required":["scheme","price","network","pay_to"]},"type":"array"}},"additionalProperties":false,"type":"object","required":["route","description","mime_type","accepts"]},"type":"array"}},"additionalProperties":false,"type":"object","required":["ok","documentation","x402","pricing","tenancy","memory_backend","routes"],"title":"Response Getpricing"},"example":{"ok":true,"documentation":{"swagger_ui":"https://lecore.rati.foundation/docs","reference":"https://lecore.rati.foundation/redoc","openapi_schema":"https://lecore.rati.foundation/openapi.json"},"x402":{"pay_to":"0x96e1604E92A8A1edD0701be3E67Bd4366e87BB84","price":"$0.0011","network":"eip155:84532","facilitator_url":"https://x402.org/facilitator","scheme":"exact","public_url":"https://lecore.rati.foundation"},"pricing":{"environment":"testnet_preview","environment_label":"Testnet developer preview","payment_asset":"testnet USDC","per_request":"$0.0011","per_1000_requests":"$1.10","display_price":"$1.10 per 1,000 requests","payment_notice":"This Base Sepolia developer preview uses testnet USDC and does not accept production payments."},"tenancy":{"default_tenant":"public","tenant_header":"X-leCore-Tenant","tenant_token_header":"X-leCore-Tenant-Token","private_tenants_enabled":true},"memory_backend":{"backend":"core","nosqlite_shadow":false,"nosqlite_configured":false,"durable_transactions":true},"routes":[{"route":"POST /v1/recall","description":"Recall nearest memories from tenant-scoped agent memory","mime_type":"application/json","accepts":[{"scheme":"exact","price":"$0.0011","network":"eip155:84532","pay_to":"0x96e1604E92A8A1edD0701be3E67Bd4366e87BB84"}]},{"route":"POST /v1/route","description":"Route a plain-English task to a leCore capability","mime_type":"application/json","accepts":[{"scheme":"exact","price":"$0.0011","network":"eip155:84532","pay_to":"0x96e1604E92A8A1edD0701be3E67Bd4366e87BB84"}]},{"route":"GET /v1/dashboard","description":"Read the service readiness dashboard","mime_type":"application/json","accepts":[{"scheme":"exact","price":"$0.0011","network":"eip155:84532","pay_to":"0x96e1604E92A8A1edD0701be3E67Bd4366e87BB84"}]}]}}}}}}},"/v1/recall":{"post":{"tags":["Paid API"],"summary":"Recall agent memory","description":"Recall the nearest entries from tenant-scoped agent memory. An unsigned request returns the x402 challenge documented in the 402 response.","operationId":"recallMemory","parameters":[{"name":"X-leCore-Tenant","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Tenant id, trimmed and lowercased by the service. Omit for the public tenant.","title":"X-Lecore-Tenant"},"description":"Tenant id, trimmed and lowercased by the service. Omit for the public tenant."},{"name":"X-leCore-Tenant-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Required whenever the resolved tenant is private, whether selected by header or JSON body.","title":"X-Lecore-Tenant-Token"},"description":"Required whenever the resolved tenant is private, whether selected by header or JSON body."},{"name":"Payment-Signature","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Omit to receive the x402 challenge; include the base64 x402 v2 payment payload when retrying.","format":"byte","title":"Payment-Signature"},"description":"Omit to receive the x402 challenge; include the base64 x402 v2 payment payload when retrying."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Payload","required":["query"],"properties":{"query":{"type":"string","minLength":1,"maxLength":8192,"pattern":"\\S","description":"Text to match against stored agent memory."},"k":{"type":"integer","minimum":1,"maximum":100,"default":3,"description":"Maximum number of memories to return."},"abstain":{"anyOf":[{"type":"number","minimum":0,"maximum":1},{"type":"null"}],"description":"Optional minimum similarity score."},"tenant":{"type":"string","description":"Tenant id. Leading/trailing whitespace is removed and letters are lowercased; the normalized id must match X-leCore-Tenant when both are supplied."}}},"examples":{"public":{"summary":"Recall public-tenant memory","value":{"query":"deterministic agent memory","k":3}}}}}},"responses":{"200":{"description":"Memory recall completed.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"title":"Response Recallmemory","required":["ok","tenant","query","hits"],"properties":{"ok":{"type":"boolean","const":true},"tenant":{"type":"string"},"query":{"type":"string"},"hits":{"type":"array","items":{"type":"object","required":["id","text","label","metadata","score"],"properties":{"id":{"type":"string"},"text":{"type":"string"},"label":{"anyOf":[{"type":"string"},{"type":"null"}]},"metadata":{"type":"object","additionalProperties":true},"score":{"type":"number"}},"additionalProperties":false}}}},"example":{"ok":true,"tenant":"public","query":"deterministic memory","hits":[{"id":"m2","text":"Prefer explicit capability routing when confidence is low.","label":"routing","metadata":{"source":"public-preview"},"score":0.82}]}}},"headers":{"Payment-Response":{"description":"Base64-encoded x402 v2 settlement response.","schema":{"type":"string","format":"byte"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"query must be a non-empty string"}}}},"401":{"description":"Private-tenant authorization failed.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"invalid tenant token"}}}},"403":{"description":"The deployment cannot authorize the selected private tenant.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"private tenants require LECORE_X402_TENANT_SECRET"}}}},"502":{"description":"The x402 facilitator could not verify or settle the payment.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}},"additionalProperties":true},"example":{"error":"Payment verification failed"}}}},"402":{"description":"Payment required or settlement failed. An unsigned or invalid-payment request includes Payment-Required; a paid request whose settlement fails can instead include Payment-Response.","headers":{"Payment-Required":{"description":"Base64-encoded x402 v2 PaymentRequired challenge, present for unsigned or invalid-payment requests.","schema":{"type":"string","format":"byte"}},"Payment-Response":{"description":"Base64-encoded x402 v2 settlement response, present when a paid request reaches the handler but settlement fails.","schema":{"type":"string","format":"byte"}}},"content":{"application/json":{"schema":{"type":"object","maxProperties":0},"example":{}},"text/html":{"schema":{"type":"string"},"example":"<!doctype html><title>Payment Required</title>"}}},"503":{"description":"The configured memory backend is temporarily unavailable.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"NoSQLite memory backend is unavailable"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/route":{"post":{"tags":["Paid API"],"summary":"Route a task to a capability","description":"Route a plain-English task to the best matching leCore capability. An unsigned request returns the x402 challenge documented in the 402 response.","operationId":"routeTask","parameters":[{"name":"X-leCore-Tenant","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Tenant id, trimmed and lowercased by the service. Omit for the public tenant.","title":"X-Lecore-Tenant"},"description":"Tenant id, trimmed and lowercased by the service. Omit for the public tenant."},{"name":"X-leCore-Tenant-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Required whenever the resolved tenant is private, whether selected by header or JSON body.","title":"X-Lecore-Tenant-Token"},"description":"Required whenever the resolved tenant is private, whether selected by header or JSON body."},{"name":"Payment-Signature","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Omit to receive the x402 challenge; include the base64 x402 v2 payment payload when retrying.","format":"byte","title":"Payment-Signature"},"description":"Omit to receive the x402 challenge; include the base64 x402 v2 payment payload when retrying."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Payload","required":["task"],"properties":{"task":{"type":"string","minLength":1,"maxLength":8192,"pattern":"\\S","description":"Plain-English task to route."},"tenant":{"type":"string","description":"Tenant id. Leading/trailing whitespace is removed and letters are lowercased; the normalized id must match X-leCore-Tenant when both are supplied."}}},"examples":{"public":{"summary":"Route a memory-related task","value":{"task":"find the best capability for semantic memory retrieval"}}}}}},"responses":{"200":{"description":"Capability routing completed.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"title":"Response Routetask","required":["ok","tenant","route"],"properties":{"ok":{"type":"boolean","const":true},"tenant":{"type":"string"},"route":{"type":"object","required":["task","decision","confidence"],"properties":{"task":{"type":"string"},"decision":{"type":"string","enum":["act","choose","unknown"]},"confidence":{"type":"number","minimum":0,"maximum":1},"prompt":{"type":"string"},"skill":{"type":"object","required":["name","does","call"],"properties":{"name":{"type":"string"},"does":{"type":"string"},"call":{"type":"string"}},"additionalProperties":false},"options":{"type":"array","items":{"type":"object","required":["name","does","call"],"properties":{"name":{"type":"string"},"does":{"type":"string"},"call":{"type":"string"}},"additionalProperties":false}}},"additionalProperties":true}}},"example":{"ok":true,"tenant":"public","route":{"task":"search a large vector collection","decision":"act","confidence":0.91,"skill":{"name":"Index (search)","does":"Search a vector index for nearest entries.","call":"index.nearest(query, k=5)"}}}}},"headers":{"Payment-Response":{"description":"Base64-encoded x402 v2 settlement response.","schema":{"type":"string","format":"byte"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"task must be a non-empty string"}}}},"401":{"description":"Private-tenant authorization failed.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"invalid tenant token"}}}},"403":{"description":"The deployment cannot authorize the selected private tenant.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"private tenants require LECORE_X402_TENANT_SECRET"}}}},"502":{"description":"The x402 facilitator could not verify or settle the payment.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}},"additionalProperties":true},"example":{"error":"Payment verification failed"}}}},"402":{"description":"Payment required or settlement failed. An unsigned or invalid-payment request includes Payment-Required; a paid request whose settlement fails can instead include Payment-Response.","headers":{"Payment-Required":{"description":"Base64-encoded x402 v2 PaymentRequired challenge, present for unsigned or invalid-payment requests.","schema":{"type":"string","format":"byte"}},"Payment-Response":{"description":"Base64-encoded x402 v2 settlement response, present when a paid request reaches the handler but settlement fails.","schema":{"type":"string","format":"byte"}}},"content":{"application/json":{"schema":{"type":"object","maxProperties":0},"example":{}},"text/html":{"schema":{"type":"string"},"example":"<!doctype html><title>Payment Required</title>"}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/dashboard":{"get":{"tags":["Paid API"],"summary":"Read the readiness dashboard","description":"Read memory, routing, native-kernel, and deterministic-engine readiness for one tenant. An unsigned request returns the documented x402 challenge.","operationId":"getDashboard","parameters":[{"name":"X-leCore-Tenant","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Tenant id, trimmed and lowercased by the service. Omit for the public tenant.","title":"X-Lecore-Tenant"},"description":"Tenant id, trimmed and lowercased by the service. Omit for the public tenant."},{"name":"X-leCore-Tenant-Token","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Required whenever the resolved tenant is private.","title":"X-Lecore-Tenant-Token"},"description":"Required whenever the resolved tenant is private."},{"name":"Payment-Signature","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Omit to receive the x402 challenge; include the base64 x402 v2 payment payload when retrying.","format":"byte","title":"Payment-Signature"},"description":"Omit to receive the x402 challenge; include the base64 x402 v2 payment payload when retrying."}],"responses":{"200":{"description":"Readiness dashboard returned.","content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"title":"Response Getdashboard","required":["ok","tenant","dashboard"],"properties":{"ok":{"type":"boolean","const":true},"tenant":{"type":"string"},"dashboard":{"type":"object","required":["name","status","memory","routing","c_kernel","checks"],"properties":{"name":{"type":"string"},"status":{"type":"string","enum":["ready","check"]},"memory":{"type":"object","required":["entries","dim","index_method","query_mutates_store"],"properties":{"entries":{"type":"integer","minimum":0},"dim":{"type":"integer","minimum":1},"index_method":{"anyOf":[{"type":"string"},{"type":"null"}]},"query_mutates_store":{"type":"boolean"}},"additionalProperties":false},"routing":{"type":"object","required":["capabilities","probe_decision","probe_skill"],"properties":{"capabilities":{"type":"integer","minimum":0},"probe_decision":{"type":"string"},"probe_skill":{"anyOf":[{"type":"string"},{"type":"null"}]}},"additionalProperties":false},"c_kernel":{"type":"object","additionalProperties":true},"checks":{"type":"object","required":["deterministic_encoding","no_model_weights","self_contained_engine"],"properties":{"deterministic_encoding":{"type":"boolean"},"no_model_weights":{"type":"boolean"},"self_contained_engine":{"type":"boolean"}},"additionalProperties":false}},"additionalProperties":true}}},"example":{"ok":true,"tenant":"public","dashboard":{"name":"leCore Agent Memory & Routing API","status":"ready","memory":{"entries":3,"dim":512,"index_method":"exact","query_mutates_store":false},"routing":{"capabilities":656,"probe_decision":"act","probe_skill":"Index (search)"},"c_kernel":{"available":false},"checks":{"deterministic_encoding":true,"no_model_weights":true,"self_contained_engine":true}}}}},"headers":{"Payment-Response":{"description":"Base64-encoded x402 v2 settlement response.","schema":{"type":"string","format":"byte"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"tenant id is invalid"}}}},"401":{"description":"Private-tenant authorization failed.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"invalid tenant token"}}}},"403":{"description":"The deployment cannot authorize the selected private tenant.","content":{"application/json":{"schema":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}},"additionalProperties":false},"example":{"detail":"private tenants require LECORE_X402_TENANT_SECRET"}}}},"502":{"description":"The x402 facilitator could not verify or settle the payment.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}},"additionalProperties":true},"example":{"error":"Payment verification failed"}}}},"402":{"description":"Payment required or settlement failed. An unsigned or invalid-payment request includes Payment-Required; a paid request whose settlement fails can instead include Payment-Response.","headers":{"Payment-Required":{"description":"Base64-encoded x402 v2 PaymentRequired challenge, present for unsigned or invalid-payment requests.","schema":{"type":"string","format":"byte"}},"Payment-Response":{"description":"Base64-encoded x402 v2 settlement response, present when a paid request reaches the handler but settlement fails.","schema":{"type":"string","format":"byte"}}},"content":{"application/json":{"schema":{"type":"object","maxProperties":0},"example":{}},"text/html":{"schema":{"type":"string"},"example":"<!doctype html><title>Payment Required</title>"}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"tags":[{"name":"Discovery","description":"Free service health, pricing, network, and route discovery."},{"name":"Paid API","description":"Hosted read and compute operations protected by the x402 v2 payment flow."}],"externalDocs":{"description":"x402 buyer quickstart","url":"https://docs.x402.org/getting-started/quickstart-for-buyers"}}