create table if not exists ai_session
(
    id            uuid                     not null
        primary key,
    room          uuid                     not null,
    model         uuid                     not null,
    version       uuid                     not null,
    token_input   bigint default 0         not null,
    token_output  bigint default 0         not null,
    latency_ms    bigint,
    cost          double precision,
    currency      varchar(255),
    error_message text,
    error_code    varchar(255),
    created_at    timestamp with time zone not null
);

create index if not exists idx_ai_session_room
    on ai_session (room);
