ai-infrastructure-huggingface-inference
TypeScript/Node.jsでHugging Face Inference SDKを使い、チャット、文章生成、埋め込み、画像生成、音声処理、翻訳、要約、Inference Endpointsなど、様々な推論処理を効率的に実行するSkill。
📜 元の英語説明(参考)
Hugging Face Inference SDK patterns for TypeScript/Node.js — InferenceClient setup, chat completion, text generation, streaming, embeddings, image generation, audio transcription, translation, summarization, and Inference Endpoints
🇯🇵 日本人クリエイター向け解説
TypeScript/Node.jsでHugging Face Inference SDKを使い、チャット、文章生成、埋め込み、画像生成、音声処理、翻訳、要約、Inference Endpointsなど、様々な推論処理を効率的に実行するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o ai-infrastructure-huggingface-inference.zip https://jpskill.com/download/10207.zip && unzip -o ai-infrastructure-huggingface-inference.zip && rm ai-infrastructure-huggingface-inference.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10207.zip -OutFile "$d\ai-infrastructure-huggingface-inference.zip"; Expand-Archive "$d\ai-infrastructure-huggingface-inference.zip" -DestinationPath $d -Force; ri "$d\ai-infrastructure-huggingface-inference.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
ai-infrastructure-huggingface-inference.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
ai-infrastructure-huggingface-inferenceフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Hugging Face 推論パターン
クイックガイド:
@huggingface/inference(v4+) を使用して、Hugging Face Hub 上の 20 万以上の ML モデルにアクセスします。InferenceClientをchatCompletion()(OpenAI 互換のチャット用)、textGeneration()(生のテキスト補完用)、chatCompletionStream()(ストリーミング用)、featureExtraction()(埋め込み用)、textToImage()(画像生成用)、automaticSpeechRecognition()(音声文字起こし用) と共に使用します。providerを設定して推論プロバイダー (Cerebras、Together、Groq など) を経由させるか、専用の Inference Endpoints にはendpointUrlを使用します。
<critical_requirements>
重要: この Skill を使用する前に
すべてのコードは CLAUDE.md のプロジェクト規約に従う必要があります (kebab-case、名前付きエクスポート、インポート順、
import type、名前付き定数)
(InferenceClient には必ずアクセストークンを渡す必要があります -- 認証なしでデプロイしないでください)
(会話型 LLM タスクには必ず chatCompletion() / chatCompletionStream() を使用する必要があります -- これらは OpenAI 互換のメッセージ形式に従います)
(エラーは必ず InferenceClientError とそのサブクラスを使用して処理する必要があります -- エラータイプチェックなしで生の catch ブロックを使用しないでください)
(すべての推論呼び出しに必ず model パラメータを指定する必要があります -- デフォルトモデルはありません)
(アクセストークンをハードコードしないでください -- 常に環境変数経由で process.env.HF_TOKEN を使用してください)
</critical_requirements>
自動検出: Hugging Face, huggingface, @huggingface/inference, InferenceClient, HfInference, hf.chatCompletion, hf.textGeneration, hf.featureExtraction, hf.textToImage, hf.automaticSpeechRecognition, hf.translation, hf.summarization, hf.textToSpeech, chatCompletionStream, textGenerationStream, HF_TOKEN, inference provider, Inference Endpoints
使用する場面:
- Hugging Face Hub でホストされている 20 万以上のモデルのいずれかにアクセスする場合
- オープンソース LLM (Qwen、Mistral、Llama など) でチャット補完を実行する場合
- セマンティック検索のために sentence-transformer モデルで埋め込みを生成する場合
- テキストプロンプトから画像を生成する場合 (FLUX、Stable Diffusion)
- 自動音声認識モデルで音声を文字起こしする場合
- 翻訳、要約、テキスト分類、または NER タスクを実行する場合
- 本番環境で使用するために専用の Inference Endpoints にモデルをデプロイする場合
- 統一された API を通じてサードパーティの推論プロバイダー (Cerebras、Together、Groq、Replicate など) を使用する場合
カバーされる主要なパターン:
- InferenceClient の初期化と構成
- Chat Completion API (OpenAI 互換のメッセージ形式、ストリーミング)
- テキスト生成 (生の補完、ストリーミング)
- 特徴抽出による埋め込み
- 画像生成 (テキストから画像へ)
- 音声文字起こし (自動音声認識)
- 翻訳、要約、およびテキスト分類
- Inference Endpoints (専用のデプロイメント)
- 推論プロバイダー (サードパーティサービス経由のルーティング)
- 型付きエラークラスによるエラー処理
使用しない場面:
- OpenAI モデルのみを使用する場合 -- OpenAI SDK を直接使用してください
- 構造化された出力とツール呼び出しを備えた、プロバイダーに依存しない統一された SDK が必要な場合 -- より高レベルの AI SDK を使用してください
- モデルを微調整またはトレーニングする必要がある場合 --
@huggingface/hubパッケージまたは Pythontransformersを使用してください
例のインデックス
- コア: セットアップ、チャット & テキスト生成 -- クライアントの初期化、チャット補完、テキスト生成、ストリーミング、エラー処理
- タスク: 埋め込み、ビジョン、オーディオ & NLP -- 特徴抽出、画像生成、音声認識、翻訳、要約、分類
- クイック API リファレンス -- メソッドシグネチャ、エラータイプ、プロバイダーリスト、モデルの推奨事項
<philosophy>
哲学
@huggingface/inference SDK は、複数のバックエンド (サーバーレスの Inference Providers、専用の Inference Endpoints、およびローカルサーバー) を通じて数十万の ML モデルにアクセスするための 統一された TypeScript クライアント を提供します。
コア原則:
- モデルに依存しないアクセス -- 1 つのクライアントで、Hub 上の任意のモデルにアクセスできます。コードを変更せずに
modelパラメータを変更することでモデルを交換します。 - プロバイダーの柔軟性 -- 単一の
providerパラメータを使用して、20 以上のプロバイダー (Cerebras、Together、Groq、Replicate など) を介して推論をルーティングするか、独自の Inference Endpoints をデプロイします。 - タスク指向の API -- メソッドは、生の HTTP エンドポイントではなく、ML タスク (
chatCompletion、textToImage、automaticSpeechRecognition) にマッピングされます。 - OpenAI 互換のチャット --
chatCompletion()は OpenAI メッセージ形式 (role+content) を使用するため、プロバイダー間の移行が容易になります。 - 非同期ジェネレーターとしてのストリーミング --
chatCompletionStream()およびtextGenerationStream()はAsyncGeneratorを返し、for await...ofで消費されます。
</philosophy>
<patterns>
コアパターン
パターン 1: クライアントのセットアップ
Hugging Face アクセストークンを使用して初期化します。認証されたアクセスにはトークンが必要です。
// lib/hf-client.ts -- 基本的なセットアップ
import { InferenceClient } from "@huggingface/inference";
const client = new InferenceClient(process.env.HF_TOKEN);
export { client };
// lib/hf-client.ts -- カスタムエンドポイントを使用
const ENDPOINT_URL =
"https://your-endpoint.us-east-1.aws.endpoints.huggingface.cloud/v1/";
const client = new InferenceClient(process.env.HF_TOKEN, {
endpointUrl: ENDPOINT_URL,
});
export { client };
良い理由: 環境変数からのトークン、エンドポイント URL の名前付き定数、名前付きエクスポート
// 悪い例: ハードコードされたトークン、名前付きエクスポートなし
const hf = new InferenceClient("hf_abc123xyz");
export default hf;
悪い理由: ハードコードされたトークンはセキュリティリスクであり、デフォルトエクスポートは規約に違反します
参照: プロバイダーのルーティング、ローカルエンドポイント、およびエンドポイントヘルパーについては、examples/core.md を参照してください
パターン 2: チャット補完 (OpenAI 互換)
会話型 LLM タスクには chatCompletion() を使用します。OpenAI メッセージ形式に従います。
const MAX_TOKENS = 512;
const TEMPERATURE = 0.1;
const response = await client.chatCompletion({
model: "Qwen/
(原文がここで切り詰められています) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Hugging Face Inference Patterns
Quick Guide: Use
@huggingface/inference(v4+) to access 200k+ ML models on the Hugging Face Hub. UseInferenceClientwithchatCompletion()for OpenAI-compatible chat,textGeneration()for raw text completion,chatCompletionStream()for streaming,featureExtraction()for embeddings,textToImage()for image generation, andautomaticSpeechRecognition()for audio transcription. Setproviderto route through inference providers (Cerebras, Together, Groq, etc.) or useendpointUrlfor dedicated Inference Endpoints.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST always pass an access token to InferenceClient -- never deploy without authentication)
(You MUST use chatCompletion() / chatCompletionStream() for conversational LLM tasks -- these follow the OpenAI-compatible message format)
(You MUST handle errors using InferenceClientError and its subclasses -- never use bare catch blocks without error type checking)
(You MUST specify a model parameter for every inference call -- there is no default model)
(You MUST never hardcode access tokens -- always use environment variables via process.env.HF_TOKEN)
</critical_requirements>
Auto-detection: Hugging Face, huggingface, @huggingface/inference, InferenceClient, HfInference, hf.chatCompletion, hf.textGeneration, hf.featureExtraction, hf.textToImage, hf.automaticSpeechRecognition, hf.translation, hf.summarization, hf.textToSpeech, chatCompletionStream, textGenerationStream, HF_TOKEN, inference provider, Inference Endpoints
When to use:
- Accessing any of the 200k+ models hosted on the Hugging Face Hub
- Running chat completion with open-source LLMs (Qwen, Mistral, Llama, etc.)
- Generating embeddings with sentence-transformer models for semantic search
- Generating images from text prompts (FLUX, Stable Diffusion)
- Transcribing audio with automatic speech recognition models
- Running translation, summarization, text classification, or NER tasks
- Deploying models on dedicated Inference Endpoints for production use
- Using third-party inference providers (Cerebras, Together, Groq, Replicate, etc.) through a unified API
Key patterns covered:
- InferenceClient initialization and configuration
- Chat Completion API (OpenAI-compatible messages format, streaming)
- Text generation (raw completion, streaming)
- Embeddings via feature extraction
- Image generation (text-to-image)
- Audio transcription (automatic speech recognition)
- Translation, summarization, and text classification
- Inference Endpoints (dedicated deployments)
- Inference Providers (routing through third-party services)
- Error handling with typed error classes
When NOT to use:
- If you only use OpenAI models -- use the OpenAI SDK directly
- If you need a provider-agnostic unified SDK with structured outputs and tool calling -- use a higher-level AI SDK
- If you need to fine-tune or train models -- use the
@huggingface/hubpackage or Pythontransformers
Examples Index
- Core: Setup, Chat & Text Generation -- Client init, chat completion, text generation, streaming, error handling
- Tasks: Embeddings, Vision, Audio & NLP -- Feature extraction, image generation, speech recognition, translation, summarization, classification
- Quick API Reference -- Method signatures, error types, provider list, model recommendations
<philosophy>
Philosophy
The @huggingface/inference SDK provides a unified TypeScript client for accessing hundreds of thousands of ML models through multiple backends: serverless Inference Providers, dedicated Inference Endpoints, and local servers.
Core principles:
- Model-agnostic access -- One client, any model on the Hub. Swap models by changing the
modelparameter without code changes. - Provider flexibility -- Route inference through 20+ providers (Cerebras, Together, Groq, Replicate, etc.) with a single
providerparameter, or deploy your own Inference Endpoints. - Task-oriented API -- Methods map to ML tasks (
chatCompletion,textToImage,automaticSpeechRecognition), not raw HTTP endpoints. - OpenAI-compatible chat --
chatCompletion()uses the OpenAI message format (role+content), making migration between providers easy. - Streaming as async generators --
chatCompletionStream()andtextGenerationStream()returnAsyncGenerator, consumed withfor await...of.
</philosophy>
<patterns>
Core Patterns
Pattern 1: Client Setup
Initialize with your Hugging Face access token. The token is required for authenticated access.
// lib/hf-client.ts -- basic setup
import { InferenceClient } from "@huggingface/inference";
const client = new InferenceClient(process.env.HF_TOKEN);
export { client };
// lib/hf-client.ts -- with custom endpoint
const ENDPOINT_URL =
"https://your-endpoint.us-east-1.aws.endpoints.huggingface.cloud/v1/";
const client = new InferenceClient(process.env.HF_TOKEN, {
endpointUrl: ENDPOINT_URL,
});
export { client };
Why good: Token from env var, named constant for endpoint URL, named export
// BAD: Hardcoded token, no named export
const hf = new InferenceClient("hf_abc123xyz");
export default hf;
Why bad: Hardcoded token is a security risk, default export violates conventions
See: examples/core.md for provider routing, local endpoints, and endpoint helper
Pattern 2: Chat Completion (OpenAI-Compatible)
Use chatCompletion() for conversational LLM tasks. Follows the OpenAI message format.
const MAX_TOKENS = 512;
const TEMPERATURE = 0.1;
const response = await client.chatCompletion({
model: "Qwen/Qwen3-32B",
provider: "cerebras",
messages: [
{ role: "system", content: "You are a helpful coding assistant." },
{ role: "user", content: "Explain TypeScript generics." },
],
max_tokens: MAX_TOKENS,
temperature: TEMPERATURE,
});
console.log(response.choices[0].message.content);
Why good: Named constants for parameters, explicit model and provider, system message for behavior
// BAD: No model specified, magic numbers, no system message
const response = await client.chatCompletion({
messages: [{ role: "user", content: "do something" }],
max_tokens: 512,
temperature: 0.1,
});
Why bad: Missing required model, magic numbers, vague prompt, no system instruction
See: examples/core.md for multi-turn conversations and provider selection
Pattern 3: Streaming Chat Completion
Use chatCompletionStream() for streaming responses. Returns an AsyncGenerator.
const MAX_TOKENS = 512;
let fullResponse = "";
for await (const chunk of client.chatCompletionStream({
model: "Qwen/Qwen3-32B",
provider: "cerebras",
messages: [{ role: "user", content: "Explain async/await in TypeScript." }],
max_tokens: MAX_TOKENS,
})) {
if (chunk.choices && chunk.choices.length > 0) {
const content = chunk.choices[0].delta.content;
if (content) {
process.stdout.write(content);
fullResponse += content;
}
}
}
console.log(); // newline
Why good: Async generator consumed with for await, progressive output, null checks on chunk data
// BAD: Not checking chunk.choices, ignoring null content
for await (const chunk of client.chatCompletionStream({
model: "...",
messages: [],
})) {
process.stdout.write(chunk.choices[0].delta.content); // May throw on null
}
Why bad: No null check -- choices may be empty, content may be null between chunks
See: examples/core.md for text generation streaming
Pattern 4: Text Generation (Raw Completion)
Use textGeneration() for prompt continuation without the chat message format.
const MAX_NEW_TOKENS = 250;
const result = await client.textGeneration({
model: "mistralai/Mixtral-8x7B-v0.1",
provider: "together",
inputs: "The key benefits of TypeScript are",
parameters: { max_new_tokens: MAX_NEW_TOKENS },
});
console.log(result.generated_text);
Why good: Named constant, clear prompt, explicit provider, direct access to generated_text
See: examples/core.md for streaming text generation
Pattern 5: Embeddings (Feature Extraction)
Use featureExtraction() for generating vector embeddings for semantic search and RAG.
const embeddings = await client.featureExtraction({
model: "sentence-transformers/all-MiniLM-L6-v2",
inputs: "That is a happy person",
});
// Returns: number[] (embedding vector)
Why good: Purpose-built embedding model, simple input/output
See: examples/tasks.md for batch embeddings and cosine similarity
Pattern 6: Image Generation (Text-to-Image)
Use textToImage() to generate images from text prompts. Returns a Blob.
const imageBlob = await client.textToImage({
model: "black-forest-labs/FLUX.1-dev",
inputs: "a serene mountain landscape at sunset",
provider: "replicate",
});
// imageBlob is a Blob -- write to file or convert to buffer
Why good: Explicit model and provider, descriptive prompt
See: examples/tasks.md for saving images, image-to-image, and output formats
Pattern 7: Audio Transcription
Use automaticSpeechRecognition() for speech-to-text.
import { readFileSync } from "node:fs";
const result = await client.automaticSpeechRecognition({
model: "facebook/wav2vec2-large-960h-lv60-self",
data: readFileSync("audio/recording.flac"),
});
console.log(result.text);
Why good: Uses data parameter with file buffer, outputs .text
See: examples/tasks.md for Whisper models, audio classification, and text-to-speech
Pattern 8: Error Handling
Always catch InferenceClientError and its subclasses. Re-throw unexpected errors.
import {
InferenceClientError,
InferenceClientInputError,
InferenceClientProviderApiError,
InferenceClientProviderOutputError,
InferenceClientHubApiError,
} from "@huggingface/inference";
try {
const result = await client.chatCompletion({
model: "Qwen/Qwen3-32B",
messages: [{ role: "user", content: "Hello" }],
});
} catch (error) {
if (error instanceof InferenceClientProviderApiError) {
console.error("Provider API error:", error.message);
console.error("Request:", error.request);
console.error("Response:", error.response);
} else if (error instanceof InferenceClientHubApiError) {
console.error("Hub API error:", error.message);
} else if (error instanceof InferenceClientProviderOutputError) {
console.error("Malformed provider response:", error.message);
} else if (error instanceof InferenceClientInputError) {
console.error("Invalid input:", error.message);
} else if (error instanceof InferenceClientError) {
console.error("Inference error:", error.message);
} else {
throw error; // Re-throw non-inference errors
}
}
Why good: Specific error types for each failure mode, request/response details for debugging, re-throws unexpected errors
See: examples/core.md for full error handling patterns
</patterns>
<decision_framework>
Decision Framework
Which Method to Use
What is your task?
+-- Conversational LLM (messages) -> chatCompletion() / chatCompletionStream()
+-- Raw text continuation -> textGeneration() / textGenerationStream()
+-- Embeddings for search/RAG -> featureExtraction()
+-- Image from text prompt -> textToImage()
+-- Speech to text -> automaticSpeechRecognition()
+-- Text to speech -> textToSpeech()
+-- Language translation -> translation()
+-- Summarize long text -> summarization()
+-- Classify text -> textClassification()
+-- Named entity recognition -> tokenClassification()
+-- Classify image -> imageClassification()
+-- Detect objects -> objectDetection()
+-- Caption an image -> imageToText()
+-- Answer questions from context -> questionAnswering()
Chat Completion vs Text Generation
Do you have a conversation with roles (system/user/assistant)?
+-- YES -> chatCompletion() / chatCompletionStream()
| Uses OpenAI-compatible message format
| Supports system messages, multi-turn
+-- NO -> Do you want to continue/complete a text prompt?
+-- YES -> textGeneration() / textGenerationStream()
| Takes raw text input via 'inputs'
+-- NO -> Use a task-specific method instead
Serverless vs Dedicated
What are your deployment needs?
+-- Prototyping / low volume -> Serverless Inference Providers (provider: "auto")
| Free tier available, shared infrastructure, may have cold starts
+-- Production / high volume -> Inference Endpoints (endpointUrl)
| Dedicated GPU, autoscaling, scale-to-zero, private infrastructure
+-- Local development -> Local endpoint (endpointUrl: "http://localhost:8080")
Works with llama.cpp, Ollama, vLLM, TGI, LiteLLM
When to Use This SDK vs Others
Do you need access to 200k+ open-source models?
+-- YES -> Use @huggingface/inference
+-- NO -> Do you only use OpenAI models?
+-- YES -> Not this skill's scope -- use the OpenAI SDK directly
+-- NO -> Do you need structured outputs / tool calling?
+-- YES -> Not this skill's scope -- use a higher-level AI SDK
+-- NO -> @huggingface/inference works for most ML tasks
</decision_framework>
<red_flags>
RED FLAGS
High Priority Issues:
- Hardcoding access tokens instead of using environment variables (security breach risk)
- Using bare
catchblocks without checkingInferenceClientErrortypes (hides API errors, loses debug info) - Omitting the
modelparameter -- always specify the model explicitly for predictable behavior (the SDK can pick a recommended model if omitted, but this is unreliable for production) - Not consuming
chatCompletionStream()/textGenerationStream()generators (tokens are silently lost) - Using
textGeneration()for conversational tasks instead ofchatCompletion()(wrong API shape)
Medium Priority Issues:
- Not specifying
providerwhen a specific provider is needed (default"auto"picks based on your HF settings, which may not be optimal) - Not checking
chunk.choiceslength before accessingchunk.choices[0]in streaming (may throw on empty chunks) - Using
request()/streamingRequest()directly -- these are deprecated, use task-specific methods - Ignoring
max_tokens/max_new_tokenslimits (output may be truncated or excessively long) - Not handling model loading time for serverless inference (cold models return 503, then load)
Common Mistakes:
- Confusing
chatCompletion()parameters withtextGeneration()parameters -- chat usesmessages+max_tokens, text generation usesinputs+parameters.max_new_tokens - Using
inputsparameter withchatCompletion()-- it usesmessages, notinputs - Using
messagesparameter withtextGeneration()-- it usesinputs, notmessages - Forgetting that
textToImage()returns aBlob, not a URL or Buffer - Treating
featureExtraction()output as always a flat array -- shape depends on the model (can be nested arrays for batch inputs) - Not passing
data(binary) for audio/image tasks, or passing a string path instead of the actual file buffer
Gotchas & Edge Cases:
- The
provider: "auto"default selects providers based on your HF account settings athf.co/settings/inference-providers-- not by availability or speed. Set an explicit provider for predictable routing. - Serverless models may need time to load (cold start). First requests to a cold model may return 503 errors while the model warms up. The SDK handles retries, but initial requests can be slow.
- When using Inference Endpoints with
endpointUrl, the model parameter is often ignored because the endpoint serves a specific model. chatCompletion()is OpenAI-API compatible -- it works with any OpenAI-compatible endpoint, not just Hugging Face.HfInferenceis still exported for backward compatibility butInferenceClientis the current class name.- Third-party provider API keys can be passed as the
accessToken-- when authenticated with a non-HF key, requests go directly to the provider instead of through HF's routing layer. - Tree-shakeable imports (
import { textGeneration } from "@huggingface/inference") require passingaccessTokenas a parameter instead of constructor. textToImage()supports multiple output types:blob(default),url,dataUrl, orjsonvia the optionsoutputTypeparameter.- Translation requires
parameters.src_langandparameters.tgt_langfor many-to-many models likembart-large-50-many-to-many-mmt.
</red_flags>
<critical_reminders>
CRITICAL REMINDERS
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST always pass an access token to InferenceClient -- never deploy without authentication)
(You MUST use chatCompletion() / chatCompletionStream() for conversational LLM tasks -- these follow the OpenAI-compatible message format)
(You MUST handle errors using InferenceClientError and its subclasses -- never use bare catch blocks without error type checking)
(You MUST specify a model parameter for every inference call -- there is no default model)
(You MUST never hardcode access tokens -- always use environment variables via process.env.HF_TOKEN)
Failure to follow these rules will produce insecure, unreliable, or silently failing AI integrations.
</critical_reminders>