Skip to content
GigadriveDocs

Request logs

What the AI Gateway records about every request, what it never records, and how long entries stay.

Every call through the AI Gateway leaves one row: who made it, which model was asked for, which provider answered, how many tokens it used and what it cost. Use it to explain a bill, to find the request behind an error, or to see which provider a fallback landed on.

What is recorded

FieldMeaning
requestIdThe value returned in X-Gigadrive-Request-Id
traceIdYour own correlation id, from X-Gigadrive-Trace-Id
statuspending, success, error or cancelled
modelRequested / modelServedWhat you asked for, and what actually answered
providerThe route that served it
providerAttemptsEvery route tried, with the error and status code of the ones that failed
errorCode / errorTypeSet when the request failed
inputTokens, outputTokens, cachedInputTokens, totalTokensToken counts
usageSourceprovider when the upstream reported usage, none when it did not
billableCostMicrosWhat you are charged, in EUR micros
latencyMsEnd to end, in milliseconds
streamingWhether the response was streamed
applicationId, authenticatedUserId, apiKeyId, callerEndUserIdWho the request is attributed to
startedAt, completedAtTimestamps

callerEndUserId is yours to set, through the X-Gigadrive-End-User-Id header or the OpenAI-standard user body field, which wins when both are present. It is the only way to attribute a request to one of your own end users, and it is capped at 255 characters.

What is not recorded

We do not retain AI Gateway request bodies. Prompts, messages, uploaded images and audio, tool definitions and the model's completion are never written to the log. The row carries counts and identifiers only.

Two things are exceptions, and both are yours: the callerEndUserId label, and the metadata map on /ai/v1/responses and /ai/v1/videos, which is stored verbatim. Put no secrets in either.

Requests recorded as cancelled are the ones where a client disconnected mid-stream. They are logged for completeness and count toward nothing: no budget, no bill.

Finding a request

Filters are shared by the log endpoint and the CSV export: from, to, applicationId, model, provider, status, requestId, authenticatedUserId, callerEndUserId and limit, which accepts 1 to 500 and defaults to 100.

import { GigadriveClient } from '@gigadrive/sdk';

const client = new GigadriveClient({
  clientId: process.env.GIGADRIVE_CLIENT_ID,
  clientSecret: process.env.GIGADRIVE_CLIENT_SECRET,
});

const organizationId = '0197b2f0-8b6d-7c2a-9f4e-111111111111';

const { items } = await client.organizations.aiGateway.usage.requests(organizationId, {
  status: 'error',
  from: '2026-08-01T00:00:00.000Z',
  limit: 100,
});

for (const event of items) {
  console.log(event.requestId, event.modelRequested, event.errorCode, event.providerAttempts);
}

const csv = await client.organizations.aiGateway.usage.export(organizationId, {
  applicationId: '0195c11c-0000-7000-8000-000000000042',
});

Reading logs needs the network:ai_gateway:usage:read scope, which a gigadrive login session does not carry: give the CLI an organization API key through GIGADRIVE_CLIENT_ID and GIGADRIVE_CLIENT_SECRET.

The export returns requestId, startedAt, status, applicationId, authenticatedUserId, callerEndUserId, modelRequested, modelServed, provider, token counts, billableCostMicros and latencyMs, and defaults to 500 rows when you give no limit.

In the console, /[org]/ai-gateway/logs streams the same rows with filters for status, model and provider and an export button. The same page inside an application shows only that application's requests. A request with no signed-in user and no end-user label appears as "Machine actor".

How long entries stay

No retention window trims the AI Gateway log, so an export reaches back to your first request.

Two deletions do remove data. Deleting the organization deletes its gateway request records with it. Deleting an application clears the application reference on its entries, which stay under the organization with no application attached.