"use client"; import { useLanguage } from "@/components/LanguageContext"; const QUICKSTART_BADGES = [ "quickstartBadgeCompat", "quickstartBadgeUnifiedKey", "quickstartBadgeModelSwitch", "quickstartBadgeUsage", "quickstartBadgeBeta", ] as const; const CODE_LINES: { text: string; className: string }[] = [ { text: 'import OpenAI from "openai";', className: "text-violet-300" }, { text: "", className: "" }, { text: "const client = new OpenAI({", className: "text-sky-300" }, { text: ' baseURL: "https://api.hubapi.ai/v1",', className: "text-emerald-300/90" }, { text: " apiKey: process.env.HUBAPI_KEY", className: "text-emerald-300/90" }, { text: "});", className: "text-sky-300" }, { text: "", className: "" }, { text: "const response = await client.chat.completions.create({", className: "text-sky-300" }, { text: ' model: "anthropic/claude-sonnet",', className: "text-emerald-300/90" }, { text: " messages: [", className: "text-sky-300" }, { text: " {", className: "text-foreground/70" }, { text: ' role: "user",', className: "text-emerald-300/90" }, { text: ' content: "Explain this document simply."', className: "text-emerald-300/90" }, { text: " }", className: "text-foreground/70" }, { text: " ]", className: "text-sky-300" }, { text: "});", className: "text-sky-300" }, { text: "", className: "" }, { text: "console.log(response.choices[0].message.content);", className: "text-amber-200/90" }, ]; export function ApiQuickstartPreview() { const { t } = useLanguage(); return (
{CODE_LINES.map((line, idx) => (
{line.text ? (
{line.text}
) : (
"\u00A0"
)}
))}
{t("terminalCodeHint")}