diff --git a/.replit b/.replit index 1d0e50d..93bbbf0 100644 --- a/.replit +++ b/.replit @@ -26,3 +26,7 @@ externalPort = 8080 [[ports]] localPort = 8081 externalPort = 80 + +[[ports]] +localPort = 24927 +externalPort = 3000 diff --git a/artifacts/api-portal/.replit-artifact/artifact.toml b/artifacts/api-portal/.replit-artifact/artifact.toml new file mode 100644 index 0000000..eb37d66 --- /dev/null +++ b/artifacts/api-portal/.replit-artifact/artifact.toml @@ -0,0 +1,31 @@ +kind = "web" +previewPath = "/" +title = "API Portal" +version = "1.0.0" +id = "artifacts/api-portal" +router = "path" + +[[integratedSkills]] +name = "react-vite" +version = "1.0.0" + +[[services]] +name = "web" +paths = [ "/" ] +localPort = 24927 + +[services.development] +run = "pnpm --filter @workspace/api-portal run dev" + +[services.production] +build = [ "pnpm", "--filter", "@workspace/api-portal", "run", "build" ] +publicDir = "artifacts/api-portal/dist/public" +serve = "static" + +[[services.production.rewrites]] +from = "/*" +to = "/index.html" + +[services.env] +PORT = "24927" +BASE_PATH = "/" diff --git a/artifacts/api-portal/components.json b/artifacts/api-portal/components.json new file mode 100644 index 0000000..3ff62cf --- /dev/null +++ b/artifacts/api-portal/components.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "new-york", + "rsc": false, + "tsx": true, + "tailwind": { + "config": "", + "css": "src/index.css", + "baseColor": "neutral", + "cssVariables": true, + "prefix": "" + }, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils", + "ui": "@/components/ui", + "lib": "@/lib", + "hooks": "@/hooks" + } +} \ No newline at end of file diff --git a/artifacts/api-portal/index.html b/artifacts/api-portal/index.html new file mode 100644 index 0000000..35cc6b3 --- /dev/null +++ b/artifacts/api-portal/index.html @@ -0,0 +1,16 @@ + + + + + + API Portal + + + + + + +
+ + + diff --git a/artifacts/api-portal/package.json b/artifacts/api-portal/package.json new file mode 100644 index 0000000..4a095e3 --- /dev/null +++ b/artifacts/api-portal/package.json @@ -0,0 +1,77 @@ +{ + "name": "@workspace/api-portal", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "vite --config vite.config.ts --host 0.0.0.0", + "build": "vite build --config vite.config.ts", + "serve": "vite preview --config vite.config.ts --host 0.0.0.0", + "typecheck": "tsc -p tsconfig.json --noEmit" + }, + "devDependencies": { + "@hookform/resolvers": "^3.10.0", + "@radix-ui/react-accordion": "^1.2.4", + "@radix-ui/react-alert-dialog": "^1.1.7", + "@radix-ui/react-aspect-ratio": "^1.1.3", + "@radix-ui/react-avatar": "^1.1.4", + "@radix-ui/react-checkbox": "^1.1.5", + "@radix-ui/react-collapsible": "^1.1.4", + "@radix-ui/react-context-menu": "^2.2.7", + "@radix-ui/react-dialog": "^1.1.7", + "@radix-ui/react-dropdown-menu": "^2.1.7", + "@radix-ui/react-hover-card": "^1.1.7", + "@radix-ui/react-label": "^2.1.3", + "@radix-ui/react-menubar": "^1.1.7", + "@radix-ui/react-navigation-menu": "^1.2.6", + "@radix-ui/react-popover": "^1.1.7", + "@radix-ui/react-progress": "^1.1.3", + "@radix-ui/react-radio-group": "^1.2.4", + "@radix-ui/react-scroll-area": "^1.2.4", + "@radix-ui/react-select": "^2.1.7", + "@radix-ui/react-separator": "^1.1.3", + "@radix-ui/react-slider": "^1.2.4", + "@radix-ui/react-slot": "^1.2.0", + "@radix-ui/react-switch": "^1.1.4", + "@radix-ui/react-tabs": "^1.1.4", + "@radix-ui/react-toast": "^1.2.7", + "@radix-ui/react-toggle": "^1.1.3", + "@radix-ui/react-toggle-group": "^1.1.3", + "@radix-ui/react-tooltip": "^1.2.0", + "@replit/vite-plugin-cartographer": "catalog:", + "@replit/vite-plugin-dev-banner": "catalog:", + "@replit/vite-plugin-runtime-error-modal": "catalog:", + "@tailwindcss/typography": "^0.5.15", + "@tailwindcss/vite": "catalog:", + "@tanstack/react-query": "catalog:", + "@types/node": "catalog:", + "@types/react": "catalog:", + "@types/react-dom": "catalog:", + "@vitejs/plugin-react": "catalog:", + "@workspace/api-client-react": "workspace:*", + "class-variance-authority": "catalog:", + "clsx": "catalog:", + "cmdk": "^1.1.1", + "date-fns": "^3.6.0", + "embla-carousel-react": "^8.6.0", + "framer-motion": "catalog:", + "input-otp": "^1.4.2", + "lucide-react": "catalog:", + "next-themes": "^0.4.6", + "react": "catalog:", + "react-day-picker": "^9.11.1", + "react-dom": "catalog:", + "react-hook-form": "^7.55.0", + "react-icons": "^5.4.0", + "react-resizable-panels": "^2.1.7", + "recharts": "^2.15.2", + "sonner": "^2.0.7", + "tailwind-merge": "catalog:", + "tailwindcss": "catalog:", + "tw-animate-css": "^1.4.0", + "vaul": "^1.1.2", + "vite": "catalog:", + "wouter": "^3.3.5", + "zod": "catalog:" + } +} diff --git a/artifacts/api-portal/public/favicon.svg b/artifacts/api-portal/public/favicon.svg new file mode 100644 index 0000000..4373d3c --- /dev/null +++ b/artifacts/api-portal/public/favicon.svg @@ -0,0 +1,3 @@ + + + diff --git a/artifacts/api-portal/public/opengraph.jpg b/artifacts/api-portal/public/opengraph.jpg new file mode 100644 index 0000000..29b2bdd Binary files /dev/null and b/artifacts/api-portal/public/opengraph.jpg differ diff --git a/artifacts/api-portal/src/App.tsx b/artifacts/api-portal/src/App.tsx new file mode 100644 index 0000000..9af061c --- /dev/null +++ b/artifacts/api-portal/src/App.tsx @@ -0,0 +1,208 @@ +import { useEffect, useState } from "react"; +import { Check, Copy, Circle } from "lucide-react"; + +const MODELS: Array<{ id: string; provider: "openai" | "anthropic" }> = [ + { id: "gpt-5.2", provider: "openai" }, + { id: "gpt-5-mini", provider: "openai" }, + { id: "gpt-5-nano", provider: "openai" }, + { id: "o4-mini", provider: "openai" }, + { id: "o3", provider: "openai" }, + { id: "claude-opus-4-6", provider: "anthropic" }, + { id: "claude-sonnet-4-6", provider: "anthropic" }, + { id: "claude-haiku-4-5", provider: "anthropic" }, +]; + +type HealthState = "checking" | "online" | "offline"; + +function CopyButton({ value, label }: { value: string; label?: string }) { + const [copied, setCopied] = useState(false); + return ( + + ); +} + +function FieldRow({ label, value, mono = true }: { label: string; value: string; mono?: boolean }) { + return ( +
+
+
{label}
+ +
+
+ {value} +
+
+ ); +} + +export default function App() { + const [health, setHealth] = useState("checking"); + const baseUrl = window.location.origin; + const modelsUrl = `${baseUrl}/v1/models`; + const chatUrl = `${baseUrl}/v1/chat/completions`; + + useEffect(() => { + let cancelled = false; + const check = async () => { + try { + const res = await fetch(`${baseUrl}/api/healthz`, { cache: "no-store" }); + if (cancelled) return; + setHealth(res.ok ? "online" : "offline"); + } catch { + if (!cancelled) setHealth("offline"); + } + }; + check(); + const t = window.setInterval(check, 10000); + return () => { + cancelled = true; + window.clearInterval(t); + }; + }, [baseUrl]); + + const dotColor = + health === "online" ? "text-emerald-400" : health === "offline" ? "text-rose-400" : "text-slate-500"; + const statusLabel = + health === "online" ? "Online" : health === "offline" ? "Offline" : "Checking…"; + + return ( +
+
+
+
+

API Portal

+

+ OpenAI-compatible reverse proxy for OpenAI and Anthropic models +

+
+
+ + + {statusLabel} + +
+
+ +
+

+ Connection +

+ + + +
+
+ API Key +
+

+ Send your PROXY_API_KEY as a Bearer + token in the{" "} + Authorization header. Configure it in + the project secrets — it is never displayed here. +

+
+{`Authorization: Bearer `}
+            
+
+
+ +
+

+ CherryStudio setup +

+
    +
  1. + + 1 + +
    + Open Settings → Model Providers{" "} + and add a new provider of type{" "} + OpenAI. +
    +
  2. +
  3. + + 2 + +
    + Set API Host / Base URL to{" "} + {baseUrl}. +
    +
  4. +
  5. + + 3 + +
    + Paste your PROXY_API_KEY into the{" "} + API Key field. +
    +
  6. +
  7. + + 4 + +
    + Click Manage Models → enable any + of the models below. CherryStudio will route requests through this proxy + automatically. +
    +
  8. +
+
+ +
+

+ Available models +

+
+ {MODELS.map((m) => ( +
+ {m.id} + + {m.provider === "openai" ? "OpenAI" : "Anthropic"} + +
+ ))} +
+
+ +
+ OpenAI-compatible API · routes gpt* /{" "} + o* models to OpenAI and{" "} + claude* models to Anthropic. +
+
+
+ ); +} diff --git a/artifacts/api-portal/src/components/ui/accordion.tsx b/artifacts/api-portal/src/components/ui/accordion.tsx new file mode 100644 index 0000000..e1797c9 --- /dev/null +++ b/artifacts/api-portal/src/components/ui/accordion.tsx @@ -0,0 +1,55 @@ +import * as React from "react" +import * as AccordionPrimitive from "@radix-ui/react-accordion" +import { ChevronDown } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Accordion = AccordionPrimitive.Root + +const AccordionItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AccordionItem.displayName = "AccordionItem" + +const AccordionTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + svg]:rotate-180", + className + )} + {...props} + > + {children} + + + +)) +AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName + +const AccordionContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + +
{children}
+
+)) +AccordionContent.displayName = AccordionPrimitive.Content.displayName + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/artifacts/api-portal/src/components/ui/alert-dialog.tsx b/artifacts/api-portal/src/components/ui/alert-dialog.tsx new file mode 100644 index 0000000..fa2b442 --- /dev/null +++ b/artifacts/api-portal/src/components/ui/alert-dialog.tsx @@ -0,0 +1,139 @@ +import * as React from "react" +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" + +import { cn } from "@/lib/utils" +import { buttonVariants } from "@/components/ui/button" + +const AlertDialog = AlertDialogPrimitive.Root + +const AlertDialogTrigger = AlertDialogPrimitive.Trigger + +const AlertDialogPortal = AlertDialogPrimitive.Portal + +const AlertDialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName + +const AlertDialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + +)) +AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName + +const AlertDialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +AlertDialogHeader.displayName = "AlertDialogHeader" + +const AlertDialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +AlertDialogFooter.displayName = "AlertDialogFooter" + +const AlertDialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName + +const AlertDialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogDescription.displayName = + AlertDialogPrimitive.Description.displayName + +const AlertDialogAction = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName + +const AlertDialogCancel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName + +export { + AlertDialog, + AlertDialogPortal, + AlertDialogOverlay, + AlertDialogTrigger, + AlertDialogContent, + AlertDialogHeader, + AlertDialogFooter, + AlertDialogTitle, + AlertDialogDescription, + AlertDialogAction, + AlertDialogCancel, +} diff --git a/artifacts/api-portal/src/components/ui/alert.tsx b/artifacts/api-portal/src/components/ui/alert.tsx new file mode 100644 index 0000000..5afd41d --- /dev/null +++ b/artifacts/api-portal/src/components/ui/alert.tsx @@ -0,0 +1,59 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const alertVariants = cva( + "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", + { + variants: { + variant: { + default: "bg-background text-foreground", + destructive: + "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +const Alert = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes & VariantProps +>(({ className, variant, ...props }, ref) => ( +
+)) +Alert.displayName = "Alert" + +const AlertTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +AlertTitle.displayName = "AlertTitle" + +const AlertDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)) +AlertDescription.displayName = "AlertDescription" + +export { Alert, AlertTitle, AlertDescription } diff --git a/artifacts/api-portal/src/components/ui/aspect-ratio.tsx b/artifacts/api-portal/src/components/ui/aspect-ratio.tsx new file mode 100644 index 0000000..c4abbf3 --- /dev/null +++ b/artifacts/api-portal/src/components/ui/aspect-ratio.tsx @@ -0,0 +1,5 @@ +import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio" + +const AspectRatio = AspectRatioPrimitive.Root + +export { AspectRatio } diff --git a/artifacts/api-portal/src/components/ui/avatar.tsx b/artifacts/api-portal/src/components/ui/avatar.tsx new file mode 100644 index 0000000..51e507b --- /dev/null +++ b/artifacts/api-portal/src/components/ui/avatar.tsx @@ -0,0 +1,50 @@ +"use client" + +import * as React from "react" +import * as AvatarPrimitive from "@radix-ui/react-avatar" + +import { cn } from "@/lib/utils" + +const Avatar = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +Avatar.displayName = AvatarPrimitive.Root.displayName + +const AvatarImage = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarImage.displayName = AvatarPrimitive.Image.displayName + +const AvatarFallback = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName + +export { Avatar, AvatarImage, AvatarFallback } diff --git a/artifacts/api-portal/src/components/ui/badge.tsx b/artifacts/api-portal/src/components/ui/badge.tsx new file mode 100644 index 0000000..3f03665 --- /dev/null +++ b/artifacts/api-portal/src/components/ui/badge.tsx @@ -0,0 +1,43 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" + +import { cn } from "@/lib/utils" + +const badgeVariants = cva( + // @replit + // Whitespace-nowrap: Badges should never wrap. + "whitespace-nowrap inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2" + + " hover-elevate ", + { + variants: { + variant: { + default: + // @replit shadow-xs instead of shadow, no hover because we use hover-elevate + "border-transparent bg-primary text-primary-foreground shadow-xs", + secondary: + // @replit no hover because we use hover-elevate + "border-transparent bg-secondary text-secondary-foreground", + destructive: + // @replit shadow-xs instead of shadow, no hover because we use hover-elevate + "border-transparent bg-destructive text-destructive-foreground shadow-xs", + // @replit shadow-xs" - use badge outline variable + outline: "text-foreground border [border-color:var(--badge-outline)]", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +export interface BadgeProps + extends React.HTMLAttributes, + VariantProps {} + +function Badge({ className, variant, ...props }: BadgeProps) { + return ( +
+ ) +} + +export { Badge, badgeVariants } diff --git a/artifacts/api-portal/src/components/ui/breadcrumb.tsx b/artifacts/api-portal/src/components/ui/breadcrumb.tsx new file mode 100644 index 0000000..60e6c96 --- /dev/null +++ b/artifacts/api-portal/src/components/ui/breadcrumb.tsx @@ -0,0 +1,115 @@ +import * as React from "react" +import { Slot } from "@radix-ui/react-slot" +import { ChevronRight, MoreHorizontal } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Breadcrumb = React.forwardRef< + HTMLElement, + React.ComponentPropsWithoutRef<"nav"> & { + separator?: React.ReactNode + } +>(({ ...props }, ref) =>