Communitygithub.com

evalix098/tiktoklive

このアプリのサーバーコードからxAI API(Grok)を呼び出します。チャット/LLM機能、画像・動画生成(Imagine)、音声(テキスト読み上げ)を提供します。

tiktoklive とは?

このスキルは、xAI API(Grok)をアプリのサーバーコードから利用するための統合機能を提供します。XAI_API_KEY環境変数が存在する場合、実際のxAI APIにアクセスでき、モック応答や他のプロバイダーに頼る代わりにAI機能を実現できます。Grok-4.5モデルを使用したチャット/LLM機能、画像生成・編集・動画生成(Imagine)、およびテキスト読み上げ(TTS)をサポートします。APIはOpenAI互換であり、既存のOpenAIスタイルのクライアントを簡単に切り替えて使用できます。このスキルは、TanStack React Start、Astro、Next.js、Remix、SvelteKit、Nuxt、Hono、Cloudflare Workers、Bun、Deno、Node.js、Python(FastAPI/Flask)、Ruby on Rails、Go、Rustなど、あらゆるサーバーサイドフレームワークやランタイムで動作します。Appドメインはserver-onlyであり、クライアントコンポーネントやVITE_プレフィックス変数でキーを公開しないように注意が必要です。

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

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

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)なので、ベースURLとキーを切り替えるだけで、任意のOpenAIスタイルのクライアントが使用できます。

環境変数 — .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 — chatと同じ認証ヘッダー
body: JSON.stringify({
  model: "grok-imagine-image-quality", // または "grok-imagine-image"(より安価)
  prompt: data.prompt,
  // n(≤10)、解像度("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エラーの場合はそれを表面化し、リトライは最大1回にしてください。

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".

関連スキル