#
Class: HfInference

For backward compatibility only, will remove soon.

`Deprecated`

replace with InferenceClient

##
Hierarchy

- `InferenceClient`

  ↳ `HfInference`

##
Constructors

###
constructor

• new HfInference(`accessToken?`, `defaultOptions?`): `HfInference`

####
Parameters

Name | Type | Default value
--- | --- | ---
`accessToken` | `string` | `""`
`defaultOptions` | `Options` & { `endpointUrl?`: `string` } | `{}`

####
Returns

`HfInference`

####
Inherited from

InferenceClient.constructor

####
Defined in

inference/src/InferenceClient.ts:15

##
Methods

###
audioClassification

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

This task reads some audio input and outputs the likelihood of classes. Recommended model: superb/hubert-large-superb-er

####
Parameters

Name | Type
--- | ---
`args` | `AudioClassificationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`AudioClassificationOutput`>

####
Inherited from

InferenceClient.audioClassification

####
Defined in

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

###
audioToAudio

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

This task reads some audio input and outputs one or multiple audio files. Example model: speechbrain/sepformer-wham does audio source separation.

####
Parameters

Name | Type
--- | ---
`args` | `AudioToAudioArgs`
`options?` | `Options`

####
Returns

`Promise`\<`AudioToAudioOutput`[]>

####
Inherited from

InferenceClient.audioToAudio

####
Defined in

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

###
automaticSpeechRecognition

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

This task reads some audio input and outputs the said words within the audio files. Recommended model (english language): facebook/wav2vec2-large-960h-lv60-self

####
Parameters

Name | Type
--- | ---
`args` | `AutomaticSpeechRecognitionArgs`
`options?` | `Options`

####
Returns

`Promise`\<`AutomaticSpeechRecognitionOutput`>

####
Inherited from

InferenceClient.automaticSpeechRecognition

####
Defined in

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

###
chatCompletion

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

Use the chat completion endpoint to generate a response to a prompt, using OpenAI message completion API no stream

####
Parameters

Name | Type
--- | ---
`args` | `BaseArgs` & `ChatCompletionInput`
`options?` | `Options`

####
Returns

`Promise`\<`ChatCompletionOutput`>

####
Inherited from

InferenceClient.chatCompletion

####
Defined in

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

###
chatCompletionStream

▸ chatCompletionStream(`args`, `options?`): `AsyncGenerator`\<`ChatCompletionStreamOutput`>

Use to continue text from a prompt. Same as `textGeneration` but returns generator that can be read one token at a time

####
Parameters

Name | Type
--- | ---
`args` | `BaseArgs` & `ChatCompletionInput`
`options?` | `Options`

####
Returns

`AsyncGenerator`\<`ChatCompletionStreamOutput`>

####
Inherited from

InferenceClient.chatCompletionStream

####
Defined in

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

###
documentQuestionAnswering

▸ documentQuestionAnswering(`args`, `options?`): `Promise`\<`DocumentQuestionAnsweringOutput`[`number`]>

Answers a question on a document image. Recommended model: impira/layoutlm-document-qa.

####
Parameters

Name | Type
--- | ---
`args` | `DocumentQuestionAnsweringArgs`
`options?` | `Options`

####
Returns

`Promise`\<`DocumentQuestionAnsweringOutput`[`number`]>

####
Inherited from

InferenceClient.documentQuestionAnswering

####
Defined in

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

###
endpoint

▸ endpoint(`endpointUrl`): `InferenceClient`

Returns a new instance of InferenceClient tied to a specified endpoint.

For backward compatibility mostly.

####
Parameters

Name | Type
--- | ---
`endpointUrl` | `string`

####
Returns

`InferenceClient`

####
Inherited from

InferenceClient.endpoint

####
Defined in

inference/src/InferenceClient.ts:46

###
featureExtraction

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

This task reads some text and outputs raw float values, that are usually consumed as part of a semantic database/semantic search.

####
Parameters

Name | Type
--- | ---
`args` | `FeatureExtractionArgs`
`options?` | `Options`

####
Returns

`Promise`\<`FeatureExtractionOutput`>

####
Inherited from

InferenceClient.featureExtraction

####
Defined in

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

###
fillMask

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

Tries to fill in a hole with a missing word (token to be precise). That’s the base task for BERT models.

####
Parameters

Name | Type
--- | ---
`args` | `FillMaskArgs`
`options?` | `Options`

####
Returns

`Promise`\<`FillMaskOutput`>

####
Inherited from

InferenceClient.fillMask

####
Defined in

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

###
imageClassification

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

This task reads some image input and outputs the likelihood of classes. Recommended model: google/vit-base-patch16-224

####
Parameters

Name | Type
--- | ---
`args` | `ImageClassificationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`ImageClassificationOutput`>

####
Inherited from

InferenceClient.imageClassification

####
Defined in

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

###
imageSegmentation

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

This task reads some image input and outputs the likelihood of classes & bounding boxes of detected objects. Recommended model: facebook/detr-resnet-50-panoptic

####
Parameters

Name | Type
--- | ---
`args` | `ImageSegmentationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`ImageSegmentationOutput`>

####
Inherited from

InferenceClient.imageSegmentation

####
Defined in

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

###
imageToImage

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

This task reads some text input and outputs an image. Recommended model: lllyasviel/sd-controlnet-depth

####
Parameters

Name | Type
--- | ---
`args` | `ImageToImageArgs`
`options?` | `Options`

####
Returns

`Promise`\<`Blob`>

####
Inherited from

InferenceClient.imageToImage

####
Defined in

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

###
imageToText

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

This task reads some image input and outputs the text caption.

####
Parameters

Name | Type
--- | ---
`args` | `ImageToTextArgs`
`options?` | `Options`

####
Returns

`Promise`\<`ImageToTextOutput`>

####
Inherited from

InferenceClient.imageToText

####
Defined in

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

###
imageToVideo

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

This task reads some text input and outputs an image. Recommended model: Wan-AI/Wan2.1-I2V-14B-720P

####
Parameters

Name | Type
--- | ---
`args` | `ImageToVideoArgs`
`options?` | `Options`

####
Returns

`Promise`\<`Blob`>

####
Inherited from

InferenceClient.imageToVideo

####
Defined in

inference/src/tasks/cv/imageToVideo.ts:14

###
objectDetection

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

This task reads some image input and outputs the likelihood of classes & bounding boxes of detected objects. Recommended model: facebook/detr-resnet-50

####
Parameters

Name | Type
--- | ---
`args` | `ObjectDetectionArgs`
`options?` | `Options`

####
Returns

`Promise`\<`ObjectDetectionOutput`>

####
Inherited from

InferenceClient.objectDetection

####
Defined in

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

###
questionAnswering

▸ questionAnswering(`args`, `options?`): `Promise`\<`QuestionAnsweringOutput`[`number`]>

Want to have a nice know-it-all bot that can answer any question?. Recommended model: deepset/roberta-base-squad2

####
Parameters

Name | Type
--- | ---
`args` | `QuestionAnsweringArgs`
`options?` | `Options`

####
Returns

`Promise`\<`QuestionAnsweringOutput`[`number`]>

####
Inherited from

InferenceClient.questionAnswering

####
Defined in

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

###
request

▸ request\<`T`>(`args`, `options?`): `Promise`\<`T`>

Primitive to make custom calls to the inference provider

####
Type parameters

Name
`T`

####
Parameters

Name | Type
--- | ---
`args` | `RequestArgs`
`options?` | `Options` & { `task?`: `InferenceTask` }

####
Returns

`Promise`\<`T`>

`Deprecated`

Use specific task functions instead. This function will be removed in a future version.

####
Inherited from

InferenceClient.request

####
Defined in

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

###
sentenceSimilarity

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

Calculate the semantic similarity between one text and a list of other sentences by comparing their embeddings.

####
Parameters

Name | Type
--- | ---
`args` | `SentenceSimilarityArgs`
`options?` | `Options`

####
Returns

`Promise`\<`SentenceSimilarityOutput`>

####
Inherited from

InferenceClient.sentenceSimilarity

####
Defined in

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

###
streamingRequest

▸ streamingRequest\<`T`>(`args`, `options?`): `AsyncGenerator`\<`T`>

Primitive to make custom inference calls that expect server-sent events, and returns the response through a generator

####
Type parameters

Name
`T`

####
Parameters

Name | Type
--- | ---
`args` | `RequestArgs`
`options?` | `Options` & { `task?`: `InferenceTask` }

####
Returns

`AsyncGenerator`\<`T`>

`Deprecated`

Use specific task functions instead. This function will be removed in a future version.

####
Inherited from

InferenceClient.streamingRequest

####
Defined in

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

###
summarization

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

This task is well known to summarize longer text into shorter text. Be careful, some models have a maximum length of input. That means that the summary cannot handle full books for instance. Be careful when choosing your model.

####
Parameters

Name | Type
--- | ---
`args` | `SummarizationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`SummarizationOutput`>

####
Inherited from

InferenceClient.summarization

####
Defined in

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

###
tableQuestionAnswering

▸ tableQuestionAnswering(`args`, `options?`): `Promise`\<`TableQuestionAnsweringOutput`[`number`]>

Don’t know SQL? Don’t want to dive into a large spreadsheet? Ask questions in plain english! Recommended model: google/tapas-base-finetuned-wtq.

####
Parameters

Name | Type
--- | ---
`args` | `TableQuestionAnsweringArgs`
`options?` | `Options`

####
Returns

`Promise`\<`TableQuestionAnsweringOutput`[`number`]>

####
Inherited from

InferenceClient.tableQuestionAnswering

####
Defined in

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

###
tabularClassification

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

Predicts target label for a given set of features in tabular form. Typically, you will want to train a classification model on your training data and use it with your new data of the same format. Example model: vvmnnnkv/wine-quality

####
Parameters

Name | Type
--- | ---
`args` | `TabularClassificationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`TabularClassificationOutput`>

####
Inherited from

InferenceClient.tabularClassification

####
Defined in

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

###
tabularRegression

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

Predicts target value for a given set of features in tabular form. Typically, you will want to train a regression model on your training data and use it with your new data of the same format. Example model: scikit-learn/Fish-Weight

####
Parameters

Name | Type
--- | ---
`args` | `TabularRegressionArgs`
`options?` | `Options`

####
Returns

`Promise`\<`TabularRegressionOutput`>

####
Inherited from

InferenceClient.tabularRegression

####
Defined in

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

###
textClassification

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

Usually used for sentiment-analysis this will output the likelihood of classes of an input. Recommended model: distilbert-base-uncased-finetuned-sst-2-english

####
Parameters

Name | Type
--- | ---
`args` | `TextClassificationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`TextClassificationOutput`>

####
Inherited from

InferenceClient.textClassification

####
Defined in

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

###
textGeneration

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

Use to continue text from a prompt. This is a very generic task. Recommended model: gpt2 (it’s a simple model, but fun to play with).

####
Parameters

Name | Type
--- | ---
`args` | `BaseArgs` & `TextGenerationInput`
`options?` | `Options`

####
Returns

`Promise`\<`TextGenerationOutput`>

####
Inherited from

InferenceClient.textGeneration

####
Defined in

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

###
textGenerationStream

▸ textGenerationStream(`args`, `options?`): `AsyncGenerator`\<`TextGenerationStreamOutput`>

Use to continue text from a prompt. Same as `textGeneration` but returns generator that can be read one token at a time

####
Parameters

Name | Type
--- | ---
`args` | `BaseArgs` & `TextGenerationInput`
`options?` | `Options`

####
Returns

`AsyncGenerator`\<`TextGenerationStreamOutput`>

####
Inherited from

InferenceClient.textGenerationStream

####
Defined in

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

###
textToImage

▸ textToImage(`args`, `options?`): `Promise`\<`string`>

This task reads some text input and outputs an image. Recommended model: stabilityai/stable-diffusion-2

####
Parameters

Name | Type
--- | ---
`args` | `TextToImageArgs`
`options?` | `TextToImageOptions` & { `outputType`: `"url"` }

####
Returns

`Promise`\<`string`>

####
Inherited from

InferenceClient.textToImage

####
Defined in

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

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

####
Parameters

Name | Type
--- | ---
`args` | `TextToImageArgs`
`options?` | `TextToImageOptions` & { `outputType?`: `"blob"` }

####
Returns

`Promise`\<`Blob`>

####
Inherited from

InferenceClient.textToImage

####
Defined in

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

▸ textToImage(`args`, `options?`): `Promise`\<`Record`\<`string`, `unknown`>>

####
Parameters

Name | Type
--- | ---
`args` | `TextToImageArgs`
`options?` | `TextToImageOptions` & { `outputType?`: `"json"` }

####
Returns

`Promise`\<`Record`\<`string`, `unknown`>>

####
Inherited from

InferenceClient.textToImage

####
Defined in

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

###
textToSpeech

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

This task synthesize an audio of a voice pronouncing a given text. Recommended model: espnet/kan-bayashi_ljspeech_vits

####
Parameters

Name | Type
--- | ---
`args` | `TextToSpeechArgs`
`options?` | `Options`

####
Returns

`Promise`\<`Blob`>

####
Inherited from

InferenceClient.textToSpeech

####
Defined in

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

###
textToVideo

▸ textToVideo(`args`, `options?`): `Promise`\<`TextToVideoOutput`>

####
Parameters

Name | Type
--- | ---
`args` | `TextToVideoArgs`
`options?` | `Options`

####
Returns

`Promise`\<`TextToVideoOutput`>

####
Inherited from

InferenceClient.textToVideo

####
Defined in

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

###
tokenClassification

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

Usually used for sentence parsing, either grammatical, or Named Entity Recognition (NER) to understand keywords contained within text. Recommended model: dbmdz/bert-large-cased-finetuned-conll03-english

####
Parameters

Name | Type
--- | ---
`args` | `TokenClassificationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`TokenClassificationOutput`>

####
Inherited from

InferenceClient.tokenClassification

####
Defined in

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

###
translation

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

This task is well known to translate text from one language to another. Recommended model: Helsinki-NLP/opus-mt-ru-en.

####
Parameters

Name | Type
--- | ---
`args` | `TranslationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`TranslationOutput`>

####
Inherited from

InferenceClient.translation

####
Defined in

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

###
visualQuestionAnswering

▸ visualQuestionAnswering(`args`, `options?`): `Promise`\<`VisualQuestionAnsweringOutput`[`number`]>

Answers a question on an image. Recommended model: dandelin/vilt-b32-finetuned-vqa.

####
Parameters

Name | Type
--- | ---
`args` | `VisualQuestionAnsweringArgs`
`options?` | `Options`

####
Returns

`Promise`\<`VisualQuestionAnsweringOutput`[`number`]>

####
Inherited from

InferenceClient.visualQuestionAnswering

####
Defined in

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

###
zeroShotClassification

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

This task is super useful to try out classification with zero code, you simply pass a sentence/paragraph and the possible labels for that sentence, and you get a result. Recommended model: facebook/bart-large-mnli.

####
Parameters

Name | Type
--- | ---
`args` | `ZeroShotClassificationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`ZeroShotClassificationOutput`>

####
Inherited from

InferenceClient.zeroShotClassification

####
Defined in

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

###
zeroShotImageClassification

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

Classify an image to specified classes. Recommended model: openai/clip-vit-large-patch14-336

####
Parameters

Name | Type
--- | ---
`args` | `ZeroShotImageClassificationArgs`
`options?` | `Options`

####
Returns

`Promise`\<`ZeroShotImageClassificationOutput`>

####
Inherited from

InferenceClient.zeroShotImageClassification

####
Defined in

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

Update on GitHub