"use client"; import { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import Card from "@/shared/components/Card"; import PricingModal from "@/shared/components/PricingModal"; export default function PricingSettingsPage() { const router = useRouter(); const [showModal, setShowModal] = useState(false); const [currentPricing, setCurrentPricing] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { loadPricing(); }, []); const loadPricing = async () => { setLoading(true); try { const response = await fetch("/api/pricing"); if (response.ok) { const data = await response.json(); setCurrentPricing(data); } } catch (error) { console.error("Failed to load pricing:", error); } finally { setLoading(false); } }; const handlePricingUpdated = () => { loadPricing(); }; // Count total models with pricing const getModelCount = () => { if (!currentPricing) return 0; let count = 0; for (const provider in currentPricing) { count += Object.keys(currentPricing[provider]).length; } return count; }; // Get providers list const getProviders = () => { if (!currentPricing) return []; return Object.keys(currentPricing).sort(); }; return (
Configure pricing rates for cost tracking and calculations
Cost Calculation: Costs are calculated based on token usage and pricing rates. Each request's cost is determined by: (input_tokens × input_rate) + (output_tokens × output_rate) + (cached_tokens × cached_rate)
Pricing Format: All rates are in dollars per million tokens ($/1M tokens). Example: An input rate of 2.50 means $2.50 per 1,000,000 input tokens.
Token Types:
Custom Pricing: You can override default pricing for specific models. Reset to defaults anytime to restore standard rates.