HuggingFaceProvider Class
HuggingFace cloud provider – supports chat/VLM (IChatTask) and object detection (IObjectDetectionTask).
Normalized detections shape: [{ "score":float, "label":string, "box":[xmin,ymin,xmax,ymax] }, ...]
Indicates whether this provider prepares and sends image inputs for supported multimodal models.
Disable for pure-text models to reduce request overhead and validation checks.See IChatTask and your model's capabilities on the provider dashboard.
string IUsesCredential. ProviderId[Get]
Unique identifier for this provider type (e.g., "OpenAI", "LlamaApi").
Used to store and retrieve credentials from the central CredentialStorage.
bool IUsesCredential. OverrideApiKey[Get]
When true, this provider asset uses its own API key instead of the central storage.
Sends a chat turn to a Hugging Face Inference endpoint and returns assistant text.
Supports optional image inputs when the selected model is multimodal.See IChatTask. HF Inference:
https://huggingface.co/docs/api-inference/indexParametersreqMessage payload and (optionally) images prepared by the editor or runtime.
streamOptional progress receiver for partial tokens; final text is always delivered.
ctCancellation token for request assembly and HTTP.
ReturnsChatResponse with assistant text and raw payload for diagnostics.
async Task< string > DetectAsync ( byte[] imageJpgOrPng,
CancellationToken ct )
Runs object detection using a Hugging Face model and returns structured detections.
Handles tensor or JSON outputs depending on the model’s task definition.See IObjectDetectionTask. HF Tasks:
https://huggingface.co/docs/inference-providers/tasks/object-detectionParametersimageJpgOrPngEncoded image data (e.g., JPG/PNG). Must be non-empty.
ctCancellation token to abort pre-processing or HTTP.
ReturnsNormalized detection set (boxes, scores, class ids) for downstream visualization.
async Task< byte[]> DetectAsync ( RenderTexture src,
CancellationToken ct )
Performs object detection on a RenderTexture by encoding it to JPEG and calling the byte[] overload.
This provides compatibility with the IObjectDetectionTask interface while adapting to cloud providers.
ParameterssrcSource RenderTexture to analyze.
ctCancellation token for aborting the operation.
ReturnsUTF-8 encoded JSON string as byte array containing detection results.