Usage, logs and traces
Join gateway metadata to stored execution records and aggregated metrics.
Gateway chat/embedding responses include normalized metadata and usage. Control-plane logs, traces, observability and providers.health expose inspection/aggregation. You need resource read permissions; there is no SDK billing or general usage-management resource.
Join an execution to its trace
const completion = await nirmos.gateway.chat.create({
route: "production-chat",
messages: [{ role: "user", content: "Say hello." }],
}, { headers: { "Nirmos-UserId": "customer_123", "Nirmos-Property-Feature": "support" } });
console.log(completion.usage, completion.metadata.requestId);
if (completion.metadata.traceId) {
const trace = await nirmos.traces.get(completion.metadata.traceId);
console.log(trace);
}Attribution headers can be supplied through RequestOptions.headers; they are not authentication or organization scope. Never put secrets or sensitive message content in attribution tags. Metadata availability differs by endpoint, deployment CORS exposure and bridge forwarding.
Inspect records
const logs = await nirmos.logs.list({ limit: 25, success: "false" });
const traces = await nirmos.traces.list({ limit: 25, from: "2026-10-01T00:00:00Z" });
console.log(logs.nextCursor, traces.items.length);
const metrics = await nirmos.observability.metrics({
from: "2026-10-01T00:00:00Z", to: "2026-10-02T00:00:00Z",
});
console.log(metrics);Logs and traces use cursor pagination, with filtering by model/provider/application/environment/trace, success and date range. observability.overview and gatewayOverview return different aggregated views. Method reference pages preserve their actual response fields; there is no SDK custom aggregation query language or live event subscription.
Token values omitted by providers normalize to zero in gateway SDK responses. Aggregated metrics are not necessarily a billing ledger. Missing metadata does not prove caching/routing was absent. Some cache flags can be passed as custom headers, and the privacy policy APIs control whether caching is permitted. Semantic response caching is not implemented.
Handle 404 for unavailable records, 403 for permissions and service errors normally. See logs, traces, observability and REST observability.
Use the public completion.metadata.requestId with logs.get() and Evaluation trace import. Persistence is asynchronous; a returned ID does not guarantee retained payloads. Trace IDs remain correlation groups.
Usage metadata is separate from optional body content. Body logging defaults off, has independent input/output sampling and retention, and applies mandatory secret redaction plus configured paths. Request-level restrictions can disable capture. Arbitrary attribution fields are not copied into persisted usage rows. Identifiers and operational metadata can still be personal data. See privacy controls.