Buckets:

|
download
raw
31.6 kB

Class: InferenceClient

Hierarchy

Constructors

constructor

new InferenceClient(accessToken?, defaultOptions?): InferenceClient

Parameters[[constructor.parameters]]

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

Returns[[constructor.returns]]

InferenceClient

Defined in[[constructor.defined-in]]

inference/src/InferenceClient.ts:15

Properties

accessToken

Private Readonly accessToken: string

Defined in[[accesstoken.defined-in]]

inference/src/InferenceClient.ts:12


defaultOptions

Private Readonly defaultOptions: Options

Defined in[[defaultoptions.defined-in]]

inference/src/InferenceClient.ts:13

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[[audioclassification.parameters]]

Name Type
args AudioClassificationArgs
options? Options

Returns[[audioclassification.returns]]

Promise<AudioClassificationOutput>

Defined in[[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[[audiotoaudio.parameters]]

Name Type
args AudioToAudioArgs
options? Options

Returns[[audiotoaudio.returns]]

Promise<AudioToAudioOutput[]>

Defined in[[audiotoaudio.defined-in]]

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


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[[automaticspeechrecognition.parameters]]

Name Type
args AutomaticSpeechRecognitionArgs
options? Options

Returns[[automaticspeechrecognition.returns]]

Promise<AutomaticSpeechRecognitionOutput>

Defined in[[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[[chatcompletion.parameters]]

Name Type
args BaseArgs & ChatCompletionInput
options? Options

Returns[[chatcompletion.returns]]

Promise<ChatCompletionOutput>

Defined in[[chatcompletion.defined-in]]

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


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[[chatcompletionstream.parameters]]

Name Type
args BaseArgs & ChatCompletionInput
options? Options

Returns[[chatcompletionstream.returns]]

AsyncGenerator<ChatCompletionStreamOutput>

Defined in[[chatcompletionstream.defined-in]]

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


documentQuestionAnswering

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

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

Parameters[[documentquestionanswering.parameters]]

Name Type
args DocumentQuestionAnsweringArgs
options? Options

Returns[[documentquestionanswering.returns]]

Promise<DocumentQuestionAnsweringOutput[number]>

Defined in[[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[[endpoint.parameters]]

Name Type
endpointUrl string

Returns[[endpoint.returns]]

InferenceClient

Defined in[[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[[featureextraction.parameters]]

Name Type
args FeatureExtractionArgs
options? Options

Returns[[featureextraction.returns]]

Promise<FeatureExtractionOutput>

Defined in[[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[[fillmask.parameters]]

Name Type
args FillMaskArgs
options? Options

Returns[[fillmask.returns]]

Promise<FillMaskOutput>

Defined in[[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[[imageclassification.parameters]]

Name Type
args ImageClassificationArgs
options? Options

Returns[[imageclassification.returns]]

Promise<ImageClassificationOutput>

Defined in[[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[[imagesegmentation.parameters]]

Name Type
args ImageSegmentationArgs
options? Options

Returns[[imagesegmentation.returns]]

Promise<ImageSegmentationOutput>

Defined in[[imagesegmentation.defined-in]]

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


imageTextToImage

imageTextToImage(args, options?): Promise<Blob>

This task takes an image and text input and outputs a new generated image. Recommended model: black-forest-labs/FLUX.2-dev

Parameters[[imagetexttoimage.parameters]]

Name Type
args ImageTextToImageArgs
options? Options

Returns[[imagetexttoimage.returns]]

Promise<Blob>

Defined in[[imagetexttoimage.defined-in]]

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


imageTextToVideo

imageTextToVideo(args, options?): Promise<Blob>

This task takes an image and text input and outputs a generated video. Recommended model: Lightricks/LTX-Video

Parameters[[imagetexttovideo.parameters]]

Name Type
args ImageTextToVideoArgs
options? Options

Returns[[imagetexttovideo.returns]]

Promise<Blob>

Defined in[[imagetexttovideo.defined-in]]

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


imageToImage

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

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

Parameters[[imagetoimage.parameters]]

Name Type
args ImageToImageArgs
options? Options

Returns[[imagetoimage.returns]]

Promise<Blob>

Defined in[[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[[imagetotext.parameters]]

Name Type
args ImageToTextArgs
options? Options

Returns[[imagetotext.returns]]

Promise<ImageToTextOutput>

Defined in[[imagetotext.defined-in]]

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


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[[imagetovideo.parameters]]

Name Type
args ImageToVideoArgs
options? Options

Returns[[imagetovideo.returns]]

Promise<Blob>

Defined in[[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[[objectdetection.parameters]]

Name Type
args ObjectDetectionArgs
options? Options

Returns[[objectdetection.returns]]

Promise<ObjectDetectionOutput>

Defined in[[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[[questionanswering.parameters]]

Name Type
args QuestionAnsweringArgs
options? Options

Returns[[questionanswering.returns]]

Promise<QuestionAnsweringOutput[number]>

Defined in[[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[[request.type-parameters]]

Name
T

Parameters[[request.parameters]]

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

Returns[[request.returns]]

Promise<T>

Deprecated

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

Defined in[[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[[sentencesimilarity.parameters]]

Name Type
args SentenceSimilarityArgs
options? Options

Returns[[sentencesimilarity.returns]]

Promise<SentenceSimilarityOutput>

Defined in[[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[[streamingrequest.type-parameters]]

Name
T

Parameters[[streamingrequest.parameters]]

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

Returns[[streamingrequest.returns]]

AsyncGenerator<T>

Deprecated

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

Defined in[[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[[summarization.parameters]]

Name Type
args SummarizationArgs
options? Options

Returns[[summarization.returns]]

Promise<SummarizationOutput>

Defined in[[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[[tablequestionanswering.parameters]]

Name Type
args TableQuestionAnsweringArgs
options? Options

Returns[[tablequestionanswering.returns]]

Promise<TableQuestionAnsweringOutput[number]>

Defined in[[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[[tabularclassification.parameters]]

Name Type
args TabularClassificationArgs
options? Options

Returns[[tabularclassification.returns]]

Promise<TabularClassificationOutput>

Defined in[[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[[tabularregression.parameters]]

Name Type
args TabularRegressionArgs
options? Options

Returns[[tabularregression.returns]]

Promise<TabularRegressionOutput>

Defined in[[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[[textclassification.parameters]]

Name Type
args TextClassificationArgs
options? Options

Returns[[textclassification.returns]]

Promise<TextClassificationOutput>

Defined in[[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[[textgeneration.parameters]]

Name Type
args BaseArgs & TextGenerationInput
options? Options

Returns[[textgeneration.returns]]

Promise<TextGenerationOutput>

Defined in[[textgeneration.defined-in]]

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


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[[textgenerationstream.parameters]]

Name Type
args BaseArgs & TextGenerationInput
options? Options

Returns[[textgenerationstream.returns]]

AsyncGenerator<TextGenerationStreamOutput>

Defined in[[textgenerationstream.defined-in]]

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


textToAudio

textToAudio(args, options?): Promise<Blob>

This task generates audio (e.g. music or sound effects) from an input text prompt. Example model: stabilityai/stable-audio-open-1.0

Parameters[[texttoaudio.parameters]]

Name Type
args TextToAudioArgs
options? Options

Returns[[texttoaudio.returns]]

Promise<Blob>

Defined in[[texttoaudio.defined-in]]

inference/src/tasks/audio/textToAudio.ts:18


textToImage

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

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

Parameters[[texttoimage.parameters]]

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

Returns[[texttoimage.returns]]

Promise<string>

Defined in[[texttoimage.defined-in]]

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

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

Parameters[[texttoimage.parameters]]

Name Type
args TextToImageArgs
options? TextToImageOptions & { outputType: "dataUrl" }

Returns[[texttoimage.returns]]

Promise<string>

Defined in[[texttoimage.defined-in]]

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

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

Parameters[[texttoimage.parameters]]

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

Returns[[texttoimage.returns]]

Promise<Blob>

Defined in[[texttoimage.defined-in]]

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

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

Parameters[[texttoimage.parameters]]

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

Returns[[texttoimage.returns]]

Promise<Record<string, unknown>>

Defined in[[texttoimage.defined-in]]

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


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[[texttospeech.parameters]]

Name Type
args TextToSpeechArgs
options? Options

Returns[[texttospeech.returns]]

Promise<Blob>

Defined in[[texttospeech.defined-in]]

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


textToVideo

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

Parameters[[texttovideo.parameters]]

Name Type
args TextToVideoArgs
options? Options

Returns[[texttovideo.returns]]

Promise<TextToVideoOutput>

Defined in[[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[[tokenclassification.parameters]]

Name Type
args TokenClassificationArgs
options? Options

Returns[[tokenclassification.returns]]

Promise<TokenClassificationOutput>

Defined in[[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[[translation.parameters]]

Name Type
args TranslationArgs
options? Options

Returns[[translation.returns]]

Promise<TranslationOutput>

Defined in[[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[[visualquestionanswering.parameters]]

Name Type
args VisualQuestionAnsweringArgs
options? Options

Returns[[visualquestionanswering.returns]]

Promise<VisualQuestionAnsweringOutput[number]>

Defined in[[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[[zeroshotclassification.parameters]]

Name Type
args ZeroShotClassificationArgs
options? Options

Returns[[zeroshotclassification.returns]]

Promise<ZeroShotClassificationOutput>

Defined in[[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[[zeroshotimageclassification.parameters]]

Name Type
args ZeroShotImageClassificationArgs
options? Options

Returns[[zeroshotimageclassification.returns]]

Promise<ZeroShotImageClassificationOutput>

Defined in[[zeroshotimageclassification.defined-in]]

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

Xet Storage Details

Size:
31.6 kB
·
Xet hash:
35bbd041055e63fe0088352067371646f2e30b4878b104478bdfc6625447e229

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.