Huggingface.js documentation

Class: HfInferenceEndpoint

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Class: HfInferenceEndpoint

Hierarchy

  • TaskWithNoAccessTokenNoEndpointUrl

    HfInferenceEndpoint

Constructors

constructor

new HfInferenceEndpoint(endpointUrl, accessToken?, defaultOptions?): HfInferenceEndpoint

Parameters

Name Type Default value
endpointUrl string undefined
accessToken string ""
defaultOptions Options {}

Returns

HfInferenceEndpoint

Defined in

inference/src/HfInference.ts:51

Properties

audioClassification

audioClassification: (args: { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options) => Promise\<AudioClassificationOutput>

Type declaration

▸ (args, options?): Promise\<AudioClassificationOutput>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options
Returns

Promise\<AudioClassificationOutput>

Defined in

inference/src/tasks/audio/audioClassification.ts:14


audioToAudio

audioToAudio: (args: { data: Blob | ArrayBuffer } | { inputs: Blob ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" }, options?: Options) => Promise\<AudioToAudioOutput[]>

Type declaration

▸ (args, options?): Promise\<AudioToAudioOutput[]>

Parameters
Name Type
args { data: Blob | ArrayBuffer } | { inputs: Blob ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" }
options? Options
Returns

Promise\<AudioToAudioOutput[]>

Defined in

inference/src/tasks/audio/audioToAudio.ts:38


automaticSpeechRecognition

automaticSpeechRecognition: (args: { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options) => Promise\<AutomaticSpeechRecognitionOutput>

Type declaration

▸ (args, options?): Promise\<AutomaticSpeechRecognitionOutput>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options
Returns

Promise\<AutomaticSpeechRecognitionOutput>

Defined in

inference/src/tasks/audio/automaticSpeechRecognition.ts:15


chatCompletion

chatCompletion: (args: {}, options?: Options) => Promise\<ChatCompletionOutput>

Type declaration

▸ (args, options?): Promise\<ChatCompletionOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<ChatCompletionOutput>

Defined in

inference/src/tasks/nlp/chatCompletion.ts:9


chatCompletionStream

chatCompletionStream: (args: {}, options?: Options) => AsyncGenerator\<ChatCompletionStreamOutput, any, unknown>

Type declaration

▸ (args, options?): AsyncGenerator\<ChatCompletionStreamOutput, any, unknown>

Parameters
Name Type
args Object
options? Options
Returns

AsyncGenerator\<ChatCompletionStreamOutput, any, unknown>

Defined in

inference/src/tasks/nlp/chatCompletionStream.ts:8


documentQuestionAnswering

documentQuestionAnswering: (args: {}, options?: Options) => Promise\<DocumentQuestionAnsweringOutputElement>

Type declaration

▸ (args, options?): Promise\<DocumentQuestionAnsweringOutputElement>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<DocumentQuestionAnsweringOutputElement>

Defined in

inference/src/tasks/multimodal/documentQuestionAnswering.ts:20


featureExtraction

featureExtraction: (args: { inputs: string | string[] ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" }, options?: Options) => Promise\<FeatureExtractionOutput>

Type declaration

▸ (args, options?): Promise\<FeatureExtractionOutput>

Parameters
Name Type Description
args Object -
args.inputs string | string[] The inputs is a string or a list of strings to get the features from. inputs: “That is a happy person”,
args.model? string The HF model to use. If not specified, will call huggingface.co/api/tasks to get the default model for the task. /!\ Legacy behavior allows this to be an URL, but this is deprecated and will be removed in the future. Use the endpointUrl parameter instead.
args.provider? "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" Set an Inference provider to run this model on. Defaults to the first provider in your user settings that is compatible with this model.
options? Options -
Returns

Promise\<FeatureExtractionOutput>

Defined in

inference/src/tasks/nlp/featureExtraction.ts:24


fillMask

fillMask: (args: {}, options?: Options) => Promise\<FillMaskOutput>

Type declaration

▸ (args, options?): Promise\<FillMaskOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<FillMaskOutput>

Defined in

inference/src/tasks/nlp/fillMask.ts:11


imageClassification

imageClassification: (args: { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options) => Promise\<ImageClassificationOutput>

Type declaration

▸ (args, options?): Promise\<ImageClassificationOutput>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options
Returns

Promise\<ImageClassificationOutput>

Defined in

inference/src/tasks/cv/imageClassification.ts:13


imageSegmentation

imageSegmentation: (args: { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options) => Promise\<ImageSegmentationOutput>

Type declaration

▸ (args, options?): Promise\<ImageSegmentationOutput>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options
Returns

Promise\<ImageSegmentationOutput>

Defined in

inference/src/tasks/cv/imageSegmentation.ts:13


imageToImage

imageToImage: (args: {}, options?: Options) => Promise\<Blob>

Type declaration

▸ (args, options?): Promise\<Blob>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<Blob>

Defined in

inference/src/tasks/cv/imageToImage.ts:13


imageToText

imageToText: (args: { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options) => Promise\<ImageToTextOutput>

Type declaration

▸ (args, options?): Promise\<ImageToTextOutput>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options
Returns

Promise\<ImageToTextOutput>

Defined in

inference/src/tasks/cv/imageToText.ts:12


objectDetection

objectDetection: (args: { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options) => Promise\<ObjectDetectionOutput>

Type declaration

▸ (args, options?): Promise\<ObjectDetectionOutput>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options
Returns

Promise\<ObjectDetectionOutput>

Defined in

inference/src/tasks/cv/objectDetection.ts:13


questionAnswering

questionAnswering: (args: {}, options?: Options) => Promise\<QuestionAnsweringOutputElement>

Type declaration

▸ (args, options?): Promise\<QuestionAnsweringOutputElement>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<QuestionAnsweringOutputElement>

Defined in

inference/src/tasks/nlp/questionAnswering.ts:11


request

request: (args: { data: Blob | ArrayBuffer ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { inputs: unknown ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { model?: string ; parameters?: Record\<string, unknown> ; prompt: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { audio_url: string ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options & { chatCompletion?: boolean ; task?: string ; taskHint?: InferenceTask }) => Promise\<unknown>

Type declaration

▸ (args, options?): Promise\<unknown>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { inputs: unknown ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { model?: string ; parameters?: Record\<string, unknown> ; prompt: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { audio_url: string ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options & { chatCompletion?: boolean ; task?: string ; taskHint?: InferenceTask }
Returns

Promise\<unknown>

Defined in

inference/src/tasks/custom/request.ts:7


sentenceSimilarity

sentenceSimilarity: (args: {}, options?: Options) => Promise\<SentenceSimilarityOutput>

Type declaration

▸ (args, options?): Promise\<SentenceSimilarityOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<SentenceSimilarityOutput>

Defined in

inference/src/tasks/nlp/sentenceSimilarity.ts:13


streamingRequest

streamingRequest: (args: { data: Blob | ArrayBuffer ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { inputs: unknown ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { model?: string ; parameters?: Record\<string, unknown> ; prompt: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { audio_url: string ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options & { chatCompletion?: boolean ; task?: string ; taskHint?: InferenceTask }) => AsyncGenerator\<unknown, any, unknown>

Type declaration

▸ (args, options?): AsyncGenerator\<unknown, any, unknown>

Parameters
Name Type
args { data: Blob | ArrayBuffer ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { inputs: unknown ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { model?: string ; parameters?: Record\<string, unknown> ; prompt: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | { audio_url: string ; model?: string ; parameters?: Record\<string, unknown> ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options & { chatCompletion?: boolean ; task?: string ; taskHint?: InferenceTask }
Returns

AsyncGenerator\<unknown, any, unknown>

Defined in

inference/src/tasks/custom/streamingRequest.ts:9


summarization

summarization: (args: {}, options?: Options) => Promise\<SummarizationOutput>

Type declaration

▸ (args, options?): Promise\<SummarizationOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<SummarizationOutput>

Defined in

inference/src/tasks/nlp/summarization.ts:11


tableQuestionAnswering

tableQuestionAnswering: (args: {}, options?: Options) => Promise\<TableQuestionAnsweringOutputElement>

Type declaration

▸ (args, options?): Promise\<TableQuestionAnsweringOutputElement>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<TableQuestionAnsweringOutputElement>

Defined in

inference/src/tasks/nlp/tableQuestionAnswering.ts:11


tabularClassification

tabularClassification: (args: { inputs: { data: Record\<string, string[]> } ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" }, options?: Options) => Promise\<TabularClassificationOutput>

Type declaration

▸ (args, options?): Promise\<TabularClassificationOutput>

Parameters
Name Type Description
args Object -
args.inputs Object -
args.inputs.data Record\<string, string[]> A table of data represented as a dict of list where entries are headers and the lists are all the values, all lists must have the same size.
args.model? string The HF model to use. If not specified, will call huggingface.co/api/tasks to get the default model for the task. /!\ Legacy behavior allows this to be an URL, but this is deprecated and will be removed in the future. Use the endpointUrl parameter instead.
args.provider? "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" Set an Inference provider to run this model on. Defaults to the first provider in your user settings that is compatible with this model.
options? Options -
Returns

Promise\<TabularClassificationOutput>

Defined in

inference/src/tasks/tabular/tabularClassification.ts:24


tabularRegression

tabularRegression: (args: { inputs: { data: Record\<string, string[]> } ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" }, options?: Options) => Promise\<TabularRegressionOutput>

Type declaration

▸ (args, options?): Promise\<TabularRegressionOutput>

Parameters
Name Type Description
args Object -
args.inputs Object -
args.inputs.data Record\<string, string[]> A table of data represented as a dict of list where entries are headers and the lists are all the values, all lists must have the same size.
args.model? string The HF model to use. If not specified, will call huggingface.co/api/tasks to get the default model for the task. /!\ Legacy behavior allows this to be an URL, but this is deprecated and will be removed in the future. Use the endpointUrl parameter instead.
args.provider? "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" Set an Inference provider to run this model on. Defaults to the first provider in your user settings that is compatible with this model.
options? Options -
Returns

Promise\<TabularRegressionOutput>

Defined in

inference/src/tasks/tabular/tabularRegression.ts:24


textClassification

textClassification: (args: {}, options?: Options) => Promise\<TextClassificationOutput>

Type declaration

▸ (args, options?): Promise\<TextClassificationOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<TextClassificationOutput>

Defined in

inference/src/tasks/nlp/textClassification.ts:11


textGeneration

textGeneration: (args: {}, options?: Options) => Promise\<TextGenerationOutput>

Type declaration

▸ (args, options?): Promise\<TextGenerationOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<TextGenerationOutput>

Defined in

inference/src/tasks/nlp/textGeneration.ts:27


textGenerationStream

textGenerationStream: (args: {}, options?: Options) => AsyncGenerator\<TextGenerationStreamOutput, any, unknown>

Type declaration

▸ (args, options?): AsyncGenerator\<TextGenerationStreamOutput, any, unknown>

Parameters
Name Type
args Object
options? Options
Returns

AsyncGenerator\<TextGenerationStreamOutput, any, unknown>

Defined in

inference/src/tasks/nlp/textGenerationStream.ts:88


textToImage

textToImage: (args: {}, options?: Options) => Promise\<Blob>

Type declaration

▸ (args, options?): Promise\<Blob>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<Blob>

Defined in

inference/src/tasks/cv/textToImage.ts:22


textToSpeech

textToSpeech: (args: {}, options?: Options) => Promise\<Blob>

Type declaration

▸ (args, options?): Promise\<Blob>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<Blob>

Defined in

inference/src/tasks/audio/textToSpeech.ts:15


textToVideo

textToVideo: (args: {}, options?: Options) => Promise\<Blob>

Type declaration

▸ (args, options?): Promise\<Blob>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<Blob>

Defined in

inference/src/tasks/cv/textToVideo.ts:25


tokenClassification

tokenClassification: (args: {}, options?: Options) => Promise\<TokenClassificationOutput>

Type declaration

▸ (args, options?): Promise\<TokenClassificationOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<TokenClassificationOutput>

Defined in

inference/src/tasks/nlp/tokenClassification.ts:12


translation

translation: (args: {}, options?: Options) => Promise\<TranslationOutput>

Type declaration

▸ (args, options?): Promise\<TranslationOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<TranslationOutput>

Defined in

inference/src/tasks/nlp/translation.ts:10


visualQuestionAnswering

visualQuestionAnswering: (args: {}, options?: Options) => Promise\<VisualQuestionAnsweringOutputElement>

Type declaration

▸ (args, options?): Promise\<VisualQuestionAnsweringOutputElement>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<VisualQuestionAnsweringOutputElement>

Defined in

inference/src/tasks/multimodal/visualQuestionAnswering.ts:18


zeroShotClassification

zeroShotClassification: (args: {}, options?: Options) => Promise\<ZeroShotClassificationOutput>

Type declaration

▸ (args, options?): Promise\<ZeroShotClassificationOutput>

Parameters
Name Type
args Object
options? Options
Returns

Promise\<ZeroShotClassificationOutput>

Defined in

inference/src/tasks/nlp/zeroShotClassification.ts:12


zeroShotImageClassification

zeroShotImageClassification: (args: { inputs: { image: Blob | ArrayBuffer } ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}, options?: Options) => Promise\<ZeroShotImageClassificationOutput>

Type declaration

▸ (args, options?): Promise\<ZeroShotImageClassificationOutput>

Parameters
Name Type
args { inputs: { image: Blob | ArrayBuffer } ; model?: string ; provider?: "fal-ai" | "replicate" | "sambanova" | "together" | "hf-inference" } | {}
options? Options
Returns

Promise\<ZeroShotImageClassificationOutput>

Defined in

inference/src/tasks/cv/zeroShotImageClassification.ts:44

< > Update on GitHub