API reference

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] }, ...]

Protected Properties

DefaultSupportedTypes : override InferenceType
[Get]
Signature
override InferenceType DefaultSupportedTypes

Properties

SupportsVision : bool
[Get]
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.
Signature
bool SupportsVision

Methods

ChatAsync ( req , stream , ct )
Sends a chat turn to a Hugging Face Inference endpoint and returns assistant text.
Supports optional image inputs when the selected model is multimodal.
Signature
async Task< ChatResponse > ChatAsync(ChatRequest req, IProgress< ChatDelta > stream=null, CancellationToken ct=default)
Parameters
req: ChatRequest  Message payload and (optionally) images prepared by the editor or runtime.
stream: IProgress< ChatDelta >  Optional progress receiver for partial tokens; final text is always delivered.
ct: CancellationToken  Cancellation token for request assembly and HTTP.
Returns
async Task< ChatResponse >  ChatResponse with assistant text and raw payload for diagnostics.
DetectAsync ( imageJpgOrPng , 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.
Signature
async Task< string > DetectAsync(byte[] imageJpgOrPng, CancellationToken ct=default)
Parameters
imageJpgOrPng: byte[]  Encoded image data (e.g., JPG/PNG). Must be non-empty.
ct: CancellationToken  Cancellation token to abort pre-processing or HTTP.
Returns
async Task< string >  Normalized detection set (boxes, scores, class ids) for downstream visualization.
DetectAsync ( src , 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.
Signature
async Task< byte[]> DetectAsync(RenderTexture src, CancellationToken ct=default)
Parameters
src: RenderTexture  Source RenderTexture to analyze.
ct: CancellationToken  Cancellation token for aborting the operation.
Returns
async Task< byte[]>  UTF-8 encoded JSON string as byte array containing detection results.