import{s as cl,o as ul,n as vt}from"../chunks/scheduler.ddeee2a5.js";import{S as ml,i as fl,e as c,s as n,c as M,h as hl,a as u,d as l,b as a,f as ol,g as y,j as m,k as $e,l as dl,m as s,n as T,t as w,o as J,p as g}from"../chunks/index.10b70568.js";import{C as Ml}from"../chunks/CopyLLMTxtMenu.48a5d8e9.js";import{C as ve}from"../chunks/CodeBlock.7ca4c11d.js";import{H as C,E as yl}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c3713d0b.js";import{H as rl,a as jt}from"../chunks/HfOption.1e773499.js";function Tl(U){let i,d="Install the required package:",r,h,p,f,b="You can now use the code snippet to generate an image in your app.",$,j,I;return h=new ve({props:{code:"cGlwJTIwaW5zdGFsbCUyMGh1Z2dpbmdmYWNlX2h1Yg==",highlighted:"pip install huggingface_hub",wrap:!1}}),j=new ve({props:{code:"aW1wb3J0JTIwb3MlMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwSW5mZXJlbmNlQ2xpZW50JTBBJTBBY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KCUwQSUyMCUyMCUyMCUyMHByb3ZpZGVyJTNEJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMGFwaV9rZXklM0Rvcy5lbnZpcm9uJTVCJTIySEZfVE9LRU4lMjIlNUQlMkMlMEEpJTBBJTBBJTIzJTIwb3V0cHV0JTIwaXMlMjBhJTIwUElMLkltYWdlJTIwb2JqZWN0JTBBaW1hZ2UlMjAlM0QlMjBjbGllbnQudGV4dF90b19pbWFnZSglMEElMjAlMjAlMjAlMjAlMjJBc3Ryb25hdXQlMjByaWRpbmclMjBhJTIwaG9yc2UlMjIlMkMlMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMmJsYWNrLWZvcmVzdC1sYWJzJTJGRkxVWC4xLXNjaG5lbGwlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

client = InferenceClient(
    provider=<span class="hljs-string">&quot;auto&quot;</span>,
    api_key=os.environ[<span class="hljs-string">&quot;HF_TOKEN&quot;</span>],
)

<span class="hljs-comment"># output is a PIL.Image object</span>
image = client.text_to_image(
    <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>,
    model=<span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>,
)`,wrap:!1}}),{c(){i=c("p"),i.textContent=d,r=n(),M(h.$$.fragment),p=n(),f=c("p"),f.textContent=b,$=n(),M(j.$$.fragment)},l(o){i=u(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-u8aytp"&&(i.textContent=d),r=a(o),y(h.$$.fragment,o),p=a(o),f=u(o,"P",{"data-svelte-h":!0}),m(f)!=="svelte-bwe790"&&(f.textContent=b),$=a(o),y(j.$$.fragment,o)},m(o,v){s(o,i,v),s(o,r,v),T(h,o,v),s(o,p,v),s(o,f,v),s(o,$,v),T(j,o,v),I=!0},p:vt,i(o){I||(w(h.$$.fragment,o),w(j.$$.fragment,o),I=!0)},o(o){J(h.$$.fragment,o),J(j.$$.fragment,o),I=!1},d(o){o&&(l(i),l(r),l(p),l(f),l($)),g(h,o),g(j,o)}}}function wl(U){let i,d="Install the required package:",r,h,p,f,b="Then, you can use the code snippet to generate an image in your app.",$,j,I;return h=new ve({props:{code:"bnBtJTIwaW5zdGFsbCUyMCU0MGh1Z2dpbmdmYWNlJTJGaW5mZXJlbmNl",highlighted:"npm install @huggingface/inference",wrap:!1}}),j=new ve({props:{code:"aW1wb3J0JTIwJTdCJTIwSW5mZXJlbmNlQ2xpZW50JTIwJTdEJTIwZnJvbSUyMCUyMiU0MGh1Z2dpbmdmYWNlJTJGaW5mZXJlbmNlJTIyJTNCJTBBJTBBY29uc3QlMjBjbGllbnQlMjAlM0QlMjBuZXclMjBJbmZlcmVuY2VDbGllbnQocHJvY2Vzcy5lbnYuSEZfVE9LRU4pJTNCJTBBJTBBY29uc3QlMjBpbWFnZSUyMCUzRCUyMGF3YWl0JTIwY2xpZW50LnRleHRUb0ltYWdlKCU3QiUwQSUyMCUyMCUyMCUyMHByb3ZpZGVyJTNBJTIwJTIyYXV0byUyMiUyQyUwQSUyMCUyMCUyMCUyMG1vZGVsJTNBJTIwJTIyYmxhY2stZm9yZXN0LWxhYnMlMkZGTFVYLjEtc2NobmVsbCUyMiUyQyUwQSUwOWlucHV0cyUzQSUyMCUyMkFzdHJvbmF1dCUyMHJpZGluZyUyMGElMjBob3JzZSUyMiUyQyUwQSUwOXBhcmFtZXRlcnMlM0ElMjAlN0IlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNBJTIwNSUyMCU3RCUyQyUwQSU3RCklM0IlMEElMkYlMkYlMkYlMjBVc2UlMjB0aGUlMjBnZW5lcmF0ZWQlMjBpbWFnZSUyMChpdCdzJTIwYSUyMEJsb2Ip",highlighted:`<span class="hljs-keyword">import</span> { <span class="hljs-title class_">InferenceClient</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;@huggingface/inference&quot;</span>;

<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> <span class="hljs-title class_">InferenceClient</span>(process.<span class="hljs-property">env</span>.<span class="hljs-property">HF_TOKEN</span>);

<span class="hljs-keyword">const</span> image = <span class="hljs-keyword">await</span> client.<span class="hljs-title function_">textToImage</span>({
    <span class="hljs-attr">provider</span>: <span class="hljs-string">&quot;auto&quot;</span>,
    <span class="hljs-attr">model</span>: <span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>,
	<span class="hljs-attr">inputs</span>: <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>,
	<span class="hljs-attr">parameters</span>: { <span class="hljs-attr">num_inference_steps</span>: <span class="hljs-number">5</span> },
});
<span class="hljs-comment">/// Use the generated image (it&#x27;s a Blob)</span>`,wrap:!1}}),{c(){i=c("p"),i.textContent=d,r=n(),M(h.$$.fragment),p=n(),f=c("p"),f.textContent=b,$=n(),M(j.$$.fragment)},l(o){i=u(o,"P",{"data-svelte-h":!0}),m(i)!=="svelte-u8aytp"&&(i.textContent=d),r=a(o),y(h.$$.fragment,o),p=a(o),f=u(o,"P",{"data-svelte-h":!0}),m(f)!=="svelte-16rowzh"&&(f.textContent=b),$=a(o),y(j.$$.fragment,o)},m(o,v){s(o,i,v),s(o,r,v),T(h,o,v),s(o,p,v),s(o,f,v),s(o,$,v),T(j,o,v),I=!0},p:vt,i(o){I||(w(h.$$.fragment,o),w(j.$$.fragment,o),I=!0)},o(o){J(h.$$.fragment,o),J(j.$$.fragment,o),I=!1},d(o){o&&(l(i),l(r),l(p),l(f),l($)),g(h,o),g(j,o)}}}function Jl(U){let i,d,r,h;return i=new jt({props:{id:"python-code-snippet",option:"python",$$slots:{default:[Tl]},$$scope:{ctx:U}}}),r=new jt({props:{id:"python-code-snippet",option:"typescript",$$slots:{default:[wl]},$$scope:{ctx:U}}}),{c(){M(i.$$.fragment),d=n(),M(r.$$.fragment)},l(p){y(i.$$.fragment,p),d=a(p),y(r.$$.fragment,p)},m(p,f){T(i,p,f),s(p,d,f),T(r,p,f),h=!0},p(p,f){const b={};f&2&&(b.$$scope={dirty:f,ctx:p}),i.$set(b);const $={};f&2&&($.$$scope={dirty:f,ctx:p}),r.$set($)},i(p){h||(w(i.$$.fragment,p),w(r.$$.fragment,p),h=!0)},o(p){J(i.$$.fragment,p),J(r.$$.fragment,p),h=!1},d(p){p&&l(d),g(i,p),g(r,p)}}}function gl(U){let i,d;return i=new ve({props:{code:"aW1wb3J0JTIwb3MlMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwSW5mZXJlbmNlQ2xpZW50JTBBJTBBY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KGFwaV9rZXklM0Rvcy5lbnZpcm9uJTVCJTIySEZfVE9LRU4lMjIlNUQpJTBBJTBBJTIzJTIwVXNpbmclMjBhdXRvbWF0aWMlMjBwcm92aWRlci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QlMjJyZXBsaWNhdGUlMjIlMjAlMjAlMjMlMjBFeHBsaWNpdGx5JTIwdXNlJTIwUmVwbGljYXRlJTBBKQ==",highlighted:`<span class="hljs-keyword">import</span> os
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

client = InferenceClient(api_key=os.environ[<span class="hljs-string">&quot;HF_TOKEN&quot;</span>])

<span class="hljs-comment"># Using automatic provider selection (default)</span>
image_auto = client.text_to_image(
    <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>,
    model=<span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>,
    provider=<span class="hljs-string">&quot;auto&quot;</span>  <span class="hljs-comment"># This is the default</span>
)

<span class="hljs-comment"># Using a specific provider</span>
image_fal = client.text_to_image(
    <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>, 
    model=<span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>,
    provider=<span class="hljs-string">&quot;fal-ai&quot;</span>  <span class="hljs-comment"># Explicitly use Fal AI</span>
)

<span class="hljs-comment"># Using another specific provider</span>
image_replicate = client.text_to_image(
    <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>,
    model=<span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>, 
    provider=<span class="hljs-string">&quot;replicate&quot;</span>  <span class="hljs-comment"># Explicitly use Replicate</span>
)`,wrap:!1}}),{c(){M(i.$$.fragment)},l(r){y(i.$$.fragment,r)},m(r,h){T(i,r,h),d=!0},p:vt,i(r){d||(w(i.$$.fragment,r),d=!0)},o(r){J(i.$$.fragment,r),d=!1},d(r){g(i,r)}}}function jl(U){let i,d;return i=new ve({props:{code:"aW1wb3J0JTIwJTdCJTIwSW5mZXJlbmNlQ2xpZW50JTIwJTdEJTIwZnJvbSUyMCUyMiU0MGh1Z2dpbmdmYWNlJTJGaW5mZXJlbmNlJTIyJTNCJTBBJTBBY29uc3QlMjBjbGllbnQlMjAlM0QlMjBuZXcl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BBJTIwJTIwJTIwJTIwcGFyYW1ldGVycyUzQSUyMCU3QiUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0ElMjA1JTIwJTdEJTJDJTBBJTdEKSUzQiUwQSUwQSUyRiUyRiUyMFVzaW5nJTIwYW5vdGhlciUyMHNwZWNpZmljJTIwcHJvdmlkZXIlMEFjb25zdCUyMGltYWdlUmVwbGljYXRlJTIwJTNEJTIwYXdhaXQlMjBjbGllbnQudGV4dFRvSW1hZ2UoJTdCJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0ElMjAlMjJibGFjay1mb3Jlc3QtbGFicyUyRkZMVVguMS1zY2huZWxsJTIyJTJDJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTNBJTIwJTIyQXN0cm9uYXV0JTIwcmlkaW5nJTIwYSUyMGhvcnNlJTIyJTJDJTBBJTIwJTIwJTIwJTIwcHJvdmlkZXIlM0ElMjAlMjJyZXBsaWNhdGUlMjIlMkMlMjAlMkYlMkYlMjBFeHBsaWNpdGx5JTIwdXNlJTIwUmVwbGljYXRlJTBBJTIwJTIwJTIwJTIwcGFyYW1ldGVycyUzQSUyMCU3QiUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0ElMjA1JTIwJTdEJTJDJTBBJTdEKSUzQg==",highlighted:`<span class="hljs-keyword">import</span> { <span class="hljs-title class_">InferenceClient</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&quot;@huggingface/inference&quot;</span>;

<span class="hljs-keyword">const</span> client = <span class="hljs-keyword">new</span> <span class="hljs-title class_">InferenceClient</span>(process.<span class="hljs-property">env</span>.<span class="hljs-property">HF_TOKEN</span>);

<span class="hljs-comment">// Using automatic provider selection (default)</span>
<span class="hljs-keyword">const</span> imageAuto = <span class="hljs-keyword">await</span> client.<span class="hljs-title function_">textToImage</span>({
    <span class="hljs-attr">model</span>: <span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>,
    <span class="hljs-attr">inputs</span>: <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>,
    <span class="hljs-attr">provider</span>: <span class="hljs-string">&quot;auto&quot;</span>, <span class="hljs-comment">// This is the default</span>
    <span class="hljs-attr">parameters</span>: { <span class="hljs-attr">num_inference_steps</span>: <span class="hljs-number">5</span> },
});

<span class="hljs-comment">// Using a specific provider</span>
<span class="hljs-keyword">const</span> imageFal = <span class="hljs-keyword">await</span> client.<span class="hljs-title function_">textToImage</span>({
    <span class="hljs-attr">model</span>: <span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>,
    <span class="hljs-attr">inputs</span>: <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>,
    <span class="hljs-attr">provider</span>: <span class="hljs-string">&quot;fal-ai&quot;</span>, <span class="hljs-comment">// Explicitly use Fal AI</span>
    <span class="hljs-attr">parameters</span>: { <span class="hljs-attr">num_inference_steps</span>: <span class="hljs-number">5</span> },
});

<span class="hljs-comment">// Using another specific provider</span>
<span class="hljs-keyword">const</span> imageReplicate = <span class="hljs-keyword">await</span> client.<span class="hljs-title function_">textToImage</span>({
    <span class="hljs-attr">model</span>: <span class="hljs-string">&quot;black-forest-labs/FLUX.1-schnell&quot;</span>,
    <span class="hljs-attr">inputs</span>: <span class="hljs-string">&quot;Astronaut riding a horse&quot;</span>,
    <span class="hljs-attr">provider</span>: <span class="hljs-string">&quot;replicate&quot;</span>, <span class="hljs-comment">// Explicitly use Replicate</span>
    <span class="hljs-attr">parameters</span>: { <span class="hljs-attr">num_inference_steps</span>: <span class="hljs-number">5</span> },
});`,wrap:!1}}),{c(){M(i.$$.fragment)},l(r){y(i.$$.fragment,r)},m(r,h){T(i,r,h),d=!0},p:vt,i(r){d||(w(i.$$.fragment,r),d=!0)},o(r){J(i.$$.fragment,r),d=!1},d(r){g(i,r)}}}function vl(U){let i,d,r,h;return i=new jt({props:{id:"provider-selection-examples",option:"python",$$slots:{default:[gl]},$$scope:{ctx:U}}}),r=new jt({props:{id:"provider-selection-examples",option:"typescript",$$slots:{default:[jl]},$$scope:{ctx:U}}}),{c(){M(i.$$.fragment),d=n(),M(r.$$.fragment)},l(p){y(i.$$.fragment,p),d=a(p),y(r.$$.fragment,p)},m(p,f){T(i,p,f),s(p,d,f),T(r,p,f),h=!0},p(p,f){const b={};f&2&&(b.$$scope={dirty:f,ctx:p}),i.$set(b);const $={};f&2&&($.$$scope={dirty:f,ctx:p}),r.$set($)},i(p){h||(w(i.$$.fragment,p),w(r.$$.fragment,p),h=!0)},o(p){J(i.$$.fragment,p),J(r.$$.fragment,p),h=!1},d(p){p&&l(d),g(i,p),g(r,p)}}}function $l(U){let i,d,r,h,p,f,b,$,j,I='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers-guides/first-api-call-thumbnail-light.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers-guides/first-api-call-thumbnail-dark.png"/>',o,v,$t="In this guide we’re going to help you make your first API call with Inference Providers.",Ue,_,bt="Many developers avoid using open source AI models because they assume deployment is complex. This guide will show you how to use a state-of-the-art model in under five minutes, with no infrastructure setup required.",Ie,G,Ut='We’re going to use the <a href="https://huggingface.co/black-forest-labs/FLUX.1-schnell" rel="nofollow">FLUX.1-schnell</a> model, which is a powerful text-to-image model.',Ce,x,It='<p>This guide assumes you have a Hugging Face account. If you don’t have one, you can create one for free at <a href="https://huggingface.co" rel="nofollow">huggingface.co</a>.</p>',xe,H,Be,L,Ct='Visit the <a href="https://huggingface.co/models?pipeline_tag=text-to-image&amp;inference_provider=fal-ai,hf-inference,nebius,nscale,replicate,together&amp;sort=trending" rel="nofollow">Hugging Face Hub</a> and look for models with the “Inference Providers” filter, you can select the provider that you want. We’ll go with <code>fal</code>.',We,Y,xt='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers-guides/search.png" alt="search image"/>',Ze,E,Bt='For this example, we’ll use <a href="https://huggingface.co/black-forest-labs/FLUX.1-schnell" rel="nofollow">FLUX.1-schnell</a>, a powerful text-to-image model. Next, navigate to the model page and scroll down to find the inference widget on the right side.',ke,V,_e,S,Wt='Before writing any code, try the widget directly on the <a href="https://huggingface.co/black-forest-labs/FLUX.1-dev?inference_provider=fal-ai" rel="nofollow">model page</a>:',Ge,X,Zt='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers-guides/widget.png" alt="widget image"/>',He,N,kt="Here, you can test the model directly in the browser from any of the available providers. You can also copy relevant code snippets to use in your own projects.",Le,F,_t="<li>Enter a prompt like “A serene mountain landscape at sunset”</li> <li>Click <strong>“Generate”</strong></li> <li>Watch as the model creates an image in seconds</li>",Ye,q,Gt="This widget uses the same endpoint you’re about to implement in code.",Ee,B,Ht='<p>You’ll need a Hugging Face account (free at <a href="https://huggingface.co" rel="nofollow">huggingface.co</a>) and remaining credits to use the model.</p>',Ve,Q,Se,A,Lt='Now let’s replicate this with Python. Click the <strong>“View Code Snippets”</strong> button in the widget to see the <a href="https://huggingface.co/black-forest-labs/FLUX.1-dev?inference_api=true&amp;language=python&amp;inference_provider=auto" rel="nofollow">generated code snippets</a>.',Xe,R,Yt='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers-guides/code-snippets.png" alt="code snippets image"/>',Ne,z,Et='You will need to populate this snippet with a valid Hugging Face User Access Token. You can find your User Access Token in your <a href="https://huggingface.co/settings/tokens" rel="nofollow">settings page</a>.',Fe,P,Vt="Set your token as an environment variable:",qe,O,Qe,W,St="<p>You can add this line to your <code>.bash_profile</code> or similar file for all your terminal environments to automatically source the token.</p>",Ae,K,Xt="The Python or TypeScript code snippet will use the token from the environment variable.",Re,Z,ze,D,Pe,ee,Nt="Nice work! You’ve successfully used a production-grade AI model without any complex setup. In just a few lines of code, you:",Oe,te,Ft="<li>Connected to a powerful text-to-image model</li> <li>Generated a custom image from text</li> <li>Saved the result locally</li>",Ke,le,qt="The model you just used runs on professional infrastructure, handling scaling, optimization, and reliability automatically.",De,se,et,ne,Qt="You might have noticed the <code>provider=&quot;auto&quot;</code> parameter in the code examples above. This is a key feature of Inference Providers that gives you control over which infrastructure provider handles your request.",tt,ae,At="<code>auto</code> is powerful because:",lt,ie,Rt="<li>It makes it easy to switch between providers, and to test different providers’ performance for your use case.</li> <li>It also gives a fallback mechanism in case a provider is unavailable.</li>",st,pe,zt="But if you want to be more specific, you can also specify a provider. Let’s see how.",nt,oe,at,re,Pt='When you use <code>provider=&quot;auto&quot;</code> (which is the default), the system automatically selects the first available provider for your chosen model based on your preference order in your <a href="https://hf.co/settings/inference-providers" rel="nofollow">Inference Provider settings</a>. This provides:',it,ce,Ot="<li><strong>Automatic failover</strong>: If one provider is unavailable, the system tries the next one</li> <li><strong>Simplified setup</strong>: No need to research which providers support your model</li> <li><strong>Optimal routing</strong>: The system handles provider selection for you</li>",pt,ue,ot,me,Kt="Alternatively, you can explicitly choose a provider if you have specific requirements:",rt,k,ct,fe,ut,he,Dt="<strong>Use <code>provider=&quot;auto&quot;</code> when:</strong>",mt,de,el="<li>You’re just getting started with Inference Providers</li> <li>You want the simplest setup and maximum reliability</li> <li>You don’t have specific infrastructure requirements</li> <li>You want automatic failover if a provider is unavailable</li>",ft,Me,tl="<strong>Use a specific provider when:</strong>",ht,ye,ll="<li>You need consistent performance characteristics</li> <li>You have specific billing or cost requirements</li> <li>You want to test different providers’ performance for your use case</li>",dt,Te,Mt,we,sl="Now that you’ve seen how easy it is to use AI models, you might wonder:",yt,Je,nl="<li>What was that “provider” system doing behind the scenes?</li> <li>How does billing work?</li> <li>What other models can you use?</li>",Tt,ge,al="Continue to the next guide to understand the provider ecosystem and make informed choices about authentication and billing.",wt,je,Jt,be,gt;return p=new Ml({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new C({props:{title:"Your First Inference Provider Call",local:"your-first-inference-provider-call",headingTag:"h1"}}),H=new C({props:{title:"Step 1: Find a Model on the Hub",local:"step-1-find-a-model-on-the-hub",headingTag:"h2"}}),V=new C({props:{title:"Step 2: Try the Interactive Widget",local:"step-2-try-the-interactive-widget",headingTag:"h2"}}),Q=new C({props:{title:"Step 3: From Clicks to Code",local:"step-3-from-clicks-to-code",headingTag:"h2"}}),O=new ve({props:{code:"ZXhwb3J0JTIwSEZfVE9LRU4lM0QlMjJ5b3VyX3Rva2VuX2hlcmUlMjI=",highlighted:'<span class="hljs-built_in">export</span> HF_TOKEN=<span class="hljs-string">&quot;your_token_here&quot;</span>',wrap:!1}}),Z=new rl({props:{id:"python-code-snippet",options:["python","typescript"],$$slots:{default:[Jl]},$$scope:{ctx:U}}}),D=new C({props:{title:"What Just Happened?",local:"what-just-happened",headingTag:"h2"}}),se=new C({props:{title:"Dive Deeper: Provider Selection",local:"dive-deeper-provider-selection",headingTag:"h2"}}),oe=new C({props:{title:"Understanding Provider Selection",local:"understanding-provider-selection",headingTag:"h3"}}),ue=new C({props:{title:"Specifying a Specific Provider",local:"specifying-a-specific-provider",headingTag:"h3"}}),k=new rl({props:{id:"provider-selection-examples",options:["python","typescript"],$$slots:{default:[vl]},$$scope:{ctx:U}}}),fe=new C({props:{title:"When to Use Each Approach",local:"when-to-use-each-approach",headingTag:"h3"}}),Te=new C({props:{title:"Next Steps",local:"next-steps",headingTag:"h2"}}),je=new yl({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/inference-providers/guides/first-api-call.md"}}),{c(){i=c("meta"),d=n(),r=c("p"),h=n(),M(p.$$.fragment),f=n(),M(b.$$.fragment),$=n(),j=c("div"),j.innerHTML=I,o=n(),v=c("p"),v.textContent=$t,Ue=n(),_=c("p"),_.textContent=bt,Ie=n(),G=c("p"),G.innerHTML=Ut,Ce=n(),x=c("blockquote"),x.innerHTML=It,xe=n(),M(H.$$.fragment),Be=n(),L=c("p"),L.innerHTML=Ct,We=n(),Y=c("p"),Y.innerHTML=xt,Ze=n(),E=c("p"),E.innerHTML=Bt,ke=n(),M(V.$$.fragment),_e=n(),S=c("p"),S.innerHTML=Wt,Ge=n(),X=c("p"),X.innerHTML=Zt,He=n(),N=c("p"),N.textContent=kt,Le=n(),F=c("ol"),F.innerHTML=_t,Ye=n(),q=c("p"),q.textContent=Gt,Ee=n(),B=c("blockquote"),B.innerHTML=Ht,Ve=n(),M(Q.$$.fragment),Se=n(),A=c("p"),A.innerHTML=Lt,Xe=n(),R=c("p"),R.innerHTML=Yt,Ne=n(),z=c("p"),z.innerHTML=Et,Fe=n(),P=c("p"),P.textContent=Vt,qe=n(),M(O.$$.fragment),Qe=n(),W=c("blockquote"),W.innerHTML=St,Ae=n(),K=c("p"),K.textContent=Xt,Re=n(),M(Z.$$.fragment),ze=n(),M(D.$$.fragment),Pe=n(),ee=c("p"),ee.textContent=Nt,Oe=n(),te=c("ul"),te.innerHTML=Ft,Ke=n(),le=c("p"),le.textContent=qt,De=n(),M(se.$$.fragment),et=n(),ne=c("p"),ne.innerHTML=Qt,tt=n(),ae=c("p"),ae.innerHTML=At,lt=n(),ie=c("ol"),ie.innerHTML=Rt,st=n(),pe=c("p"),pe.textContent=zt,nt=n(),M(oe.$$.fragment),at=n(),re=c("p"),re.innerHTML=Pt,it=n(),ce=c("ul"),ce.innerHTML=Ot,pt=n(),M(ue.$$.fragment),ot=n(),me=c("p"),me.textContent=Kt,rt=n(),M(k.$$.fragment),ct=n(),M(fe.$$.fragment),ut=n(),he=c("p"),he.innerHTML=Dt,mt=n(),de=c("ul"),de.innerHTML=el,ft=n(),Me=c("p"),Me.innerHTML=tl,ht=n(),ye=c("ul"),ye.innerHTML=ll,dt=n(),M(Te.$$.fragment),Mt=n(),we=c("p"),we.textContent=sl,yt=n(),Je=c("ul"),Je.innerHTML=nl,Tt=n(),ge=c("p"),ge.textContent=al,wt=n(),M(je.$$.fragment),Jt=n(),be=c("p"),this.h()},l(e){const t=hl("svelte-u9bgzb",document.head);i=u(t,"META",{name:!0,content:!0}),t.forEach(l),d=a(e),r=u(e,"P",{}),ol(r).forEach(l),h=a(e),y(p.$$.fragment,e),f=a(e),y(b.$$.fragment,e),$=a(e),j=u(e,"DIV",{class:!0,"data-svelte-h":!0}),m(j)!=="svelte-c1hlgc"&&(j.innerHTML=I),o=a(e),v=u(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-zsh8em"&&(v.textContent=$t),Ue=a(e),_=u(e,"P",{"data-svelte-h":!0}),m(_)!=="svelte-pjp0gs"&&(_.textContent=bt),Ie=a(e),G=u(e,"P",{"data-svelte-h":!0}),m(G)!=="svelte-x2nudu"&&(G.innerHTML=Ut),Ce=a(e),x=u(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(x)!=="svelte-122ax3a"&&(x.innerHTML=It),xe=a(e),y(H.$$.fragment,e),Be=a(e),L=u(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-ix9dqv"&&(L.innerHTML=Ct),We=a(e),Y=u(e,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-1sbosxx"&&(Y.innerHTML=xt),Ze=a(e),E=u(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-1ymaj5t"&&(E.innerHTML=Bt),ke=a(e),y(V.$$.fragment,e),_e=a(e),S=u(e,"P",{"data-svelte-h":!0}),m(S)!=="svelte-ywvg23"&&(S.innerHTML=Wt),Ge=a(e),X=u(e,"P",{"data-svelte-h":!0}),m(X)!=="svelte-k10px9"&&(X.innerHTML=Zt),He=a(e),N=u(e,"P",{"data-svelte-h":!0}),m(N)!=="svelte-tfan97"&&(N.textContent=kt),Le=a(e),F=u(e,"OL",{"data-svelte-h":!0}),m(F)!=="svelte-8mevop"&&(F.innerHTML=_t),Ye=a(e),q=u(e,"P",{"data-svelte-h":!0}),m(q)!=="svelte-1rbio20"&&(q.textContent=Gt),Ee=a(e),B=u(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(B)!=="svelte-1pfiaff"&&(B.innerHTML=Ht),Ve=a(e),y(Q.$$.fragment,e),Se=a(e),A=u(e,"P",{"data-svelte-h":!0}),m(A)!=="svelte-140lfhs"&&(A.innerHTML=Lt),Xe=a(e),R=u(e,"P",{"data-svelte-h":!0}),m(R)!=="svelte-1e9zahi"&&(R.innerHTML=Yt),Ne=a(e),z=u(e,"P",{"data-svelte-h":!0}),m(z)!=="svelte-z2mpc4"&&(z.innerHTML=Et),Fe=a(e),P=u(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-fphway"&&(P.textContent=Vt),qe=a(e),y(O.$$.fragment,e),Qe=a(e),W=u(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(W)!=="svelte-11ogidq"&&(W.innerHTML=St),Ae=a(e),K=u(e,"P",{"data-svelte-h":!0}),m(K)!=="svelte-ke48wm"&&(K.textContent=Xt),Re=a(e),y(Z.$$.fragment,e),ze=a(e),y(D.$$.fragment,e),Pe=a(e),ee=u(e,"P",{"data-svelte-h":!0}),m(ee)!=="svelte-1vb4k34"&&(ee.textContent=Nt),Oe=a(e),te=u(e,"UL",{"data-svelte-h":!0}),m(te)!=="svelte-tw7fp4"&&(te.innerHTML=Ft),Ke=a(e),le=u(e,"P",{"data-svelte-h":!0}),m(le)!=="svelte-emryxg"&&(le.textContent=qt),De=a(e),y(se.$$.fragment,e),et=a(e),ne=u(e,"P",{"data-svelte-h":!0}),m(ne)!=="svelte-1wdbntq"&&(ne.innerHTML=Qt),tt=a(e),ae=u(e,"P",{"data-svelte-h":!0}),m(ae)!=="svelte-1g2gepm"&&(ae.innerHTML=At),lt=a(e),ie=u(e,"OL",{"data-svelte-h":!0}),m(ie)!=="svelte-1yd1kcu"&&(ie.innerHTML=Rt),st=a(e),pe=u(e,"P",{"data-svelte-h":!0}),m(pe)!=="svelte-16cjxf7"&&(pe.textContent=zt),nt=a(e),y(oe.$$.fragment,e),at=a(e),re=u(e,"P",{"data-svelte-h":!0}),m(re)!=="svelte-1i755lw"&&(re.innerHTML=Pt),it=a(e),ce=u(e,"UL",{"data-svelte-h":!0}),m(ce)!=="svelte-zivimi"&&(ce.innerHTML=Ot),pt=a(e),y(ue.$$.fragment,e),ot=a(e),me=u(e,"P",{"data-svelte-h":!0}),m(me)!=="svelte-ef9dcb"&&(me.textContent=Kt),rt=a(e),y(k.$$.fragment,e),ct=a(e),y(fe.$$.fragment,e),ut=a(e),he=u(e,"P",{"data-svelte-h":!0}),m(he)!=="svelte-1tyb5bs"&&(he.innerHTML=Dt),mt=a(e),de=u(e,"UL",{"data-svelte-h":!0}),m(de)!=="svelte-6mck15"&&(de.innerHTML=el),ft=a(e),Me=u(e,"P",{"data-svelte-h":!0}),m(Me)!=="svelte-lc2twy"&&(Me.innerHTML=tl),ht=a(e),ye=u(e,"UL",{"data-svelte-h":!0}),m(ye)!=="svelte-139sjn1"&&(ye.innerHTML=ll),dt=a(e),y(Te.$$.fragment,e),Mt=a(e),we=u(e,"P",{"data-svelte-h":!0}),m(we)!=="svelte-1j0qh13"&&(we.textContent=sl),yt=a(e),Je=u(e,"UL",{"data-svelte-h":!0}),m(Je)!=="svelte-n6vv9b"&&(Je.innerHTML=nl),Tt=a(e),ge=u(e,"P",{"data-svelte-h":!0}),m(ge)!=="svelte-74jiyr"&&(ge.textContent=al),wt=a(e),y(je.$$.fragment,e),Jt=a(e),be=u(e,"P",{}),ol(be).forEach(l),this.h()},h(){$e(i,"name","hf:doc:metadata"),$e(i,"content",bl),$e(j,"class","flex justify-center"),$e(x,"class","tip"),$e(B,"class","warning"),$e(W,"class","tip")},m(e,t){dl(document.head,i),s(e,d,t),s(e,r,t),s(e,h,t),T(p,e,t),s(e,f,t),T(b,e,t),s(e,$,t),s(e,j,t),s(e,o,t),s(e,v,t),s(e,Ue,t),s(e,_,t),s(e,Ie,t),s(e,G,t),s(e,Ce,t),s(e,x,t),s(e,xe,t),T(H,e,t),s(e,Be,t),s(e,L,t),s(e,We,t),s(e,Y,t),s(e,Ze,t),s(e,E,t),s(e,ke,t),T(V,e,t),s(e,_e,t),s(e,S,t),s(e,Ge,t),s(e,X,t),s(e,He,t),s(e,N,t),s(e,Le,t),s(e,F,t),s(e,Ye,t),s(e,q,t),s(e,Ee,t),s(e,B,t),s(e,Ve,t),T(Q,e,t),s(e,Se,t),s(e,A,t),s(e,Xe,t),s(e,R,t),s(e,Ne,t),s(e,z,t),s(e,Fe,t),s(e,P,t),s(e,qe,t),T(O,e,t),s(e,Qe,t),s(e,W,t),s(e,Ae,t),s(e,K,t),s(e,Re,t),T(Z,e,t),s(e,ze,t),T(D,e,t),s(e,Pe,t),s(e,ee,t),s(e,Oe,t),s(e,te,t),s(e,Ke,t),s(e,le,t),s(e,De,t),T(se,e,t),s(e,et,t),s(e,ne,t),s(e,tt,t),s(e,ae,t),s(e,lt,t),s(e,ie,t),s(e,st,t),s(e,pe,t),s(e,nt,t),T(oe,e,t),s(e,at,t),s(e,re,t),s(e,it,t),s(e,ce,t),s(e,pt,t),T(ue,e,t),s(e,ot,t),s(e,me,t),s(e,rt,t),T(k,e,t),s(e,ct,t),T(fe,e,t),s(e,ut,t),s(e,he,t),s(e,mt,t),s(e,de,t),s(e,ft,t),s(e,Me,t),s(e,ht,t),s(e,ye,t),s(e,dt,t),T(Te,e,t),s(e,Mt,t),s(e,we,t),s(e,yt,t),s(e,Je,t),s(e,Tt,t),s(e,ge,t),s(e,wt,t),T(je,e,t),s(e,Jt,t),s(e,be,t),gt=!0},p(e,[t]){const il={};t&2&&(il.$$scope={dirty:t,ctx:e}),Z.$set(il);const pl={};t&2&&(pl.$$scope={dirty:t,ctx:e}),k.$set(pl)},i(e){gt||(w(p.$$.fragment,e),w(b.$$.fragment,e),w(H.$$.fragment,e),w(V.$$.fragment,e),w(Q.$$.fragment,e),w(O.$$.fragment,e),w(Z.$$.fragment,e),w(D.$$.fragment,e),w(se.$$.fragment,e),w(oe.$$.fragment,e),w(ue.$$.fragment,e),w(k.$$.fragment,e),w(fe.$$.fragment,e),w(Te.$$.fragment,e),w(je.$$.fragment,e),gt=!0)},o(e){J(p.$$.fragment,e),J(b.$$.fragment,e),J(H.$$.fragment,e),J(V.$$.fragment,e),J(Q.$$.fragment,e),J(O.$$.fragment,e),J(Z.$$.fragment,e),J(D.$$.fragment,e),J(se.$$.fragment,e),J(oe.$$.fragment,e),J(ue.$$.fragment,e),J(k.$$.fragment,e),J(fe.$$.fragment,e),J(Te.$$.fragment,e),J(je.$$.fragment,e),gt=!1},d(e){e&&(l(d),l(r),l(h),l(f),l($),l(j),l(o),l(v),l(Ue),l(_),l(Ie),l(G),l(Ce),l(x),l(xe),l(Be),l(L),l(We),l(Y),l(Ze),l(E),l(ke),l(_e),l(S),l(Ge),l(X),l(He),l(N),l(Le),l(F),l(Ye),l(q),l(Ee),l(B),l(Ve),l(Se),l(A),l(Xe),l(R),l(Ne),l(z),l(Fe),l(P),l(qe),l(Qe),l(W),l(Ae),l(K),l(Re),l(ze),l(Pe),l(ee),l(Oe),l(te),l(Ke),l(le),l(De),l(et),l(ne),l(tt),l(ae),l(lt),l(ie),l(st),l(pe),l(nt),l(at),l(re),l(it),l(ce),l(pt),l(ot),l(me),l(rt),l(ct),l(ut),l(he),l(mt),l(de),l(ft),l(Me),l(ht),l(ye),l(dt),l(Mt),l(we),l(yt),l(Je),l(Tt),l(ge),l(wt),l(Jt),l(be)),l(i),g(p,e),g(b,e),g(H,e),g(V,e),g(Q,e),g(O,e),g(Z,e),g(D,e),g(se,e),g(oe,e),g(ue,e),g(k,e),g(fe,e),g(Te,e),g(je,e)}}}const bl='{"title":"Your First Inference Provider Call","local":"your-first-inference-provider-call","sections":[{"title":"Step 1: Find a Model on the Hub","local":"step-1-find-a-model-on-the-hub","sections":[],"depth":2},{"title":"Step 2: Try the Interactive Widget","local":"step-2-try-the-interactive-widget","sections":[],"depth":2},{"title":"Step 3: From Clicks to Code","local":"step-3-from-clicks-to-code","sections":[],"depth":2},{"title":"What Just Happened?","local":"what-just-happened","sections":[],"depth":2},{"title":"Dive Deeper: Provider Selection","local":"dive-deeper-provider-selection","sections":[{"title":"Understanding Provider Selection","local":"understanding-provider-selection","sections":[],"depth":3},{"title":"Specifying a Specific Provider","local":"specifying-a-specific-provider","sections":[],"depth":3},{"title":"When to Use Each Approach","local":"when-to-use-each-approach","sections":[],"depth":3}],"depth":2},{"title":"Next Steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function Ul(U){return ul(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class kl extends ml{constructor(i){super(),fl(this,i,Ul,$l,cl,{})}}export{kl as component};
