B11 - Cost Reconciliation
| Group | Technology | Status | Service | Roadmap phase | Contracts |
|---|---|---|---|---|---|
| B - LLM management and Model Gateway | Developed | to develop | finops | 6 | usage-event |
Role and responsibilities
Reconciles estimated, measured and billed costs from provider invoices and exports.
Data model
Tables (schema eai, every tenant table carries tenant_id uuid NOT NULL with an RLS policy on current_setting('app.tenant_id', true)::uuid): eai.usage_events, eai.price_cards, eai.fx_rates, eai.recon_imports, eai.audit_events.
API endpoints
POST /v1/finops/reconciliation/importsGET /v1/finops/reconciliation/importsPOST /v1/finops/reconciliation/runGET /v1/finops/reconciliation/report
POST /v1/finops/reconciliation/imports HTTP/1.1
Host: <control-plane-host>
X-API-Key: eai_xxx_secret
Accept-Language: en
Content-Type: application/json
{"source": "generic_csv", "filename": "invoice-2025-05.csv", "mapping": {"date": "date", "amount": "cost", "provider": "provider", "model": "model", "currency": "currency"}, "content": "date,provider,model,cost,currency\n2025-05-01,openai,gpt-4o,12.50,USD\n2025-05-02,openai,gpt-4o,8.10,USD\n"}
{"id": "3a5d36bc-b8c9-491e-a829-c340e4ae749f", "source": "generic_csv", "provider": null, "filename": "invoice-2025-05.csv", "line_count": 2, "total": {"amount": "20.6", "currency": "USD"}, "period_start": "2025-05-01", "period_end": "2025-05-02", "created_at": "2026-10-30T02:38:04.108259+01:00"}
Errors use the common envelope {"error": {"code", "message", "message_i18n", "details", "request_id"}}; lists are paginated with limit and cursor.
SDK usage
Python (enterprise_ai):
from enterprise_ai import EnterpriseAI
client = EnterpriseAI(base_url="<control-plane-url>", api_key="eai_xxx_secret")
items = client.finops.list_price_cards()
TypeScript (@enterprise-ai/sdk):
import { EnterpriseAI } from "@enterprise-ai/sdk";
const eai = new EnterpriseAI({ baseUrl: "<control-plane-url>", apiKey: process.env.EAI_API_KEY });
const items = await eai.finops.priceCards.list();
Java (enterprise-ai-java):
EnterpriseAIClient client = EnterpriseAIClient.builder()
.baseUrl("<control-plane-url>")
.apiKey(System.getenv("EAI_API_KEY"))
.build();
var items = client.finops().listPriceCards();
Go (enterprise-ai-go):
client, _ := eai.NewClient(eai.WithBaseURL("<control-plane-url>"), eai.WithAPIKey(os.Getenv("EAI_API_KEY")))
items, err := client.FinOps.ListPriceCards(ctx)
Configuration
- Environment:
EAI_DATABASE_URL,EAI_OTEL_EXPORTER_OTLP_ENDPOINT. - Helm values:
controlPlane.enabled,controlPlane.replicas,controlPlane.resources,controlPlane.config.
Security controls
- Authentication by OIDC JWT, tenant API key with scopes, or SPIFFE mTLS; tenant resolved from the credential, never from the body.
- Authorization through OpenFGA and OPA decisions; every mutation and decision writes a hash-chained
eai.audit_eventsrow. - Secrets never returned by the API; TLS everywhere; Cilium network policies restrict who can reach the service.
Observability
- Metrics:
eai_cost_reconciliation_requests_total,eai_cost_reconciliation_errors_total,eai_cost_reconciliation_latency_seconds(Prometheus). - Traces: OpenTelemetry spans
eai.finops.*with W3Ctraceparentpropagation, AI spans forwarded to Opik. - Audit actions:
finops.price_card.create,finops.price_card.retire,finops.reconciliation.run,policy.evaluate.
FinOps aspects
Lifecycle: estimated (before call) -> measured (Usage Event) -> billed (provider invoice import: openai, anthropic, aws_cur, azure, gcp, generic_csv). The report shows variance and raises alerts above threshold.
Failure modes and resilience
- Stateless replicas behind the API Gateway, PostgreSQL HA for state; readiness probe
GET /readyzremoves unhealthy pods. - External system unavailable: fail closed for security decisions, explicit error code, no silent bypass.
Standalone adoption (client of a client)
A client of a client can adopt this brick alone with the Python SDK sub-client client.finops (TS eai.finops, Java client.finops(), Go client.FinOps). Minimal deployment: Control Plane API + PostgreSQL + Keycloak (or API keys), the Control Plane loads every domain of services/control-plane/src/eai/domains; the optional chart components are switched off in deploy/helm/enterprise-ai/values.yaml (vllm.enabled, qdrant.enabled, nats.enabled, workers.enabled).
Acceptance tests
- A tenant cannot read or modify another tenant's resources (RLS test).
- Every mutation produces an audit event verifiable by
GET /v1/audit/verify. - Errors are returned in English and French according to
Accept-Language.
Unavailable costs (LLM_-011)
A media cost without a known price stays unavailable: the estimate total is then null and complete: false, so the reconciliation never compares an invented zero with an invoice.