import{s as Le,n as Se,o as Ae}from"../chunks/scheduler.f6319a2a.js";import{S as Re,i as Be,g as i,s as n,r,A as Pe,h as a,f as l,c as o,j as _e,u as m,x as u,k as ke,y as Ve,a as s,v as p,d,t as f,w as g}from"../chunks/index.85aa684c.js";import{C as E}from"../chunks/CodeBlock.3400fc53.js";import{D as Ge}from"../chunks/DocNotebookDropdown.3fc3604b.js";import{H as ue,E as Oe}from"../chunks/getInferenceSnippets.743412b2.js";function xe(ce){let c,H,N,W,T,j,b,Z,M,Te=`<code>smolagents</code> provides a flexible framework that allows you to use various language models from different providers.
This guide will show you how to use different model types with your agents.`,Q,w,Y,h,be="<code>smolagents</code> supports several model types out of the box:",F,v,Me='<li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.InferenceClientModel">InferenceClientModel</a>: Uses Hugging Face’s Inference API to access models</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.TransformersModel">TransformersModel</a>: Runs models locally using the Transformers library</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.VLLMModel">VLLMModel</a>: Uses vLLM for fast inference with optimized serving</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.MLXModel">MLXModel</a>: Optimized for Apple Silicon devices using MLX</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.LiteLLMModel">LiteLLMModel</a>: Provides access to hundreds of LLMs through LiteLLM</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.LiteLLMRouterModel">LiteLLMRouterModel</a>: Distributes requests among multiple models</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.OpenAIServerModel">OpenAIServerModel</a>: Provides access to any provider that implements an OpenAI-compatible API</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.AzureOpenAIServerModel">AzureOpenAIServerModel</a>: Uses Azure’s OpenAI service</li> <li><a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.AmazonBedrockServerModel">AmazonBedrockServerModel</a>: Connects to AWS Bedrock’s API</li>',X,J,z,$,we=`As explained in the Google Gemini API documentation (<a href="https://ai.google.dev/gemini-api/docs/openai" rel="nofollow">https://ai.google.dev/gemini-api/docs/openai</a>),
Google provides an OpenAI-compatible API for Gemini models, allowing you to use the <a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.OpenAIServerModel">OpenAIServerModel</a>
with Gemini models by setting the appropriate base URL.`,q,I,he="First, install the required dependencies:",D,y,K,U,ve='Then, <a href="https://ai.google.dev/gemini-api/docs/api-key" rel="nofollow">get a Gemini API key</a> and set it in your code:',ee,_,te,k,Je=`Now, you can initialize the Gemini model using the <code>OpenAIServerModel</code> class
and setting the <code>api_base</code> parameter to the Gemini API base URL:`,le,L,se,S,ne,A,$e=`OpenRouter provides access to a wide variety of language models through a unified OpenAI-compatible API.
You can use the <a href="/docs/smolagents/v1.21.1/en/reference/models#smolagents.OpenAIServerModel">OpenAIServerModel</a> to connect to OpenRouter by setting the appropriate base URL.`,oe,R,Ie="First, install the required dependencies:",ie,B,ae,P,ye='Then, <a href="https://openrouter.ai/keys" rel="nofollow">get an OpenRouter API key</a> and set it in your code:',re,V,me,G,Ue="Now, you can initialize any model available on OpenRouter using the <code>OpenAIServerModel</code> class:",pe,O,de,x,fe,C,ge;return T=new ue({props:{title:"Using different models",local:"using-different-models",headingTag:"h1"}}),b=new Ge({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/en/using_different_models.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/en/pytorch/using_different_models.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/smolagents_doc/en/tensorflow/using_different_models.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/en/using_different_models.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/en/pytorch/using_different_models.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/smolagents_doc/en/tensorflow/using_different_models.ipynb"}]}}),w=new ue({props:{title:"Available model types",local:"available-model-types",headingTag:"h2"}}),J=new ue({props:{title:"Using Google Gemini Models",local:"using-google-gemini-models",headingTag:"h2"}}),y=new E({props:{code:"cGlwJTIwaW5zdGFsbCUyMHNtb2xhZ2VudHMlNUJvcGVuYWklNUQ=",highlighted:"pip install smolagents[openai]",wrap:!1}}),_=new E({props:{code:"R0VNSU5JX0FQSV9LRVklMjAlM0QlMjAlM0NZT1VSLUdFTUlOSS1BUEktS0VZJTNF",highlighted:"GEMINI_API_KEY = &lt;YOUR-GEMINI-API-KEY&gt;",wrap:!1}}),L=new E({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBPcGVuQUlTZXJ2ZXJNb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwT3BlbkFJU2VydmVyTW9kZWwoJTBBJTIwJTIwJTIwJTIwbW9kZWxfaWQlM0QlMjJnZW1pbmktMi4wLWZsYXNoJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIzJTIwR29vZ2xlJTIwR2VtaW5pJTIwT3BlbkFJLWNvbXBhdGlibGUlMjBBUEklMjBiYXNlJTIwVVJMJTBBJTIwJTIwJTIwJTIwYXBpX2Jhc2UlM0QlMjJodHRwcyUzQSUyRiUyRmdlbmVyYXRpdmVsYW5ndWFnZS5nb29nbGVhcGlzLmNvbSUyRnYxYmV0YSUyRm9wZW5haSUyRiUyMiUyQyUwQSUyMCUyMCUyMCUyMGFwaV9rZXklM0RHRU1JTklfQVBJX0tFWSUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> OpenAIServerModel

model = OpenAIServerModel(
    model_id=<span class="hljs-string">&quot;gemini-2.0-flash&quot;</span>,
    <span class="hljs-comment"># Google Gemini OpenAI-compatible API base URL</span>
    api_base=<span class="hljs-string">&quot;https://generativelanguage.googleapis.com/v1beta/openai/&quot;</span>,
    api_key=GEMINI_API_KEY,
)`,wrap:!1}}),S=new ue({props:{title:"Using OpenRouter Models",local:"using-openrouter-models",headingTag:"h2"}}),B=new E({props:{code:"cGlwJTIwaW5zdGFsbCUyMHNtb2xhZ2VudHMlNUJvcGVuYWklNUQ=",highlighted:"pip install smolagents[openai]",wrap:!1}}),V=new E({props:{code:"T1BFTlJPVVRFUl9BUElfS0VZJTIwJTNEJTIwJTNDWU9VUi1PUEVOUk9VVEVSLUFQSS1LRVklM0U=",highlighted:"OPENROUTER_API_KEY = &lt;YOUR-OPENROUTER-API-KEY&gt;",wrap:!1}}),O=new E({props:{code:"ZnJvbSUyMHNtb2xhZ2VudHMlMjBpbXBvcnQlMjBPcGVuQUlTZXJ2ZXJNb2RlbCUwQSUwQW1vZGVsJTIwJTNEJTIwT3BlbkFJU2VydmVyTW9kZWwoJTBBJTIwJTIwJTIwJTIwJTIzJTIwWW91JTIwY2FuJTIwdXNlJTIwYW55JTIwbW9kZWwlMjBJRCUyMGF2YWlsYWJsZSUyMG9uJTIwT3BlblJvdXRlciUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTNEJTIyb3BlbmFpJTJGZ3B0LTRvJTIyJTJDJTBBJTIwJTIwJTIwJTIwJTIzJTIwT3BlblJvdXRlciUyMEFQSSUyMGJhc2UlMjBVUkwlMEElMjAlMjAlMjAlMjBhcGlfYmFzZSUzRCUyMmh0dHBzJTNBJTJGJTJGb3BlbnJvdXRlci5haSUyRmFwaSUyRnYxJTIyJTJDJTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRE9QRU5ST1VURVJfQVBJX0tFWSUyQyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> smolagents <span class="hljs-keyword">import</span> OpenAIServerModel

model = OpenAIServerModel(
    <span class="hljs-comment"># You can use any model ID available on OpenRouter</span>
    model_id=<span class="hljs-string">&quot;openai/gpt-4o&quot;</span>,
    <span class="hljs-comment"># OpenRouter API base URL</span>
    api_base=<span class="hljs-string">&quot;https://openrouter.ai/api/v1&quot;</span>,
    api_key=OPENROUTER_API_KEY,
)`,wrap:!1}}),x=new Oe({props:{source:"https://github.com/huggingface/smolagents/blob/main/docs/source/en/examples/using_different_models.md"}}),{c(){c=i("meta"),H=n(),N=i("p"),W=n(),r(T.$$.fragment),j=n(),r(b.$$.fragment),Z=n(),M=i("p"),M.innerHTML=Te,Q=n(),r(w.$$.fragment),Y=n(),h=i("p"),h.innerHTML=be,F=n(),v=i("ol"),v.innerHTML=Me,X=n(),r(J.$$.fragment),z=n(),$=i("p"),$.innerHTML=we,q=n(),I=i("p"),I.textContent=he,D=n(),r(y.$$.fragment),K=n(),U=i("p"),U.innerHTML=ve,ee=n(),r(_.$$.fragment),te=n(),k=i("p"),k.innerHTML=Je,le=n(),r(L.$$.fragment),se=n(),r(S.$$.fragment),ne=n(),A=i("p"),A.innerHTML=$e,oe=n(),R=i("p"),R.textContent=Ie,ie=n(),r(B.$$.fragment),ae=n(),P=i("p"),P.innerHTML=ye,re=n(),r(V.$$.fragment),me=n(),G=i("p"),G.innerHTML=Ue,pe=n(),r(O.$$.fragment),de=n(),r(x.$$.fragment),fe=n(),C=i("p"),this.h()},l(e){const t=Pe("svelte-u9bgzb",document.head);c=a(t,"META",{name:!0,content:!0}),t.forEach(l),H=o(e),N=a(e,"P",{}),_e(N).forEach(l),W=o(e),m(T.$$.fragment,e),j=o(e),m(b.$$.fragment,e),Z=o(e),M=a(e,"P",{"data-svelte-h":!0}),u(M)!=="svelte-nqa3ku"&&(M.innerHTML=Te),Q=o(e),m(w.$$.fragment,e),Y=o(e),h=a(e,"P",{"data-svelte-h":!0}),u(h)!=="svelte-z7j4in"&&(h.innerHTML=be),F=o(e),v=a(e,"OL",{"data-svelte-h":!0}),u(v)!=="svelte-1s2er4p"&&(v.innerHTML=Me),X=o(e),m(J.$$.fragment,e),z=o(e),$=a(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-2vjfps"&&($.innerHTML=we),q=o(e),I=a(e,"P",{"data-svelte-h":!0}),u(I)!=="svelte-1f3oki6"&&(I.textContent=he),D=o(e),m(y.$$.fragment,e),K=o(e),U=a(e,"P",{"data-svelte-h":!0}),u(U)!=="svelte-1scf5a3"&&(U.innerHTML=ve),ee=o(e),m(_.$$.fragment,e),te=o(e),k=a(e,"P",{"data-svelte-h":!0}),u(k)!=="svelte-1a5n7np"&&(k.innerHTML=Je),le=o(e),m(L.$$.fragment,e),se=o(e),m(S.$$.fragment,e),ne=o(e),A=a(e,"P",{"data-svelte-h":!0}),u(A)!=="svelte-1onkxfl"&&(A.innerHTML=$e),oe=o(e),R=a(e,"P",{"data-svelte-h":!0}),u(R)!=="svelte-1f3oki6"&&(R.textContent=Ie),ie=o(e),m(B.$$.fragment,e),ae=o(e),P=a(e,"P",{"data-svelte-h":!0}),u(P)!=="svelte-co5fkh"&&(P.innerHTML=ye),re=o(e),m(V.$$.fragment,e),me=o(e),G=a(e,"P",{"data-svelte-h":!0}),u(G)!=="svelte-1ibsz4t"&&(G.innerHTML=Ue),pe=o(e),m(O.$$.fragment,e),de=o(e),m(x.$$.fragment,e),fe=o(e),C=a(e,"P",{}),_e(C).forEach(l),this.h()},h(){ke(c,"name","hf:doc:metadata"),ke(c,"content",Ee)},m(e,t){Ve(document.head,c),s(e,H,t),s(e,N,t),s(e,W,t),p(T,e,t),s(e,j,t),p(b,e,t),s(e,Z,t),s(e,M,t),s(e,Q,t),p(w,e,t),s(e,Y,t),s(e,h,t),s(e,F,t),s(e,v,t),s(e,X,t),p(J,e,t),s(e,z,t),s(e,$,t),s(e,q,t),s(e,I,t),s(e,D,t),p(y,e,t),s(e,K,t),s(e,U,t),s(e,ee,t),p(_,e,t),s(e,te,t),s(e,k,t),s(e,le,t),p(L,e,t),s(e,se,t),p(S,e,t),s(e,ne,t),s(e,A,t),s(e,oe,t),s(e,R,t),s(e,ie,t),p(B,e,t),s(e,ae,t),s(e,P,t),s(e,re,t),p(V,e,t),s(e,me,t),s(e,G,t),s(e,pe,t),p(O,e,t),s(e,de,t),p(x,e,t),s(e,fe,t),s(e,C,t),ge=!0},p:Se,i(e){ge||(d(T.$$.fragment,e),d(b.$$.fragment,e),d(w.$$.fragment,e),d(J.$$.fragment,e),d(y.$$.fragment,e),d(_.$$.fragment,e),d(L.$$.fragment,e),d(S.$$.fragment,e),d(B.$$.fragment,e),d(V.$$.fragment,e),d(O.$$.fragment,e),d(x.$$.fragment,e),ge=!0)},o(e){f(T.$$.fragment,e),f(b.$$.fragment,e),f(w.$$.fragment,e),f(J.$$.fragment,e),f(y.$$.fragment,e),f(_.$$.fragment,e),f(L.$$.fragment,e),f(S.$$.fragment,e),f(B.$$.fragment,e),f(V.$$.fragment,e),f(O.$$.fragment,e),f(x.$$.fragment,e),ge=!1},d(e){e&&(l(H),l(N),l(W),l(j),l(Z),l(M),l(Q),l(Y),l(h),l(F),l(v),l(X),l(z),l($),l(q),l(I),l(D),l(K),l(U),l(ee),l(te),l(k),l(le),l(se),l(ne),l(A),l(oe),l(R),l(ie),l(ae),l(P),l(re),l(me),l(G),l(pe),l(de),l(fe),l(C)),l(c),g(T,e),g(b,e),g(w,e),g(J,e),g(y,e),g(_,e),g(L,e),g(S,e),g(B,e),g(V,e),g(O,e),g(x,e)}}}const Ee='{"title":"Using different models","local":"using-different-models","sections":[{"title":"Available model types","local":"available-model-types","sections":[],"depth":2},{"title":"Using Google Gemini Models","local":"using-google-gemini-models","sections":[],"depth":2},{"title":"Using OpenRouter Models","local":"using-openrouter-models","sections":[],"depth":2}],"depth":1}';function Ne(ce){return Ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qe extends Re{constructor(c){super(),Be(this,c,Ne,xe,Le,{})}}export{Qe as component};
