Communitygithub.com

evalix098/tiktoklive

從應用程式伺服器端程式碼呼叫 xAI API (Grok),使用注入的 XAI_API_KEY:提供聊天/LLM 功能、圖片與影片生成 (Imagine) 以及語音 (文字轉語音)。當應用程式需要任何「AI」/「助理」/「聊天機器人」/「Grok」功能、執行時圖片/影片生成或語音功能時使用。觸發條件為「AI」、「LLM」、「聊天機器人」、「助理」、「Grok」、「xAI」、「生成文字」、「摘要」、「生成圖片」、「AI 影片」、「語音」、「文字轉語音」、「TTS」、「OpenAI」(請改用 xAI)。

tiktoklive 是什麼?

此技能提供對 xAI API (Grok) 的完整存取權限,可在應用程式伺服器端程式碼中啟用 AI 功能。當環境中存在 `XAI_API_KEY` 時,應用程式即可擁有真正的 xAI API 存取權,無需模擬回應或使用其他提供者。此技能支援聊天/LLM (最新模型為 `grok-4.5`)、圖片與影片生成 (Imagine API) 以及語音 (文字轉語音) 等功能。由於 API 金鑰屬於應用程式擁有者,每一次 API 呼叫都會耗用他們的配額和點數,因此必須謹慎使用,避免浪費。建議的做法包括:設定輸出上限 (`max_tokens`)、僅在使用者觸發時才進行 API 呼叫、快取結果,以及將昂貴的流程 (如媒體生成) 置於身分驗證或使用限制之後。此 API 與 OpenAI 相容,使用標準的 `fetch` 呼叫即可,無需額外的 SDK。

相容平台~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/evalix098/tiktoklive/tree/HEAD/.grok/skills/xai-api

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

xAI API (Grok)

當環境中存在 XAI_API_KEY 時,此應用程式便擁有真正的 xAI API 存取權——請將其用於 AI 功能,而不要模擬回應或使用其他提供者。同一個變數在部署應用程式時也會被注入,因此基於此變數建構的程式碼在預覽和正式環境中都能以相同方式運作。

此金鑰是應用程式擁有者的個人金鑰:每次呼叫都會耗用他們的配額和點數。 在使用上請審慎考量——在將 AI 呼叫接入任何會自動執行或對訪客開放的流程之前,請參閱謹慎使用額度。

此金鑰解鎖了完整的 API 功能,不僅限於聊天:

  • 聊天 / LLM — 最新模型:grok-4.5;除非使用者特別要求,否則預設使用此模型。
  • Imagine (圖片與影片) — 在應用程式執行時生成及編輯圖片、生成影片。
  • 語音 — 文字轉語音,提供富有表現力的語音選項 (以及語音轉文字功能)。
  • 官方文件:docs.x.ai — 端點、模型、參數、串流、工具使用。不要猜測 API 的結構;請查閱文件。
  • 此 API 與 OpenAI 相容 (https://api.x.ai/v1),因此任何 OpenAI 風格的客戶端只需切換基本 URL 和金鑰即可使用。

環境變數 — 請勿建立 .env 檔案

變數位置用途
XAI_API_KEY伺服器由平台注入 (預覽和部署)。切勿自行編寫、寫死或向使用者索取此金鑰。

此金鑰僅供伺服器端使用:在 createServerFn 處理器 / 伺服器程式碼中使用 process.env.XAI_API_KEY 讀取,切勿在客戶端元件中使用,也絕不能透過 VITE_ 前綴的變數或 API 回應將其暴露出去。

此金鑰可能是不存在的 (逐步開放)。請妥善降級處理——檢查金鑰是否存在,若不存在則顯示友善的「AI 功能目前不可用」狀態,而非讓應用程式崩潰:

const apiKey = process.env.XAI_API_KEY;
if (!apiKey) throw new Error("AI is not available in this environment");

呼叫 API (僅限伺服器端)

無需 SDK——從伺服器函式中使用原生的 fetch:

import { createServerFn } from "@tanstack/react-start";

export const askGrok = createServerFn({ method: "POST" })
  .validator((input: { prompt: string }) => input)
  .handler(async ({ data }) => {
    const apiKey = process.env.XAI_API_KEY;
    if (!apiKey) return { ok: false as const, error: "AI is not available" };

    const res = await fetch("https://api.x.ai/v1/chat/completions", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${apiKey}`,
      },
      body: JSON.stringify({
        model: "grok-4.5",
        messages: [{ role: "user", content: data.prompt }],
      }),
    });
    if (!res.ok) {
      return { ok: false as const, error: `xAI API error ${res.status}` };
    }
    const body = (await res.json()) as {
      choices: { message: { content: string } }[];
    };
    return { ok: true as const, text: body.choices[0]?.message.content ?? "" };
  });

關於串流、結構化輸出、視覺辨識或完整模型列表,請參閱 docs.x.ai — 其結構與 OpenAI 相容。

Imagine — 圖片與影片生成 (僅限伺服器端)

相同的金鑰可用於驅動應用程式中的執行時圖片/影片功能 (使用者頭像、場景美術、生成的內容)。這與您的建置時 imagine_text_to_image / imagine_image_to_image / imagine_image_to_video 工具 (imagine-grok-build 技能) 不同:當正在運行的應用程式需要生成媒體時請使用API,而當您在建置過程中為靜態素材進行創作時則使用那些工具。

// POST https://api.x.ai/v1/images/generations — 使用與聊天相同的授權標頭
body: JSON.stringify({
  model: "grok-imagine-image-quality", // 或 "grok-imagine-image" (較便宜)
  prompt: data.prompt,
  // n (≤10), resolution ("1k"|"2k"), response_format ("url"|"b64_json")
})
// → body.data[0].url
  • 圖片編輯:POST /v1/images/edits — 自然語言編輯,最多可使用 3 張參考圖片。
  • 影片:grok-imagine-video 需透過非同步影片端點 (啟動,然後輪詢傳回的請求 ID;片段最長約 15 秒)。
  • 完整參數與範例:docs.x.ai → Imagine API。

語音 — 文字轉語音 (僅限伺服器端)

POST https://api.x.ai/v1/tts 可將文字轉換為語音音訊——適用於旁白、無障礙功能、角色語音:

// 相同的 Authorization 標頭;傳回音訊位元組 (例如 MP3)
body: JSON.stringify({ text: data.text, voice_id: "eve" }) // eve = 預設語音

透過 GET /v1/tts/voices 列出可用的語音 (也支援自訂語音);語音轉文字功能同樣可用。詳情請參閱 docs.x.ai → Voice API。從您的伺服器函式中將音訊提供給客戶端——切勿從瀏覽器端呼叫此 API (這會暴露金鑰)。

謹慎使用額度

此金鑰屬於應用程式擁有者 (您正在為其建構的使用者):每一次呼叫——包括由已部署應用程式的匿名訪客觸發的呼叫——都會耗用他們個人的配額和點數。將配額浪費在無謂的呼叫上會降低或中斷其金鑰的所有其他用途。請謹慎使用:

  • 設定輸出上限 (max_tokens) 並保持提示詞簡潔,特別是針對訪客面向的功能。圖片生成,尤其是影片生成,每次呼叫的成本遠高於聊天。
  • 絕不要在任何迴圈中、每次按鍵時或頁面載入時呼叫 API——請確保呼叫是由使用者發起的 (如按鈕點擊、表單提交) 並進行去抖處理。
  • 快取或持久化結果 (請參閱 neon 技能),而不是為每個訪客或每次渲染重新生成相同內容。
  • 對昂貴的流程加上限制——特別是媒體生成。在已具備登入功能的應用程式中,可將其置於 authMiddleware 之後 (請參閱 auth 技能)。登入功能預設為關閉,若未經授權直接使用中介軟體會導致已部署的應用程式崩潰 (AGENTS.md §0.5)——因此,對於沒有帳號系統的應用程式,請改用使用限制的方式:由使用者發起呼叫、設定小額限制、快取結果。
  • 請勿設定過多的重試機制:當 API 發生錯誤時,向使用者顯示錯誤訊息;最多重試一次。

Individual skills in this repo

This repo contains 17 individual skills — each has its own dedicated page.

evalix098/tiktoklive

Add user accounts and sign-in to this TanStack Start app. Use when the app needs authentication, sign-in, user accounts, protected routes, or per-user data. Triggers on "auth", "login", "log in", "sign in", "sign up", "account", "users", "authentication", "protected", "who is logged in", "current user", "per-user".

evalix098/tiktoklive

Build browser games and interactive/canvas/3D experiences in this TanStack Start + React app. Use for any game, simulation, or WebGL/Canvas experience — 2D or 3D, single-player. Covers the game loop & timing, 3D orientation/camera conventions, collision, performance, assets, audio, save, game feel, and per-genre playbooks. For WASD / vehicle / flight **input signs and inverted A/D**, open the **`controls`** skill — do not rely on this file or racing-kart alone. Triggers on "game", "minecraft", "fps", "platformer", "racing", "tetris", "snake", "shooter", "3d", "three.js", "canvas", "voxel", "physics".

evalix098/tiktoklive

Player-facing input signs for browser games: WASD, vehicles, flight, FPS mouse-look, and the #1 failure mode (inverted A/D). Mandatory control self-tests and a tiny test interface so you can verify A turns left before shipping. Load for ANY game with movement, steering, flying, driving, tanks, boats, mechs, drones, planes, karts, third-person follow cams — not only racing. Triggers on "controls", "WASD", "inverted", "steer", "flight", "airplane", "kart", "vehicle", "yaw", "roll", "pitch", "mouse look", "A/D".

evalix098/tiktoklive

Design and build polished, non-generic UI for this TanStack Start + React + Tailwind v4 + shadcn/Radix app. Use whenever you create or restyle any interface surface — pages, landing pages, dashboards, forms, modals, nav, and game overlays (start screens, HUD, menus). Covers design tokens, layout, typography, color, spacing, motion, and the anti-"AI-slop" rules that keep output from looking generic. Triggers on "design", "UI", "make it look good", "polish", "landing page", "theme", "style", "redesign", "ugly", "clean up".

evalix098/tiktoklive

Deep guide for game ANIMATION assets: motion cycles, action keyframes, effect sequences, and animation sprite sheets — built around a video-first pipeline. In this app-builder sandbox, execute via the video2dsprite / generate2dsprite skills (magenta + scripts), not ad-hoc ffmpeg. Use whenever generating anything that moves: walk/run cycles, attacks, idles, FX, flags, fire, animation sheets. Complements game-asset-core.

evalix098/tiktoklive

Core discipline for ANY game-asset generation with Imagine tools: the engine-ready defaults users don't state, spec checklists, style anchoring, read-back verification, honest defect flagging. Use whenever generating any game art (sprites, sheets, animations, tiles, UI, FX) — then ALSO load the matching specialist skill: game-animation-frames for anything that moves, game-tilesets for tiles/terrain, game-character-consistency for recurring characters, game-ui-icons for UI and icons.

evalix098/tiktoklive

Deep guide for CHARACTER IDENTITY across images: turnarounds (front/side/ back), state and damage variants, palette swaps, equipment changes, and same-character-in-context sets. Use whenever generating character turnarounds, character sheets, variants of an existing sprite, or any same-subject multi-image set. Complements game-asset-core.

evalix098/tiktoklive

Deep guide for game TILE assets: seamless tileable textures, terrain transition tilesets, autotiles, and ground/platform tiles. Use whenever generating tileable textures, tilesets, terrain transitions, or seamless patterns. Complements game-asset-core.

evalix098/tiktoklive

Deep guide for game UI assets: buttons with interaction states, panels, bars, wordmark logos, and icon sets. Use whenever generating game UI elements, HUD assets, inventory icons, icon sets, buttons, or title logos. Complements game-asset-core.

evalix098/tiktoklive

Generate production-oriented 2D game maps with `imagine_text_to_image`: RPG/top-down maps, side-scroller parallax stages, tilemaps, layered raster maps, prop packs, collision zones, and walkable areas. Use when building browser games that need real map art (not pure code-drawn tiles), layered props, or map collision metadata. Triggers on "map", "level", "stage", "tilemap", "overworld", "dungeon", "side scroller background", "prop pack", "2D map".

evalix098/tiktoklive

Generate and postprocess 2D game sprites and animation sheets: pixel-art characters, NPCs, creatures, spells, projectiles, impacts, props, summons, and transparent PNG/GIF exports. Use when building browser games that need real sprite sheets (not code-drawn placeholders), matching a map art style, or producing magenta-background sheets for chroma-key cleanup. Triggers on "sprite", "sprite sheet", "animation sheet", "pixel art character", "walk cycle", "attack animation", "projectile sprite", "2D game asset".

evalix098/tiktoklive

How to use the Imagine tools in Grok Build: imagine_text_to_image, imagine_image_to_image, imagine_reference_to_image, imagine_text_to_video, imagine_image_to_video, imagine_reference_to_video, and render_file for chat previews. When to build a visual with code instead of generating it, prompt-craft, reference-first handling of real people, factual grounding, and asset-consistency. Load this whenever generating or editing an image or video is on the table. Tool-usage-driven, not triggered by a user merely mentioning images.

evalix098/tiktoklive

Peer-to-peer realtime multiplayer over WebRTC data channels: every user of the deployed app connects directly to every other user (full mesh), the server only brokers the handshake at /api/rtc. Lowest possible latency, zero per-message server cost. Use for 2-8 player co-op/casual realtime: shared cursors, drawing, party games, casual action. Triggers: p2p, peer to peer, webrtc, low latency multiplayer, direct connection.

evalix098/tiktoklive

Use Neon Postgres (the database) in this TanStack Start app. Use when the app needs to store or query data, persist state, or keep per-user data. Triggers on "database", "Postgres", "Neon", "save data", "store data", "persist", "tables", "SQL", "query", "migrations".

evalix098/tiktoklive

Share-link previews and app identity for apps on *.grok.me: the injector-owned og:image card, the SVG favicon, and PWA icons for installable apps. Use when scaffolding, renaming, or restyling the app — and for share / unfurl / OG / Twitter card questions. A custom 1200×630 card from the app's own art is the default — games of every kind (DOM board/word games included), whimsical apps, creative tools, and brand-forward pages; only plain utilities keep the placeholder. Always run the brand-asset pass as a `task` subagent and never wait for it. Triggers on "share", "rename", "app name", "OG", "Open Graph", "twitter card", "unfurl", "og:image", "og:type", "x:game:image", "x-banner", "link preview", "social card", "thumbnail", "preview image", "favicon", "app icon", "PWA", "manifest", "installable", "home screen", "SEO", "meta description".

evalix098/tiktoklive

Official Three.js API and TSL (Three.js Shading Language) reference for LLM code generation. Load when writing or debugging three.js / WebGL / WebGPU / custom materials / shaders / GLTF / advanced three APIs beyond basic game loop/controls. Prefer building-games for game correctness (loop, WASD, camera, orientation); use this skill for full API/TSL depth. Triggers on "three.js", "threejs", "WebGPU", "TSL", "NodeMaterial", "shader", "GLTF", "MeshStandard", "OrbitControls", "WebGLRenderer".

evalix098/tiktoklive

Grok Build only. Turn a 2D character still into denser animation sprites via imagine_text_to_image base → imagine_image_to_video (6s/10s run-in-place) → ffmpeg frames → magenta chroma-key → dense sampled strips/grids/GIFs. Use when the user wants video-to-sprite, smoother run/walk cycles, or denser intermediate poses. Prefer generate2dsprite for crisp production pixel sheets. Triggers on "video to sprite", "imagine_image_to_video sprite", "dense walk cycle", "smooth run animation from video".

相關技能