Components / AI Dashboards

AI Request Log

A real-time scrolling log of AI API requests with status indicators, response times, and token counts.

Live Preview — ai-request-log-01

Real-time API Logs

Live
12:04:22200POST/v1/chat/completions842ms
12:04:15200GET/v1/models124ms
12:03:58200POST/v1/embeddings245ms
12:03:42429POST/v1/chat/completions12ms
12:03:10200POST/v1/images/generations4.2s

Installation

Dependencies

Install the core libraries required for this component.

npm
npm install react lucide-react

Source Code

ai-request-log-01.tsx
"use client";

import React, { useState, useEffect } from "react";
import { CheckCircle2, AlertCircle, Clock } from "lucide-react";

interface Request {
    id: string;
    method: string;
    path: string;
    status: number;
    time: string;
    duration: string;
}

const mockRequests: Request[] = [
    { id: "1", method: "POST", path: "/v1/chat/completions", status: 200, time: "12:04:22", duration: "842ms" },
    { id: "2", method: "GET", path: "/v1/models", status: 200, time: "12:04:15", duration: "124ms" },
    { id: "3", method: "POST", path: "/v1/embeddings", status: 200, time: "12:03:58", duration: "245ms" },
    { id: "4", method: "POST", path: "/v1/chat/completions", status: 429, time: "12:03:42", duration: "12ms" },
    { id: "5", method: "POST", path: "/v1/images/generations", status: 200, time: "12:03:10", duration: "4.2s" },
];

export default function AIRequestLog() {
    return (
        <div className="rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-950 shadow-sm w-full max-w-2xl mx-auto overflow-hidden">
            <div className="px-4 py-3 border-b border-zinc-200 dark:border-zinc-800 flex items-center justify-between bg-zinc-50 dark:bg-zinc-900">
                <h3 className="text-xs font-bold uppercase tracking-wider text-zinc-500">Real-time API Logs</h3>
                <span className="flex items-center gap-1.5 text-[10px] font-medium text-emerald-500">
                    <span className="h-1.5 w-1.5 rounded-full bg-emerald-500 animate-pulse" />
                    Live
                </span>
            </div>
            <div className="divide-y divide-zinc-200 dark:divide-zinc-800 font-mono text-[11px]">
                {mockRequests.map((req) => (
                    <div key={req.id} className="flex items-center gap-4 px-4 py-2.5 hover:bg-zinc-50/50 dark:hover:bg-zinc-900/50 transition-colors">
                        <span className="text-zinc-400 w-14 shrink-0">{req.time}</span>
                        <span className={`w-10 font-bold ${req.status === 200 ? "text-emerald-500" : "text-red-500"}`}>{req.status}</span>
                        <span className="text-blue-500 font-bold w-10 shrink-0">{req.method}</span>
                        <span className="text-zinc-900 dark:text-zinc-100 truncate flex-1">{req.path}</span>
                        <span className="text-zinc-400 w-16 text-right shrink-0">{req.duration}</span>
                    </div>
                ))}
            </div>
        </div>
    );
}

Type Reference

Types and interfaces defined in this component.

Request
interface Request {
    id: string;
    method: string;
    path: string;
    status: number;
    time: string;
    duration: string;
}

Functional Logic

Internal functions used to handle component logic.

Function Parameters
AIRequestLog() None

JSX Tags Usage

Every JSX/HTML tag used in this component, with usage count and source.

Tag Count Type Source
<div> Native Native HTML
<h3> Native Native HTML
<span> Native Native HTML

Related Components

  • AI Analytics Card — A dashboard analytics card showing AI model usage metrics with sparkline charts, percentage changes, and trend indicators.
  • AI Token Usage Meter — A circular progress meter showing AI token consumption with remaining quota and cost estimation.
  • AI Model Performance Table — A comparison table showing AI model performance benchmarks with sortable columns for speed, accuracy, and cost.
  • AI Cost Breakdown Chart — A visual cost breakdown showing AI spending by model with horizontal bar charts and total cost summary.
  • AI Service Status Badge — An AI service status indicator showing operational health with animated pulse dots and uptime percentages.
  • AI Activity Feed — A timestamped activity feed showing recent AI interactions, model changes, and system events with icon indicators.