import{s as Yn,o as Ln,n as He}from"../chunks/scheduler.6062bdaf.js";import{S as Xn,i as Qn,g as h,s,r,A as En,h as d,f as n,c as l,j as zn,u as o,x as m,k as Rn,y as An,a,v as p,d as g,t as f,w as u}from"../chunks/index.4bca734e.js";import{T as Se}from"../chunks/Tip.b9ac1f03.js";import{C as _}from"../chunks/CodeBlock.fa01571c.js";import{H as j,E as Fn}from"../chunks/EditOnGithub.74ab2baa.js";function Pn(w){let i,y=`<a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> is a Python client making HTTP calls to our APIs. If you want to make the HTTP calls directly using
your preferred tool (curl, postman,…), please refer to the <a href="https://huggingface.co/docs/api-inference/index" rel="nofollow">Inference API</a>
or to the <a href="https://huggingface.co/docs/inference-endpoints/index" rel="nofollow">Inference Endpoints</a> documentation pages.`,c,b,C=`For web development, a <a href="https://huggingface.co/docs/huggingface.js/inference/README" rel="nofollow">JS client</a> has been released.
If you are interested in game development, you might have a look at our <a href="https://github.com/huggingface/unity-api" rel="nofollow">C# project</a>.`;return{c(){i=h("p"),i.innerHTML=y,c=s(),b=h("p"),b.innerHTML=C},l($){i=d($,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1be8gtn"&&(i.innerHTML=y),c=l($),b=d($,"P",{"data-svelte-h":!0}),m(b)!=="svelte-22w7rm"&&(b.innerHTML=C)},m($,M){a($,i,M),a($,c,M),a($,b,M)},p:He,d($){$&&(n(i),n(c),n(b))}}}function Kn(w){let i,y=`The API is designed to be simple. Not all parameters and options are available or described for the end user. Check out
<a href="https://huggingface.co/docs/api-inference/detailed_parameters" rel="nofollow">this page</a> if you are interested in learning more about
all the parameters available for each task.`;return{c(){i=h("p"),i.innerHTML=y},l(c){i=d(c,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1o4uc5e"&&(i.innerHTML=y)},m(c,b){a(c,i,b)},p:He,d(c){c&&n(i)}}}function Dn(w){let i,y=`There are more than 200k models on the Hugging Face Hub! Each task in the <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> comes with a recommended
model. Be aware that the HF recommendation can change over time without prior notice. Therefore it is best to explicitly
set a model once you are decided. Also, in most cases you’ll be interested in finding a model specific to <em>your</em> needs.
Visit the <a href="https://huggingface.co/models" rel="nofollow">Models</a> page on the Hub to explore your possibilities.`;return{c(){i=h("p"),i.innerHTML=y},l(c){i=d(c,"P",{"data-svelte-h":!0}),m(i)!=="svelte-17gz0m2"&&(i.innerHTML=y)},m(c,b){a(c,i,b)},p:He,d(c){c&&n(i)}}}function On(w){let i,y=`Authentication is NOT mandatory when using the Inference API. However, authenticated users get a higher free-tier to
play with the service. Token is also mandatory if you want to run inference on your private models or on private
endpoints.`;return{c(){i=h("p"),i.textContent=y},l(c){i=d(c,"P",{"data-svelte-h":!0}),m(i)!=="svelte-7vtkgf"&&(i.textContent=y)},m(c,b){a(c,i,b)},p:He,d(c){c&&n(i)}}}function ea(w){let i,y=`Check out the <a href="https://huggingface.co/tasks" rel="nofollow">Tasks</a> page to learn more about each task, how to use them, and the
most popular models for each task.`;return{c(){i=h("p"),i.innerHTML=y},l(c){i=d(c,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1u4hr1j"&&(i.innerHTML=y)},m(c,b){a(c,i,b)},p:He,d(c){c&&n(i)}}}function ta(w){let i,y=`This is the recommended way to adapt your code to <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a>. It lets you benefit from the task-specific
methods like <code>feature_extraction</code>.`;return{c(){i=h("p"),i.innerHTML=y},l(c){i=d(c,"P",{"data-svelte-h":!0}),m(i)!=="svelte-vp4r81"&&(i.innerHTML=y)},m(c,b){a(c,i,b)},p:He,d(c){c&&n(i)}}}function na(w){let i,y,c,b,C,$,M,sn=`Inference is the process of using a trained model to make predictions on new data. As this process can be compute-intensive,
running on a dedicated server can be an interesting option. The <code>huggingface_hub</code> library provides an easy way to call a
service that runs inference for hosted models. There are several services you can connect to:`,Re,W,ln=`<li><a href="https://huggingface.co/docs/api-inference/index" rel="nofollow">Inference API</a>: a service that allows you to run accelerated inference
on Hugging Face’s infrastructure for free. This service is a fast way to get started, test different models, and
prototype AI products.</li> <li><a href="https://huggingface.co/docs/inference-endpoints/index" rel="nofollow">Inference Endpoints</a>: a product to easily deploy models to production.
Inference is run by Hugging Face in a dedicated, fully managed infrastructure on a cloud provider of your choice.</li>`,Ye,v,cn=`These services can be called with the <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> object. It acts as a replacement for the legacy
<a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceApi">InferenceApi</a> client, adding specific support for tasks and handling inference on both
<a href="https://huggingface.co/docs/api-inference/index" rel="nofollow">Inference API</a> and <a href="https://huggingface.co/docs/inference-endpoints/index" rel="nofollow">Inference Endpoints</a>.
Learn how to migrate to the new client in the <a href="#legacy-inferenceapi-client">Legacy InferenceAPI client</a> section.`,Le,U,Xe,x,Qe,G,rn="Let’s get started with a text-to-image task:",Ee,V,Ae,q,on=`We initialized an <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> with the default parameters. The only thing you need to know is the <a href="#supported-tasks">task</a> you want
to perform. By default, the client will connect to the Inference API and select a model to complete the task. In our
example, we generated an image from a text prompt. The returned value is a <code>PIL.Image</code> object that can be saved to a
file.`,Fe,I,Pe,N,Ke,B,pn="What if you want to use a specific model? You can specify it either as a parameter or directly at an instance level:",De,S,Oe,Z,et,H,tt,z,gn=`The examples we saw above use the Serverless Inference API. This proves to be very useful for prototyping
and testing things quickly. Once you’re ready to deploy your model to production, you’ll need to use a dedicated infrastructure.
That’s where <a href="https://huggingface.co/docs/inference-endpoints/index" rel="nofollow">Inference Endpoints</a> comes into play. It allows you to deploy
any model and expose it as a private API. Once deployed, you’ll get a URL that you can connect to using exactly the same
code as before, changing only the <code>model</code> parameter:`,nt,R,at,Y,st,L,fn=`Calls made with the <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> can be authenticated using a <a href="https://huggingface.co/docs/hub/security-tokens" rel="nofollow">User Access Token</a>.
By default, it will use the token saved on your machine if you are logged in (check out
<a href="https://huggingface.co/docs/huggingface_hub/quick-start#authentication" rel="nofollow">how to authenticate</a>). If you are not logged in, you can pass
your token as an instance parameter:`,lt,X,it,k,ct,Q,rt,E,un=`<a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a>’s goal is to provide the easiest interface to run inference on Hugging Face models. It
has a simple API that supports the most common tasks. Here is a list of the currently supported tasks:`,ot,A,hn='<thead><tr><th>Domain</th> <th>Task</th> <th>Supported</th> <th>Documentation</th></tr></thead> <tbody><tr><td>Audio</td> <td><a href="https://huggingface.co/tasks/audio-classification" rel="nofollow">Audio Classification</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.audio_classification">audio_classification()</a></td></tr> <tr><td>Audio</td> <td><a href="https://huggingface.co/tasks/audio-to-audio" rel="nofollow">Audio-to-Audio</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.audio_to_audio">audio_to_audio()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/automatic-speech-recognition" rel="nofollow">Automatic Speech Recognition</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.automatic_speech_recognition">automatic_speech_recognition()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/text-to-speech" rel="nofollow">Text-to-Speech</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.text_to_speech">text_to_speech()</a></td></tr> <tr><td>Computer Vision</td> <td><a href="https://huggingface.co/tasks/image-classification" rel="nofollow">Image Classification</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.image_classification">image_classification()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/image-segmentation" rel="nofollow">Image Segmentation</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.image_segmentation">image_segmentation()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/image-to-image" rel="nofollow">Image-to-Image</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.image_to_image">image_to_image()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/image-to-text" rel="nofollow">Image-to-Text</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.image_to_text">image_to_text()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/object-detection" rel="nofollow">Object Detection</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.object_detection">object_detection()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/text-to-image" rel="nofollow">Text-to-Image</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.text_to_image">text_to_image()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/zero-shot-image-classification" rel="nofollow">Zero-Shot-Image-Classification</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.zero_shot_image_classification">zero_shot_image_classification()</a></td></tr> <tr><td>Multimodal</td> <td><a href="https://huggingface.co/tasks/document-question-answering" rel="nofollow">Documentation Question Answering</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.document_question_answering">document_question_answering()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/visual-question-answering" rel="nofollow">Visual Question Answering</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.visual_question_answering">visual_question_answering()</a></td></tr> <tr><td>NLP</td> <td>Conversational</td> <td></td> <td><em>deprecated</em>, use Chat Completion</td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/text-generation" rel="nofollow">Chat Completion</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.chat_completion">chat_completion()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/feature-extraction" rel="nofollow">Feature Extraction</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.feature_extraction">feature_extraction()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/fill-mask" rel="nofollow">Fill Mask</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.fill_mask">fill_mask()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/question-answering" rel="nofollow">Question Answering</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.question_answering">question_answering()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/sentence-similarity" rel="nofollow">Sentence Similarity</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.sentence_similarity">sentence_similarity()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/summarization" rel="nofollow">Summarization</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.summarization">summarization()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/table-question-answering" rel="nofollow">Table Question Answering</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.table_question_answering">table_question_answering()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/text-classification" rel="nofollow">Text Classification</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.text_classification">text_classification()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/text-generation" rel="nofollow">Text Generation</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.text_generation">text_generation()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/token-classification" rel="nofollow">Token Classification</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.token_classification">token_classification()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/translation" rel="nofollow">Translation</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.translation">translation()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/zero-shot-classification" rel="nofollow">Zero Shot Classification</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.zero_shot_classification">zero_shot_classification()</a></td></tr> <tr><td>Tabular</td> <td><a href="https://huggingface.co/tasks/tabular-classification" rel="nofollow">Tabular Classification</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.tabular_classification">tabular_classification()</a></td></tr> <tr><td></td> <td><a href="https://huggingface.co/tasks/tabular-regression" rel="nofollow">Tabular Regression</a></td> <td>✅</td> <td><a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.tabular_regression">tabular_regression()</a></td></tr></tbody>',pt,T,gt,F,ft,P,dn=`However, it is not always possible to cover all use cases. For custom requests, the <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.post">InferenceClient.post()</a> method
gives you the flexibility to send any request to the Inference API. For example, you can specify how to parse the inputs
and outputs. In the example below, the generated image is returned as raw bytes instead of parsing it as a <code>PIL Image</code>.
This can be helpful if you don’t have <code>Pillow</code> installed in your setup and just care about the binary content of the
image. <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient.post">InferenceClient.post()</a> is also useful to handle tasks that are not yet officially supported.`,ut,K,ht,D,dt,O,mn=`An async version of the client is also provided, based on <code>asyncio</code> and <code>aiohttp</code>. You can either install <code>aiohttp</code>
directly or use the <code>[inference]</code> extra:`,mt,ee,yt,te,yn=`After installation all async API endpoints are available via <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.AsyncInferenceClient">AsyncInferenceClient</a>. Its initialization and APIs are
strictly the same as the sync-only version.`,bt,ne,_t,ae,bn='For more information about the <code>asyncio</code> module, please refer to the <a href="https://docs.python.org/3/library/asyncio.html" rel="nofollow">official documentation</a>.',jt,se,wt,le,_n='In the above section, we saw the main aspects of <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a>. Let’s dive into some more advanced tips.',$t,ie,Mt,ce,jn="When doing inference, there are two main causes for a timeout:",Ct,re,wn="<li>The inference process takes a long time to complete.</li> <li>The model is not available, for example when Inference API is loading it for the first time.</li>",Ut,oe,$n=`<a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> has a global <code>timeout</code> parameter to handle those two aspects. By default, it is set to <code>None</code>,
meaning that the client will wait indefinitely for the inference to complete. If you want more control in your workflow,
you can set it to a specific value in seconds. If the timeout delay expires, an <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceTimeoutError">InferenceTimeoutError</a> is raised.
You can catch it and handle it in your code:`,It,pe,Zt,ge,kt,fe,Mn=`Some tasks require binary inputs, for example, when dealing with images or audio files. In this case, <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a>
tries to be as permissive as possible and accept different types:`,Tt,ue,Cn=`<li>raw <code>bytes</code></li> <li>a file-like object, opened as binary (<code>with open(&quot;audio.flac&quot;, &quot;rb&quot;) as f: ...</code>)</li> <li>a path (<code>str</code> or <code>Path</code>) pointing to a local file</li> <li>a URL (<code>str</code>) pointing to a remote file (e.g. <code>https://...</code>). In this case, the file will be downloaded locally before
sending it to the Inference API.</li>`,Jt,he,Wt,de,vt,me,Un=`<a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> acts as a replacement for the legacy <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceApi">InferenceApi</a> client. It adds specific support for tasks and
handles inference on both <a href="https://huggingface.co/docs/api-inference/index" rel="nofollow">Inference API</a> and <a href="https://huggingface.co/docs/inference-endpoints/index" rel="nofollow">Inference Endpoints</a>.`,xt,ye,In='Here is a short guide to help you migrate from <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceApi">InferenceApi</a> to <a href="/docs/huggingface_hub/main/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a>.',Gt,be,Vt,_e,Zn="Change from",qt,je,Nt,we,kn="to",Bt,$e,St,Me,Ht,Ce,Tn="Change from",zt,Ue,Rt,Ie,Jn="to",Yt,Ze,Lt,J,Xt,ke,Qt,Te,Wn="Change from",Et,Je,At,We,vn="to",Ft,ve,Pt,xe,Kt,Ge,xn="Change from",Dt,Ve,Ot,qe,Gn="to",en,Ne,tn,Be,nn,ze,an;return C=new j({props:{title:"Run Inference on servers",local:"run-inference-on-servers",headingTag:"h1"}}),U=new Se({props:{$$slots:{default:[Pn]},$$scope:{ctx:w}}}),x=new j({props:{title:"Getting started",local:"getting-started",headingTag:"h2"}}),V=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCgpJTBBJTBBaW1hZ2UlMjAlM0QlMjBjbGllbnQudGV4dF90b19pbWFnZSglMjJBbiUyMGFzdHJvbmF1dCUyMHJpZGluZyUyMGElMjBob3JzZSUyMG9uJTIwdGhlJTIwbW9vbi4lMjIpJTBBaW1hZ2Uuc2F2ZSglMjJhc3Ryb25hdXQucG5nJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient()

<span class="hljs-meta">&gt;&gt;&gt; </span>image = client.text_to_image(<span class="hljs-string">&quot;An astronaut riding a horse on the moon.&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;astronaut.png&quot;</span>)`,wrap:!1}}),I=new Se({props:{warning:!0,$$slots:{default:[Kn]},$$scope:{ctx:w}}}),N=new j({props:{title:"Using a specific model",local:"using-a-specific-model",headingTag:"h3"}}),S=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRCUyMnByb21wdGhlcm8lMkZvcGVuam91cm5leS12NCUyMiklMEFjbGllbnQudGV4dF90b19pbWFnZSguLi4pJTBBY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KCklMEFjbGllbnQudGV4dF90b19pbWFnZSguLi4lMkMlMjBtb2RlbCUzRCUyMnByb21wdGhlcm8lMkZvcGVuam91cm5leS12NCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-comment"># Initialize client for a specific model</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient(model=<span class="hljs-string">&quot;prompthero/openjourney-v4&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>client.text_to_image(...)
<span class="hljs-comment"># Or use a generic client but pass your model as an argument</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient()
<span class="hljs-meta">&gt;&gt;&gt; </span>client.text_to_image(..., model=<span class="hljs-string">&quot;prompthero/openjourney-v4&quot;</span>)`,wrap:!1}}),Z=new Se({props:{$$slots:{default:[Dn]},$$scope:{ctx:w}}}),H=new j({props:{title:"Using a specific URL",local:"using-a-specific-url",headingTag:"h3"}}),R=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRCUyMmh0dHBzJTNBJTJGJTJGdXUxNDlyZXo2Z3c5ZWhlai5ldS13ZXN0LTEuYXdzLmVuZHBvaW50cy5odWdnaW5nZmFjZS5jbG91ZCUyRmRlZXBmbG95ZC1pZiUyMiklMEFjbGllbnQlMjAlM0QlMjBJbmZlcmVuY2VDbGllbnQoKSUwQWNsaWVudC50ZXh0X3RvX2ltYWdlKC4uLiUyQyUyMG1vZGVsJTNEJTIyaHR0cHMlM0ElMkYlMkZ1dTE0OXJlejZndzllaGVqLmV1LXdlc3QtMS5hd3MuZW5kcG9pbnRzLmh1Z2dpbmdmYWNlLmNsb3VkJTJGZGVlcGZsb3lkLWlmJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient(model=<span class="hljs-string">&quot;https://uu149rez6gw9ehej.eu-west-1.aws.endpoints.huggingface.cloud/deepfloyd-if&quot;</span>)
<span class="hljs-comment"># or</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient()
<span class="hljs-meta">&gt;&gt;&gt; </span>client.text_to_image(..., model=<span class="hljs-string">&quot;https://uu149rez6gw9ehej.eu-west-1.aws.endpoints.huggingface.cloud/deepfloyd-if&quot;</span>)`,wrap:!1}}),Y=new j({props:{title:"Authentication",local:"authentication",headingTag:"h3"}}),X=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCh0b2tlbiUzRCUyMmhmXyoqKiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient(token=<span class="hljs-string">&quot;hf_***&quot;</span>)`,wrap:!1}}),k=new Se({props:{$$slots:{default:[On]},$$scope:{ctx:w}}}),Q=new j({props:{title:"Supported tasks",local:"supported-tasks",headingTag:"h2"}}),T=new Se({props:{$$slots:{default:[ea]},$$scope:{ctx:w}}}),F=new j({props:{title:"Custom requests",local:"custom-requests",headingTag:"h2"}}),K=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCgpJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQucG9zdChqc29uJTNEJTdCJTIyaW5wdXRzJTIyJTNBJTIwJTIyQW4lMjBhc3Ryb25hdXQlMjByaWRpbmclMjBhJTIwaG9yc2UlMjBvbiUyMHRoZSUyMG1vb24uJTIyJTdEJTJDJTIwbW9kZWwlM0QlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24tMi0xJTIyKSUwQXJlc3BvbnNlLmNvbnRlbnQlMjAlMjMlMjByYXclMjBieXRlcw==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient()
<span class="hljs-meta">&gt;&gt;&gt; </span>response = client.post(json={<span class="hljs-string">&quot;inputs&quot;</span>: <span class="hljs-string">&quot;An astronaut riding a horse on the moon.&quot;</span>}, model=<span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>response.content <span class="hljs-comment"># raw bytes</span>
<span class="hljs-string">b&#x27;...&#x27;</span>`,wrap:!1}}),D=new j({props:{title:"Async client",local:"async-client",headingTag:"h2"}}),ee=new _({props:{code:"cGlwJTIwaW5zdGFsbCUyMC0tdXBncmFkZSUyMGh1Z2dpbmdmYWNlX2h1YiU1QmluZmVyZW5jZSU1RCUwQSUyMyUyMG9yJTBBJTIzJTIwcGlwJTIwaW5zdGFsbCUyMGFpb2h0dHA=",highlighted:`pip install --upgrade huggingface_hub[inference]
<span class="hljs-comment"># or</span>
<span class="hljs-comment"># pip install aiohttp</span>`,wrap:!1}}),ne=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEFzeW5jSW5mZXJlbmNlQ2xpZW50JTBBY2xpZW50JTIwJTNEJTIwQXN5bmNJbmZlcmVuY2VDbGllbnQoKSUwQSUwQWltYWdlJTIwJTNEJTIwYXdhaXQlMjBjbGllbnQudGV4dF90b19pbWFnZSglMjJBbiUyMGFzdHJvbmF1dCUyMHJpZGluZyUyMGElMjBob3JzZSUyMG9uJTIwdGhlJTIwbW9vbi4lMjIpJTBBaW1hZ2Uuc2F2ZSglMjJhc3Ryb25hdXQucG5nJTIyKSUwQSUwQWFzeW5jJTIwZm9yJTIwdG9rZW4lMjBpbiUyMGF3YWl0JTIwY2xpZW50LnRleHRfZ2VuZXJhdGlvbiglMjJUaGUlMjBIdWdnaW5nZmFjZSUyMEh1YiUyMGlzJTIyJTJDJTIwc3RyZWFtJTNEVHJ1ZSklM0ElMEElMjAlMjAlMjAlMjBwcmludCh0b2tlbiUyQyUyMGVuZCUzRCUyMiUyMik=",highlighted:`<span class="hljs-comment"># Code must be run in a asyncio concurrent context.</span>
<span class="hljs-comment"># $ python -m asyncio</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> AsyncInferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = AsyncInferenceClient()

<span class="hljs-meta">&gt;&gt;&gt; </span>image = <span class="hljs-keyword">await</span> client.text_to_image(<span class="hljs-string">&quot;An astronaut riding a horse on the moon.&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;astronaut.png&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">async</span> <span class="hljs-keyword">for</span> token <span class="hljs-keyword">in</span> <span class="hljs-keyword">await</span> client.text_generation(<span class="hljs-string">&quot;The Huggingface Hub is&quot;</span>, stream=<span class="hljs-literal">True</span>):
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(token, end=<span class="hljs-string">&quot;&quot;</span>)
 a platform <span class="hljs-keyword">for</span> sharing <span class="hljs-keyword">and</span> discussing ML-related content.`,wrap:!1}}),se=new j({props:{title:"Advanced tips",local:"advanced-tips",headingTag:"h2"}}),ie=new j({props:{title:"Timeout",local:"timeout",headingTag:"h3"}}),pe=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUyQyUyMEluZmVyZW5jZVRpbWVvdXRFcnJvciUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCh0aW1lb3V0JTNEMzApJTBBdHJ5JTNBJTBBJTIwJTIwJTIwJTIwY2xpZW50LnRleHRfdG9faW1hZ2UoLi4uKSUwQWV4Y2VwdCUyMEluZmVyZW5jZVRpbWVvdXRFcnJvciUzQSUwQSUyMCUyMCUyMCUyMHByaW50KCUyMkluZmVyZW5jZSUyMHRpbWVkJTIwb3V0JTIwYWZ0ZXIlMjAzMHMuJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient, InferenceTimeoutError
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient(timeout=<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">try</span>:
<span class="hljs-meta">... </span>    client.text_to_image(...)
<span class="hljs-meta">... </span><span class="hljs-keyword">except</span> InferenceTimeoutError:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Inference timed out after 30s.&quot;</span>)`,wrap:!1}}),ge=new j({props:{title:"Binary inputs",local:"binary-inputs",headingTag:"h3"}}),he=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCgpJTBBY2xpZW50LmltYWdlX2NsYXNzaWZpY2F0aW9uKCUyMmh0dHBzJTNBJTJGJTJGdXBsb2FkLndpa2ltZWRpYS5vcmclMkZ3aWtpcGVkaWElMkZjb21tb25zJTJGdGh1bWIlMkY0JTJGNDMlMkZDdXRlX2RvZy5qcGclMkYzMjBweC1DdXRlX2RvZy5qcGclMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient()
<span class="hljs-meta">&gt;&gt;&gt; </span>client.image_classification(<span class="hljs-string">&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Cute_dog.jpg/320px-Cute_dog.jpg&quot;</span>)
[{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9779096841812134</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;Blenheim spaniel&#x27;</span>}, ...]`,wrap:!1}}),de=new j({props:{title:"Legacy InferenceAPI client",local:"legacy-inferenceapi-client",headingTag:"h2"}}),be=new j({props:{title:"Initialization",local:"initialization",headingTag:"h3"}}),je=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUFwaSUwQWluZmVyZW5jZSUyMCUzRCUyMEluZmVyZW5jZUFwaShyZXBvX2lkJTNEJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIlMkMlMjB0b2tlbiUzREFQSV9UT0tFTik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceApi
<span class="hljs-meta">&gt;&gt;&gt; </span>inference = InferenceApi(repo_id=<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, token=API_TOKEN)`,wrap:!1}}),$e=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWluZmVyZW5jZSUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwdG9rZW4lM0RBUElfVE9LRU4p",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>inference = InferenceClient(model=<span class="hljs-string">&quot;bert-base-uncased&quot;</span>, token=API_TOKEN)`,wrap:!1}}),Me=new j({props:{title:"Run on a specific task",local:"run-on-a-specific-task",headingTag:"h3"}}),Ue=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUFwaSUwQWluZmVyZW5jZSUyMCUzRCUyMEluZmVyZW5jZUFwaShyZXBvX2lkJTNEJTIycGFyYXBocmFzZS14bG0tci1tdWx0aWxpbmd1YWwtdjElMjIlMkMlMjB0YXNrJTNEJTIyZmVhdHVyZS1leHRyYWN0aW9uJTIyKSUwQWluZmVyZW5jZSguLi4p",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceApi
<span class="hljs-meta">&gt;&gt;&gt; </span>inference = InferenceApi(repo_id=<span class="hljs-string">&quot;paraphrase-xlm-r-multilingual-v1&quot;</span>, task=<span class="hljs-string">&quot;feature-extraction&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inference(...)`,wrap:!1}}),Ze=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWluZmVyZW5jZSUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCgpJTBBaW5mZXJlbmNlLmZlYXR1cmVfZXh0cmFjdGlvbiguLi4lMkMlMjBtb2RlbCUzRCUyMnBhcmFwaHJhc2UteGxtLXItbXVsdGlsaW5ndWFsLXYxJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>inference = InferenceClient()
<span class="hljs-meta">&gt;&gt;&gt; </span>inference.feature_extraction(..., model=<span class="hljs-string">&quot;paraphrase-xlm-r-multilingual-v1&quot;</span>)`,wrap:!1}}),J=new Se({props:{$$slots:{default:[ta]},$$scope:{ctx:w}}}),ke=new j({props:{title:"Run custom request",local:"run-custom-request",headingTag:"h3"}}),Je=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUFwaSUwQWluZmVyZW5jZSUyMCUzRCUyMEluZmVyZW5jZUFwaShyZXBvX2lkJTNEJTIyYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBaW5mZXJlbmNlKGlucHV0cyUzRCUyMlRoZSUyMGdvYWwlMjBvZiUyMGxpZmUlMjBpcyUyMCU1Qk1BU0slNUQuJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceApi
<span class="hljs-meta">&gt;&gt;&gt; </span>inference = InferenceApi(repo_id=<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inference(inputs=<span class="hljs-string">&quot;The goal of life is [MASK].&quot;</span>)
[{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;the goal of life is life.&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.10933292657136917</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">2166</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;life&#x27;</span>}]`,wrap:!1}}),ve=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCgpJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQucG9zdChqc29uJTNEJTdCJTIyaW5wdXRzJTIyJTNBJTIwJTIyVGhlJTIwZ29hbCUyMG9mJTIwbGlmZSUyMGlzJTIwJTVCTUFTSyU1RC4lMjIlN0QlMkMlMjBtb2RlbCUzRCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQXJlc3BvbnNlLmpzb24oKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient()
<span class="hljs-meta">&gt;&gt;&gt; </span>response = client.post(json={<span class="hljs-string">&quot;inputs&quot;</span>: <span class="hljs-string">&quot;The goal of life is [MASK].&quot;</span>}, model=<span class="hljs-string">&quot;bert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>response.json()
[{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;the goal of life is life.&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.10933292657136917</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">2166</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;life&#x27;</span>}]`,wrap:!1}}),xe=new j({props:{title:"Run with parameters",local:"run-with-parameters",headingTag:"h3"}}),Ve=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUFwaSUwQWluZmVyZW5jZSUyMCUzRCUyMEluZmVyZW5jZUFwaShyZXBvX2lkJTNEJTIydHlwZWZvcm0lMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1tbmxpJTIyKSUwQWlucHV0cyUyMCUzRCUyMCUyMkhpJTJDJTIwSSUyMHJlY2VudGx5JTIwYm91Z2h0JTIwYSUyMGRldmljZSUyMGZyb20lMjB5b3VyJTIwY29tcGFueSUyMGJ1dCUyMGl0JTIwaXMlMjBub3QlMjB3b3JraW5nJTIwYXMlMjBhZHZlcnRpc2VkJTIwYW5kJTIwSSUyMHdvdWxkJTIwbGlrZSUyMHRvJTIwZ2V0JTIwcmVpbWJ1cnNlZCElMjIlMEFwYXJhbXMlMjAlM0QlMjAlN0IlMjJjYW5kaWRhdGVfbGFiZWxzJTIyJTNBJTVCJTIycmVmdW5kJTIyJTJDJTIwJTIybGVnYWwlMjIlMkMlMjAlMjJmYXElMjIlNUQlN0QlMEFpbmZlcmVuY2UoaW5wdXRzJTJDJTIwcGFyYW1zKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceApi
<span class="hljs-meta">&gt;&gt;&gt; </span>inference = InferenceApi(repo_id=<span class="hljs-string">&quot;typeform/distilbert-base-uncased-mnli&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = <span class="hljs-string">&quot;Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>params = {<span class="hljs-string">&quot;candidate_labels&quot;</span>:[<span class="hljs-string">&quot;refund&quot;</span>, <span class="hljs-string">&quot;legal&quot;</span>, <span class="hljs-string">&quot;faq&quot;</span>]}
<span class="hljs-meta">&gt;&gt;&gt; </span>inference(inputs, params)
{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>: [<span class="hljs-string">&#x27;refund&#x27;</span>, <span class="hljs-string">&#x27;faq&#x27;</span>, <span class="hljs-string">&#x27;legal&#x27;</span>], <span class="hljs-string">&#x27;scores&#x27;</span>: [<span class="hljs-number">0.9378499388694763</span>, <span class="hljs-number">0.04914155602455139</span>, <span class="hljs-number">0.013008488342165947</span>]}`,wrap:!1}}),Ne=new _({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCgpJTBBaW5wdXRzJTIwJTNEJTIwJTIySGklMkMlMjBJJTIwcmVjZW50bHklMjBib3VnaHQlMjBhJTIwZGV2aWNlJTIwZnJvbSUyMHlvdXIlMjBjb21wYW55JTIwYnV0JTIwaXQlMjBpcyUyMG5vdCUyMHdvcmtpbmclMjBhcyUyMGFkdmVydGlzZWQlMjBhbmQlMjBJJTIwd291bGQlMjBsaWtlJTIwdG8lMjBnZXQlMjByZWltYnVyc2VkISUyMiUwQXBhcmFtcyUyMCUzRCUyMCU3QiUyMmNhbmRpZGF0ZV9sYWJlbHMlMjIlM0ElNUIlMjJyZWZ1bmQlMjIlMkMlMjAlMjJsZWdhbCUyMiUyQyUyMCUyMmZhcSUyMiU1RCU3RCUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LnBvc3QoanNvbiUzRCU3QiUyMmlucHV0cyUyMiUzQSUyMGlucHV0cyUyQyUyMCUyMnBhcmFtZXRlcnMlMjIlM0ElMjBwYXJhbXMlN0QlMkMlMjBtb2RlbCUzRCUyMnR5cGVmb3JtJTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtbW5saSUyMiklMEFyZXNwb25zZS5qc29uKCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient
<span class="hljs-meta">&gt;&gt;&gt; </span>client = InferenceClient()
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = <span class="hljs-string">&quot;Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>params = {<span class="hljs-string">&quot;candidate_labels&quot;</span>:[<span class="hljs-string">&quot;refund&quot;</span>, <span class="hljs-string">&quot;legal&quot;</span>, <span class="hljs-string">&quot;faq&quot;</span>]}
<span class="hljs-meta">&gt;&gt;&gt; </span>response = client.post(json={<span class="hljs-string">&quot;inputs&quot;</span>: inputs, <span class="hljs-string">&quot;parameters&quot;</span>: params}, model=<span class="hljs-string">&quot;typeform/distilbert-base-uncased-mnli&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>response.json()
{<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>: [<span class="hljs-string">&#x27;refund&#x27;</span>, <span class="hljs-string">&#x27;faq&#x27;</span>, <span class="hljs-string">&#x27;legal&#x27;</span>], <span class="hljs-string">&#x27;scores&#x27;</span>: [<span class="hljs-number">0.9378499388694763</span>, <span class="hljs-number">0.04914155602455139</span>, <span class="hljs-number">0.013008488342165947</span>]}`,wrap:!1}}),Be=new Fn({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/guides/inference.md"}}),{c(){i=h("meta"),y=s(),c=h("p"),b=s(),r(C.$$.fragment),$=s(),M=h("p"),M.innerHTML=sn,Re=s(),W=h("ul"),W.innerHTML=ln,Ye=s(),v=h("p"),v.innerHTML=cn,Le=s(),r(U.$$.fragment),Xe=s(),r(x.$$.fragment),Qe=s(),G=h("p"),G.textContent=rn,Ee=s(),r(V.$$.fragment),Ae=s(),q=h("p"),q.innerHTML=on,Fe=s(),r(I.$$.fragment),Pe=s(),r(N.$$.fragment),Ke=s(),B=h("p"),B.textContent=pn,De=s(),r(S.$$.fragment),Oe=s(),r(Z.$$.fragment),et=s(),r(H.$$.fragment),tt=s(),z=h("p"),z.innerHTML=gn,nt=s(),r(R.$$.fragment),at=s(),r(Y.$$.fragment),st=s(),L=h("p"),L.innerHTML=fn,lt=s(),r(X.$$.fragment),it=s(),r(k.$$.fragment),ct=s(),r(Q.$$.fragment),rt=s(),E=h("p"),E.innerHTML=un,ot=s(),A=h("table"),A.innerHTML=hn,pt=s(),r(T.$$.fragment),gt=s(),r(F.$$.fragment),ft=s(),P=h("p"),P.innerHTML=dn,ut=s(),r(K.$$.fragment),ht=s(),r(D.$$.fragment),dt=s(),O=h("p"),O.innerHTML=mn,mt=s(),r(ee.$$.fragment),yt=s(),te=h("p"),te.innerHTML=yn,bt=s(),r(ne.$$.fragment),_t=s(),ae=h("p"),ae.innerHTML=bn,jt=s(),r(se.$$.fragment),wt=s(),le=h("p"),le.innerHTML=_n,$t=s(),r(ie.$$.fragment),Mt=s(),ce=h("p"),ce.textContent=jn,Ct=s(),re=h("ul"),re.innerHTML=wn,Ut=s(),oe=h("p"),oe.innerHTML=$n,It=s(),r(pe.$$.fragment),Zt=s(),r(ge.$$.fragment),kt=s(),fe=h("p"),fe.innerHTML=Mn,Tt=s(),ue=h("ul"),ue.innerHTML=Cn,Jt=s(),r(he.$$.fragment),Wt=s(),r(de.$$.fragment),vt=s(),me=h("p"),me.innerHTML=Un,xt=s(),ye=h("p"),ye.innerHTML=In,Gt=s(),r(be.$$.fragment),Vt=s(),_e=h("p"),_e.textContent=Zn,qt=s(),r(je.$$.fragment),Nt=s(),we=h("p"),we.textContent=kn,Bt=s(),r($e.$$.fragment),St=s(),r(Me.$$.fragment),Ht=s(),Ce=h("p"),Ce.textContent=Tn,zt=s(),r(Ue.$$.fragment),Rt=s(),Ie=h("p"),Ie.textContent=Jn,Yt=s(),r(Ze.$$.fragment),Lt=s(),r(J.$$.fragment),Xt=s(),r(ke.$$.fragment),Qt=s(),Te=h("p"),Te.textContent=Wn,Et=s(),r(Je.$$.fragment),At=s(),We=h("p"),We.textContent=vn,Ft=s(),r(ve.$$.fragment),Pt=s(),r(xe.$$.fragment),Kt=s(),Ge=h("p"),Ge.textContent=xn,Dt=s(),r(Ve.$$.fragment),Ot=s(),qe=h("p"),qe.textContent=Gn,en=s(),r(Ne.$$.fragment),tn=s(),r(Be.$$.fragment),nn=s(),ze=h("p"),this.h()},l(e){const t=En("svelte-u9bgzb",document.head);i=d(t,"META",{name:!0,content:!0}),t.forEach(n),y=l(e),c=d(e,"P",{}),zn(c).forEach(n),b=l(e),o(C.$$.fragment,e),$=l(e),M=d(e,"P",{"data-svelte-h":!0}),m(M)!=="svelte-411gzg"&&(M.innerHTML=sn),Re=l(e),W=d(e,"UL",{"data-svelte-h":!0}),m(W)!=="svelte-lzzf1y"&&(W.innerHTML=ln),Ye=l(e),v=d(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-1d7uj83"&&(v.innerHTML=cn),Le=l(e),o(U.$$.fragment,e),Xe=l(e),o(x.$$.fragment,e),Qe=l(e),G=d(e,"P",{"data-svelte-h":!0}),m(G)!=="svelte-8lplub"&&(G.textContent=rn),Ee=l(e),o(V.$$.fragment,e),Ae=l(e),q=d(e,"P",{"data-svelte-h":!0}),m(q)!=="svelte-1fbeihw"&&(q.innerHTML=on),Fe=l(e),o(I.$$.fragment,e),Pe=l(e),o(N.$$.fragment,e),Ke=l(e),B=d(e,"P",{"data-svelte-h":!0}),m(B)!=="svelte-1npu22n"&&(B.textContent=pn),De=l(e),o(S.$$.fragment,e),Oe=l(e),o(Z.$$.fragment,e),et=l(e),o(H.$$.fragment,e),tt=l(e),z=d(e,"P",{"data-svelte-h":!0}),m(z)!=="svelte-cp0irx"&&(z.innerHTML=gn),nt=l(e),o(R.$$.fragment,e),at=l(e),o(Y.$$.fragment,e),st=l(e),L=d(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-q9so4a"&&(L.innerHTML=fn),lt=l(e),o(X.$$.fragment,e),it=l(e),o(k.$$.fragment,e),ct=l(e),o(Q.$$.fragment,e),rt=l(e),E=d(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-1xqsjmo"&&(E.innerHTML=un),ot=l(e),A=d(e,"TABLE",{"data-svelte-h":!0}),m(A)!=="svelte-sj7idz"&&(A.innerHTML=hn),pt=l(e),o(T.$$.fragment,e),gt=l(e),o(F.$$.fragment,e),ft=l(e),P=d(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-1jtwxv4"&&(P.innerHTML=dn),ut=l(e),o(K.$$.fragment,e),ht=l(e),o(D.$$.fragment,e),dt=l(e),O=d(e,"P",{"data-svelte-h":!0}),m(O)!=="svelte-1gqwj00"&&(O.innerHTML=mn),mt=l(e),o(ee.$$.fragment,e),yt=l(e),te=d(e,"P",{"data-svelte-h":!0}),m(te)!=="svelte-1bdjfju"&&(te.innerHTML=yn),bt=l(e),o(ne.$$.fragment,e),_t=l(e),ae=d(e,"P",{"data-svelte-h":!0}),m(ae)!=="svelte-q492az"&&(ae.innerHTML=bn),jt=l(e),o(se.$$.fragment,e),wt=l(e),le=d(e,"P",{"data-svelte-h":!0}),m(le)!=="svelte-2b1sa3"&&(le.innerHTML=_n),$t=l(e),o(ie.$$.fragment,e),Mt=l(e),ce=d(e,"P",{"data-svelte-h":!0}),m(ce)!=="svelte-8gznjs"&&(ce.textContent=jn),Ct=l(e),re=d(e,"UL",{"data-svelte-h":!0}),m(re)!=="svelte-ovc80h"&&(re.innerHTML=wn),Ut=l(e),oe=d(e,"P",{"data-svelte-h":!0}),m(oe)!=="svelte-1erkhu8"&&(oe.innerHTML=$n),It=l(e),o(pe.$$.fragment,e),Zt=l(e),o(ge.$$.fragment,e),kt=l(e),fe=d(e,"P",{"data-svelte-h":!0}),m(fe)!=="svelte-4hhs15"&&(fe.innerHTML=Mn),Tt=l(e),ue=d(e,"UL",{"data-svelte-h":!0}),m(ue)!=="svelte-vaeuct"&&(ue.innerHTML=Cn),Jt=l(e),o(he.$$.fragment,e),Wt=l(e),o(de.$$.fragment,e),vt=l(e),me=d(e,"P",{"data-svelte-h":!0}),m(me)!=="svelte-4xn88d"&&(me.innerHTML=Un),xt=l(e),ye=d(e,"P",{"data-svelte-h":!0}),m(ye)!=="svelte-17wtofw"&&(ye.innerHTML=In),Gt=l(e),o(be.$$.fragment,e),Vt=l(e),_e=d(e,"P",{"data-svelte-h":!0}),m(_e)!=="svelte-ft9vbs"&&(_e.textContent=Zn),qt=l(e),o(je.$$.fragment,e),Nt=l(e),we=d(e,"P",{"data-svelte-h":!0}),m(we)!=="svelte-8wg17z"&&(we.textContent=kn),Bt=l(e),o($e.$$.fragment,e),St=l(e),o(Me.$$.fragment,e),Ht=l(e),Ce=d(e,"P",{"data-svelte-h":!0}),m(Ce)!=="svelte-ft9vbs"&&(Ce.textContent=Tn),zt=l(e),o(Ue.$$.fragment,e),Rt=l(e),Ie=d(e,"P",{"data-svelte-h":!0}),m(Ie)!=="svelte-8wg17z"&&(Ie.textContent=Jn),Yt=l(e),o(Ze.$$.fragment,e),Lt=l(e),o(J.$$.fragment,e),Xt=l(e),o(ke.$$.fragment,e),Qt=l(e),Te=d(e,"P",{"data-svelte-h":!0}),m(Te)!=="svelte-ft9vbs"&&(Te.textContent=Wn),Et=l(e),o(Je.$$.fragment,e),At=l(e),We=d(e,"P",{"data-svelte-h":!0}),m(We)!=="svelte-8wg17z"&&(We.textContent=vn),Ft=l(e),o(ve.$$.fragment,e),Pt=l(e),o(xe.$$.fragment,e),Kt=l(e),Ge=d(e,"P",{"data-svelte-h":!0}),m(Ge)!=="svelte-ft9vbs"&&(Ge.textContent=xn),Dt=l(e),o(Ve.$$.fragment,e),Ot=l(e),qe=d(e,"P",{"data-svelte-h":!0}),m(qe)!=="svelte-8wg17z"&&(qe.textContent=Gn),en=l(e),o(Ne.$$.fragment,e),tn=l(e),o(Be.$$.fragment,e),nn=l(e),ze=d(e,"P",{}),zn(ze).forEach(n),this.h()},h(){Rn(i,"name","hf:doc:metadata"),Rn(i,"content",aa)},m(e,t){An(document.head,i),a(e,y,t),a(e,c,t),a(e,b,t),p(C,e,t),a(e,$,t),a(e,M,t),a(e,Re,t),a(e,W,t),a(e,Ye,t),a(e,v,t),a(e,Le,t),p(U,e,t),a(e,Xe,t),p(x,e,t),a(e,Qe,t),a(e,G,t),a(e,Ee,t),p(V,e,t),a(e,Ae,t),a(e,q,t),a(e,Fe,t),p(I,e,t),a(e,Pe,t),p(N,e,t),a(e,Ke,t),a(e,B,t),a(e,De,t),p(S,e,t),a(e,Oe,t),p(Z,e,t),a(e,et,t),p(H,e,t),a(e,tt,t),a(e,z,t),a(e,nt,t),p(R,e,t),a(e,at,t),p(Y,e,t),a(e,st,t),a(e,L,t),a(e,lt,t),p(X,e,t),a(e,it,t),p(k,e,t),a(e,ct,t),p(Q,e,t),a(e,rt,t),a(e,E,t),a(e,ot,t),a(e,A,t),a(e,pt,t),p(T,e,t),a(e,gt,t),p(F,e,t),a(e,ft,t),a(e,P,t),a(e,ut,t),p(K,e,t),a(e,ht,t),p(D,e,t),a(e,dt,t),a(e,O,t),a(e,mt,t),p(ee,e,t),a(e,yt,t),a(e,te,t),a(e,bt,t),p(ne,e,t),a(e,_t,t),a(e,ae,t),a(e,jt,t),p(se,e,t),a(e,wt,t),a(e,le,t),a(e,$t,t),p(ie,e,t),a(e,Mt,t),a(e,ce,t),a(e,Ct,t),a(e,re,t),a(e,Ut,t),a(e,oe,t),a(e,It,t),p(pe,e,t),a(e,Zt,t),p(ge,e,t),a(e,kt,t),a(e,fe,t),a(e,Tt,t),a(e,ue,t),a(e,Jt,t),p(he,e,t),a(e,Wt,t),p(de,e,t),a(e,vt,t),a(e,me,t),a(e,xt,t),a(e,ye,t),a(e,Gt,t),p(be,e,t),a(e,Vt,t),a(e,_e,t),a(e,qt,t),p(je,e,t),a(e,Nt,t),a(e,we,t),a(e,Bt,t),p($e,e,t),a(e,St,t),p(Me,e,t),a(e,Ht,t),a(e,Ce,t),a(e,zt,t),p(Ue,e,t),a(e,Rt,t),a(e,Ie,t),a(e,Yt,t),p(Ze,e,t),a(e,Lt,t),p(J,e,t),a(e,Xt,t),p(ke,e,t),a(e,Qt,t),a(e,Te,t),a(e,Et,t),p(Je,e,t),a(e,At,t),a(e,We,t),a(e,Ft,t),p(ve,e,t),a(e,Pt,t),p(xe,e,t),a(e,Kt,t),a(e,Ge,t),a(e,Dt,t),p(Ve,e,t),a(e,Ot,t),a(e,qe,t),a(e,en,t),p(Ne,e,t),a(e,tn,t),p(Be,e,t),a(e,nn,t),a(e,ze,t),an=!0},p(e,[t]){const Vn={};t&2&&(Vn.$$scope={dirty:t,ctx:e}),U.$set(Vn);const qn={};t&2&&(qn.$$scope={dirty:t,ctx:e}),I.$set(qn);const Nn={};t&2&&(Nn.$$scope={dirty:t,ctx:e}),Z.$set(Nn);const Bn={};t&2&&(Bn.$$scope={dirty:t,ctx:e}),k.$set(Bn);const Sn={};t&2&&(Sn.$$scope={dirty:t,ctx:e}),T.$set(Sn);const Hn={};t&2&&(Hn.$$scope={dirty:t,ctx:e}),J.$set(Hn)},i(e){an||(g(C.$$.fragment,e),g(U.$$.fragment,e),g(x.$$.fragment,e),g(V.$$.fragment,e),g(I.$$.fragment,e),g(N.$$.fragment,e),g(S.$$.fragment,e),g(Z.$$.fragment,e),g(H.$$.fragment,e),g(R.$$.fragment,e),g(Y.$$.fragment,e),g(X.$$.fragment,e),g(k.$$.fragment,e),g(Q.$$.fragment,e),g(T.$$.fragment,e),g(F.$$.fragment,e),g(K.$$.fragment,e),g(D.$$.fragment,e),g(ee.$$.fragment,e),g(ne.$$.fragment,e),g(se.$$.fragment,e),g(ie.$$.fragment,e),g(pe.$$.fragment,e),g(ge.$$.fragment,e),g(he.$$.fragment,e),g(de.$$.fragment,e),g(be.$$.fragment,e),g(je.$$.fragment,e),g($e.$$.fragment,e),g(Me.$$.fragment,e),g(Ue.$$.fragment,e),g(Ze.$$.fragment,e),g(J.$$.fragment,e),g(ke.$$.fragment,e),g(Je.$$.fragment,e),g(ve.$$.fragment,e),g(xe.$$.fragment,e),g(Ve.$$.fragment,e),g(Ne.$$.fragment,e),g(Be.$$.fragment,e),an=!0)},o(e){f(C.$$.fragment,e),f(U.$$.fragment,e),f(x.$$.fragment,e),f(V.$$.fragment,e),f(I.$$.fragment,e),f(N.$$.fragment,e),f(S.$$.fragment,e),f(Z.$$.fragment,e),f(H.$$.fragment,e),f(R.$$.fragment,e),f(Y.$$.fragment,e),f(X.$$.fragment,e),f(k.$$.fragment,e),f(Q.$$.fragment,e),f(T.$$.fragment,e),f(F.$$.fragment,e),f(K.$$.fragment,e),f(D.$$.fragment,e),f(ee.$$.fragment,e),f(ne.$$.fragment,e),f(se.$$.fragment,e),f(ie.$$.fragment,e),f(pe.$$.fragment,e),f(ge.$$.fragment,e),f(he.$$.fragment,e),f(de.$$.fragment,e),f(be.$$.fragment,e),f(je.$$.fragment,e),f($e.$$.fragment,e),f(Me.$$.fragment,e),f(Ue.$$.fragment,e),f(Ze.$$.fragment,e),f(J.$$.fragment,e),f(ke.$$.fragment,e),f(Je.$$.fragment,e),f(ve.$$.fragment,e),f(xe.$$.fragment,e),f(Ve.$$.fragment,e),f(Ne.$$.fragment,e),f(Be.$$.fragment,e),an=!1},d(e){e&&(n(y),n(c),n(b),n($),n(M),n(Re),n(W),n(Ye),n(v),n(Le),n(Xe),n(Qe),n(G),n(Ee),n(Ae),n(q),n(Fe),n(Pe),n(Ke),n(B),n(De),n(Oe),n(et),n(tt),n(z),n(nt),n(at),n(st),n(L),n(lt),n(it),n(ct),n(rt),n(E),n(ot),n(A),n(pt),n(gt),n(ft),n(P),n(ut),n(ht),n(dt),n(O),n(mt),n(yt),n(te),n(bt),n(_t),n(ae),n(jt),n(wt),n(le),n($t),n(Mt),n(ce),n(Ct),n(re),n(Ut),n(oe),n(It),n(Zt),n(kt),n(fe),n(Tt),n(ue),n(Jt),n(Wt),n(vt),n(me),n(xt),n(ye),n(Gt),n(Vt),n(_e),n(qt),n(Nt),n(we),n(Bt),n(St),n(Ht),n(Ce),n(zt),n(Rt),n(Ie),n(Yt),n(Lt),n(Xt),n(Qt),n(Te),n(Et),n(At),n(We),n(Ft),n(Pt),n(Kt),n(Ge),n(Dt),n(Ot),n(qe),n(en),n(tn),n(nn),n(ze)),n(i),u(C,e),u(U,e),u(x,e),u(V,e),u(I,e),u(N,e),u(S,e),u(Z,e),u(H,e),u(R,e),u(Y,e),u(X,e),u(k,e),u(Q,e),u(T,e),u(F,e),u(K,e),u(D,e),u(ee,e),u(ne,e),u(se,e),u(ie,e),u(pe,e),u(ge,e),u(he,e),u(de,e),u(be,e),u(je,e),u($e,e),u(Me,e),u(Ue,e),u(Ze,e),u(J,e),u(ke,e),u(Je,e),u(ve,e),u(xe,e),u(Ve,e),u(Ne,e),u(Be,e)}}}const aa='{"title":"Run Inference on servers","local":"run-inference-on-servers","sections":[{"title":"Getting started","local":"getting-started","sections":[{"title":"Using a specific model","local":"using-a-specific-model","sections":[],"depth":3},{"title":"Using a specific URL","local":"using-a-specific-url","sections":[],"depth":3},{"title":"Authentication","local":"authentication","sections":[],"depth":3}],"depth":2},{"title":"Supported tasks","local":"supported-tasks","sections":[],"depth":2},{"title":"Custom requests","local":"custom-requests","sections":[],"depth":2},{"title":"Async client","local":"async-client","sections":[],"depth":2},{"title":"Advanced tips","local":"advanced-tips","sections":[{"title":"Timeout","local":"timeout","sections":[],"depth":3},{"title":"Binary inputs","local":"binary-inputs","sections":[],"depth":3}],"depth":2},{"title":"Legacy InferenceAPI client","local":"legacy-inferenceapi-client","sections":[{"title":"Initialization","local":"initialization","sections":[],"depth":3},{"title":"Run on a specific task","local":"run-on-a-specific-task","sections":[],"depth":3},{"title":"Run custom request","local":"run-custom-request","sections":[],"depth":3},{"title":"Run with parameters","local":"run-with-parameters","sections":[],"depth":3}],"depth":2}],"depth":1}';function sa(w){return Ln(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pa extends Xn{constructor(i){super(),Qn(this,i,sa,na,Yn,{})}}export{pa as component};
