{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-04-29-deepinfra-on-hugging-face-inference-providers-fire/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "[![banner image](https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg)](https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg)\n\nWe're thrilled to share that **DeepInfra** is now a supported Inference Provider on the Hugging Face Hub!\n\nDeepInfra joins our growing ecosystem, enhancing the breadth and capabilities of serverless inference directly on the Hub's model pages. Inference Providers are also seamlessly integrated into our client SDKs (for both JS and Python), making it super easy to use a wide variety of models with your preferred providers.\n\n[DeepInfra](https://deepinfra.com) is a serverless AI inference platform offering one of the most cost-effective pricing per token in the industry. With a catalog of over 100 models, DeepInfra makes it easy for developers to integrate a wide range of AI capabilities into their applications with minimal setup.\n\nDeepInfra supports a broad spectrum of model types - from LLMs to text-to-image, text-to-video, embeddings, and more. As part of this initial integration, DeepInfra is launching support for **conversational and text-generation tasks** on Hugging Face, enabling access to popular open-weight LLMs such as [DeepSeek V4](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro?inference_provider=deepinfra), [Kimi-K2.6](https://huggingface.co/moonshotai/Kimi-K2.6?inference_provider=deepinfra), [GLM-5.1](https://huggingface.co/zai-org/GLM-5.1?inference_provider=deepinfra), and many more. **Support for additional tasks** (text-to-image, text-to-video, embeddings, and more) will roll out soon!\n\nRead more about how to use DeepInfra as an Inference Provider in its dedicated [documentation page](https://huggingface.co/docs/inference-providers/providers/deepinfra).\n\nSee the full list of models supported by DeepInfra [here](https://huggingface.co/models?inference_provider=deepinfra&sort=trending).\n\nFollow DeepInfra on Hugging Face: [https://huggingface.co/DeepInfra](https://huggingface.co/DeepInfra).\n\n## How it works\n\n### In the website UI\n\n1. In your user account settings, you are able to:\n\n- Set your own API keys for the providers you've signed up with. If no custom key is set, your requests will be routed through HF.\n- Order providers by preference. This applies to the widget and code snippets in the model pages.\n\n![Inference Providers](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/user-setting-v2.png)\n\n2. As mentioned, there are two modes when calling Inference Providers:\n\n- Custom key (calls go directly to the inference provider, using your own API key of the corresponding inference provider)\n- Routed by HF (in that case, you don't need a token from the provider, and the charges are applied directly to your HF account rather than the provider's account)\n\n![Inference Providers](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/explainer.png)\n\n3. Model pages showcase third-party inference providers (the ones that are compatible with the current model, sorted by user preference)\n\n![Inference Providers](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/model-widget-v2.png)\n\n### From the client SDKs\n\nDeepInfra is available through the Hugging Face SDKs - `huggingface_hub` (>= 1.11.2) for Python and `@huggingface/inference` for JavaScript.\n\nThe following examples show how to use [DeepSeek V4 Pro](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro) through DeepInfra. Use a [Hugging Face token](https://huggingface.co/settings/tokens) to authenticate - the request will be routed to DeepInfra automatically.\n\n#### From your favorite Agent Harness\n\nHugging Face Inference Providers are integrated in most Agent Harnesses - including Pi, OpenCode, Hermes Agents, OpenClaw, and more. This means you can plug DeepInfra-hosted models straight into your favorite tools without any extra glue code. Browse the full list of integrations [here](https://huggingface.co/docs/inference-providers/en/integrations/index).\n\n#### from Python\n\n```python\nimport os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://router.huggingface.co/v1\",\n    api_key=os.environ[\"HF_TOKEN\"],\n)\n\ncompletion = client.chat.completions.create(\n    model=\"deepseek-ai/DeepSeek-V4-Pro:deepinfra\",\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": \"Write a Python function that returns the nth Fibonacci number using memoization.\"\n        }\n    ],\n)\n\nprint(completion.choices[0].message)\n```\n\n#### from JS\n\n```js\nimport { OpenAI } from \"openai\";\n\nconst client = new OpenAI({\n    baseURL: \"https://router.huggingface.co/v1\",\n    apiKey: process.env.HF_TOKEN,\n});\n\nconst chatCompletion = await client.chat.completions.create({\n    model: \"deepseek-ai/DeepSeek-V4-Pro:deepinfra\",\n    messages: [\n        {\n            role: \"user\",\n            content: \"Write a Python function that returns the nth Fibonacci number using memoization.\",\n        },\n    ],\n});\n\nconsole.log(chatCompletion.choices[0].message);\n```\n\n## Billing\n\nFor direct requests, i.e. when you use the key from an inference provider, you are billed by the corresponding provider. For instance, if you use a DeepInfra API key you're billed on your DeepInfra account.\n\nFor routed requests, i.e. when you authenticate via the Hugging Face Hub, you'll only pay the standard provider API rates. There's no additional markup from us; we just pass through the provider costs directly. (In the future, we may establish revenue-sharing agreements with our provider partners.)\n\n**Important Note** ‼️ PRO users get $2 worth of Inference credits every month. You can use them across providers. 🔥\n\nSubscribe to the [Hugging Face PRO plan](https://hf.co/subscribe/pro) to get access to Inference credits, ZeroGPU, Spaces Dev Mode, 20x higher limits, and more.\n\nWe also provide free inference with a small quota for our signed-in free users, but please upgrade to PRO if you can!\n\n## Feedback and next steps\n\nWe would love to get your feedback! Share your thoughts and/or comments here: [https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/49](https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/49)\n",
  "authors": [],
  "captured_at": "2026-10-19T01:26:53.998049939+00:00",
  "category": "ai",
  "content_html": "<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg\"><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg\" alt=\"banner image\" loading=\"eager\" decoding=\"async\" fetchpriority=\"high\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></a></p>\n<p>We're thrilled to share that <strong>DeepInfra</strong> is now a supported Inference Provider on the Hugging Face Hub!</p>\n<p>DeepInfra joins our growing ecosystem, enhancing the breadth and capabilities of serverless inference directly on the Hub's model pages. Inference Providers are also seamlessly integrated into our client SDKs (for both JS and Python), making it super easy to use a wide variety of models with your preferred providers.</p>\n<p><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://deepinfra.com\">DeepInfra</a> is a serverless AI inference platform offering one of the most cost-effective pricing per token in the industry. With a catalog of over 100 models, DeepInfra makes it easy for developers to integrate a wide range of AI capabilities into their applications with minimal setup.</p>\n<p>DeepInfra supports a broad spectrum of model types - from LLMs to text-to-image, text-to-video, embeddings, and more. As part of this initial integration, DeepInfra is launching support for <strong>conversational and text-generation tasks</strong> on Hugging Face, enabling access to popular open-weight LLMs such as <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro?inference_provider=deepinfra\">DeepSeek V4</a>, <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/moonshotai/Kimi-K2.6?inference_provider=deepinfra\">Kimi-K2.6</a>, <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/zai-org/GLM-5.1?inference_provider=deepinfra\">GLM-5.1</a>, and many more. <strong>Support for additional tasks</strong> (text-to-image, text-to-video, embeddings, and more) will roll out soon!</p>\n<p>Read more about how to use DeepInfra as an Inference Provider in its dedicated <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/inference-providers/providers/deepinfra\">documentation page</a>.</p>\n<p>See the full list of models supported by DeepInfra <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/models?inference_provider=deepinfra&amp;sort=trending\">here</a>.</p>\n<p>Follow DeepInfra on Hugging Face: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/DeepInfra\">https://huggingface.co/DeepInfra</a>.</p>\n<h2>How it works</h2>\n<h3>In the website UI</h3>\n<ol>\n<li>In your user account settings, you are able to:</li>\n</ol>\n<ul>\n<li>Set your own API keys for the providers you've signed up with. If no custom key is set, your requests will be routed through HF.</li>\n<li>Order providers by preference. This applies to the widget and code snippets in the model pages.</li>\n</ul>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/user-setting-v2.png\" alt=\"Inference Providers\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<ol start=\"2\">\n<li>As mentioned, there are two modes when calling Inference Providers:</li>\n</ol>\n<ul>\n<li>Custom key (calls go directly to the inference provider, using your own API key of the corresponding inference provider)</li>\n<li>Routed by HF (in that case, you don't need a token from the provider, and the charges are applied directly to your HF account rather than the provider's account)</li>\n</ul>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/explainer.png\" alt=\"Inference Providers\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<ol start=\"3\">\n<li>Model pages showcase third-party inference providers (the ones that are compatible with the current model, sorted by user preference)</li>\n</ol>\n<p><picture class=\"article-picture article-picture-fallback\" style=\"--image-ratio:16 / 9\"><img src=\"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/model-widget-v2.png\" alt=\"Inference Providers\" loading=\"lazy\" decoding=\"async\" fetchpriority=\"low\" referrerpolicy=\"no-referrer\" class=\"progressive-image\"></picture></p>\n<h3>From the client SDKs</h3>\n<p>DeepInfra is available through the Hugging Face SDKs - <code>huggingface_hub</code> (&gt;= 1.11.2) for Python and <code>@huggingface/inference</code> for JavaScript.</p>\n<p>The following examples show how to use <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro\">DeepSeek V4 Pro</a> through DeepInfra. Use a <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/settings/tokens\">Hugging Face token</a> to authenticate - the request will be routed to DeepInfra automatically.</p>\n<h4>From your favorite Agent Harness</h4>\n<p>Hugging Face Inference Providers are integrated in most Agent Harnesses - including Pi, OpenCode, Hermes Agents, OpenClaw, and more. This means you can plug DeepInfra-hosted models straight into your favorite tools without any extra glue code. Browse the full list of integrations <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/docs/inference-providers/en/integrations/index\">here</a>.</p>\n<h4>from Python</h4>\n<pre><code class=\"language-python\"><span class=\"code-snippet\" data-language=\"Python\"><span class=\"syntax-source syntax-python\"><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-python\">import</span> <span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">os</span></span></span>\n<span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-from syntax-python\">from</span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-meta syntax-import-source syntax-python\"> <span class=\"syntax-meta syntax-import-path syntax-python\"><span class=\"syntax-meta syntax-import-name syntax-python\">openai</span></span> <span class=\"syntax-meta syntax-statement syntax-import syntax-python\"><span class=\"syntax-keyword syntax-control syntax-import syntax-python\">import</span></span></span></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"></span><span class=\"syntax-meta syntax-statement syntax-import syntax-python\"> <span class=\"syntax-meta syntax-generic-name syntax-python\">OpenAI</span></span>\n\n<span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">client</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">OpenAI</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">\n    <span class=\"syntax-variable syntax-parameter syntax-python\">base_url</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">https://router.huggingface.co/v1<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>\n    <span class=\"syntax-variable syntax-parameter syntax-python\">api_key</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-item-access syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">os</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span><span class=\"syntax-meta syntax-generic-name syntax-python\">environ</span></span></span><span class=\"syntax-meta syntax-item-access syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-begin syntax-python\">[</span></span><span class=\"syntax-meta syntax-item-access syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">HF_TOKEN<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span></span><span class=\"syntax-meta syntax-item-access syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-end syntax-python\">]</span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>\n</span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n\n<span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">completion</span></span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span> <span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">client</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span><span class=\"syntax-meta syntax-generic-name syntax-python\">chat</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span><span class=\"syntax-meta syntax-generic-name syntax-python\">completions</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span></span><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-variable syntax-function syntax-python\">create</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\">\n    <span class=\"syntax-variable syntax-parameter syntax-python\">model</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">deepseek-ai/DeepSeek-V4-Pro:deepinfra<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>\n    <span class=\"syntax-variable syntax-parameter syntax-python\">messages</span><span class=\"syntax-keyword syntax-operator syntax-assignment syntax-python\">=</span><span class=\"syntax-meta syntax-structure syntax-list syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-list syntax-begin syntax-python\">[</span>\n        <span class=\"syntax-meta syntax-structure syntax-dictionary-or-set syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-dictionary-or-set syntax-begin syntax-python\">{</span>\n            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">role<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-python\">:</span> <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">user<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-dictionary-or-set syntax-python\">,</span>\n            <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">content<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-python\">:</span> <span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-python\">&quot;</span></span></span><span class=\"syntax-meta syntax-string syntax-python\"><span class=\"syntax-string syntax-quoted syntax-double syntax-python\">Write a Python function that returns the nth Fibonacci number using memoization.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-python\">&quot;</span></span></span>\n        <span class=\"syntax-punctuation syntax-section syntax-dictionary-or-set syntax-end syntax-python\">}</span></span>\n    <span class=\"syntax-punctuation syntax-section syntax-list syntax-end syntax-python\">]</span></span><span class=\"syntax-punctuation syntax-separator syntax-arguments syntax-python\">,</span>\n</span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n\n<span class=\"syntax-meta syntax-function-call syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-support syntax-function syntax-builtin syntax-python\">print</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-begin syntax-python\">(</span><span class=\"syntax-meta syntax-function-call syntax-arguments syntax-python\"><span class=\"syntax-meta syntax-item-access syntax-python\"><span class=\"syntax-meta syntax-qualified-name syntax-python\"><span class=\"syntax-meta syntax-generic-name syntax-python\">completion</span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span><span class=\"syntax-meta syntax-generic-name syntax-python\">choices</span></span></span><span class=\"syntax-meta syntax-item-access syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-begin syntax-python\">[</span></span><span class=\"syntax-meta syntax-item-access syntax-arguments syntax-python\"><span class=\"syntax-constant syntax-numeric syntax-integer syntax-decimal syntax-python\">0</span></span><span class=\"syntax-meta syntax-item-access syntax-python\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-end syntax-python\">]</span></span><span class=\"syntax-punctuation syntax-accessor syntax-dot syntax-python\">.</span><span class=\"syntax-meta syntax-generic-name syntax-python\">message</span></span><span class=\"syntax-punctuation syntax-section syntax-arguments syntax-end syntax-python\">)</span></span>\n</span></span></code></pre>\n<h4>from JS</h4>\n<pre><code class=\"language-js\"><span class=\"code-snippet\" data-language=\"JavaScript\"><span class=\"syntax-source syntax-js\"><span class=\"syntax-meta syntax-import syntax-js\"><span class=\"syntax-keyword syntax-control syntax-import-export syntax-js\">import</span> <span class=\"syntax-meta syntax-block syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">OpenAI</span> <span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span> <span class=\"syntax-keyword syntax-control syntax-import-export syntax-js\">from</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-js\">&quot;</span>openai<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-js\">&quot;</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n\n<span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">client</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-meta syntax-instance syntax-constructor syntax-js\"><span class=\"syntax-keyword syntax-operator syntax-word syntax-new syntax-js\">new</span><span class=\"syntax-meta syntax-function-call syntax-constructor syntax-js\"> <span class=\"syntax-variable syntax-type syntax-js\">OpenAI</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-meta syntax-object-literal syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span>\n    <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">baseURL</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-js\">&quot;</span>https://router.huggingface.co/v1<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-js\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n    <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">apiKey</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-support syntax-type syntax-object syntax-process syntax-js\">process</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-support syntax-type syntax-object syntax-process syntax-js\">env</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-property syntax-object syntax-js\">HF_TOKEN</span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n<span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n\n<span class=\"syntax-storage syntax-type syntax-js\">const</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">chatCompletion</span> <span class=\"syntax-keyword syntax-operator syntax-assignment syntax-js\">=</span> <span class=\"syntax-variable syntax-other syntax-readwrite syntax-js\">await</span> <span class=\"syntax-variable syntax-other syntax-object syntax-js\">client</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-property syntax-object syntax-js\">chat</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-property syntax-object syntax-js\">completions</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-function-call syntax-method syntax-js\"><span class=\"syntax-variable syntax-function syntax-js\">create</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-meta syntax-object-literal syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span>\n    <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">model</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-js\">&quot;</span>deepseek-ai/DeepSeek-V4-Pro:deepinfra<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-js\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n    <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">messages</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-meta syntax-sequence syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">[</span>\n        <span class=\"syntax-meta syntax-object-literal syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">{</span>\n            <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">role</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-js\">&quot;</span>user<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-js\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n            <span class=\"syntax-meta syntax-object-literal syntax-key syntax-js\">content</span><span class=\"syntax-punctuation syntax-separator syntax-key-value syntax-js\">:</span> <span class=\"syntax-string syntax-quoted syntax-double syntax-js\"><span class=\"syntax-punctuation syntax-definition syntax-string syntax-begin syntax-js\">&quot;</span>Write a Python function that returns the nth Fibonacci number using memoization.<span class=\"syntax-punctuation syntax-definition syntax-string syntax-end syntax-js\">&quot;</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n        <span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n    <span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">]</span></span><span class=\"syntax-punctuation syntax-separator syntax-comma syntax-js\">,</span>\n<span class=\"syntax-punctuation syntax-section syntax-block syntax-js\">}</span></span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n\n<span class=\"syntax-meta syntax-function-call syntax-method syntax-js\"><span class=\"syntax-support syntax-type syntax-object syntax-console syntax-js\">console</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-support syntax-function syntax-console syntax-js\">log</span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">(</span><span class=\"syntax-variable syntax-other syntax-object syntax-js\">chatCompletion</span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-property syntax-object syntax-js\">choices</span><span class=\"syntax-meta syntax-brackets syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">[</span><span class=\"syntax-constant syntax-numeric syntax-js\">0</span><span class=\"syntax-punctuation syntax-section syntax-brackets syntax-js\">]</span></span><span class=\"syntax-punctuation syntax-accessor syntax-js\">.</span><span class=\"syntax-meta syntax-property syntax-object syntax-js\">message</span></span><span class=\"syntax-meta syntax-group syntax-js\"><span class=\"syntax-punctuation syntax-section syntax-group syntax-js\">)</span></span></span><span class=\"syntax-punctuation syntax-terminator syntax-statement syntax-js\">;</span>\n</span></span></code></pre>\n<h2>Billing</h2>\n<p>For direct requests, i.e. when you use the key from an inference provider, you are billed by the corresponding provider. For instance, if you use a DeepInfra API key you're billed on your DeepInfra account.</p>\n<p>For routed requests, i.e. when you authenticate via the Hugging Face Hub, you'll only pay the standard provider API rates. There's no additional markup from us; we just pass through the provider costs directly. (In the future, we may establish revenue-sharing agreements with our provider partners.)</p>\n<p><strong>Important Note</strong> ‼️ PRO users get $2 worth of Inference credits every month. You can use them across providers. 🔥</p>\n<p>Subscribe to the <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://hf.co/subscribe/pro\">Hugging Face PRO plan</a> to get access to Inference credits, ZeroGPU, Spaces Dev Mode, 20x higher limits, and more.</p>\n<p>We also provide free inference with a small quota for our signed-in free users, but please upgrade to PRO if you can!</p>\n<h2>Feedback and next steps</h2>\n<p>We would love to get your feedback! Share your thoughts and/or comments here: <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/49\">https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/49</a></p>\n",
  "content_markdown": "[![banner image](https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg)](https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg)\n\nWe're thrilled to share that **DeepInfra** is now a supported Inference Provider on the Hugging Face Hub!\n\nDeepInfra joins our growing ecosystem, enhancing the breadth and capabilities of serverless inference directly on the Hub's model pages. Inference Providers are also seamlessly integrated into our client SDKs (for both JS and Python), making it super easy to use a wide variety of models with your preferred providers.\n\n[DeepInfra](https://deepinfra.com) is a serverless AI inference platform offering one of the most cost-effective pricing per token in the industry. With a catalog of over 100 models, DeepInfra makes it easy for developers to integrate a wide range of AI capabilities into their applications with minimal setup.\n\nDeepInfra supports a broad spectrum of model types - from LLMs to text-to-image, text-to-video, embeddings, and more. As part of this initial integration, DeepInfra is launching support for **conversational and text-generation tasks** on Hugging Face, enabling access to popular open-weight LLMs such as [DeepSeek V4](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro?inference_provider=deepinfra), [Kimi-K2.6](https://huggingface.co/moonshotai/Kimi-K2.6?inference_provider=deepinfra), [GLM-5.1](https://huggingface.co/zai-org/GLM-5.1?inference_provider=deepinfra), and many more. **Support for additional tasks** (text-to-image, text-to-video, embeddings, and more) will roll out soon!\n\nRead more about how to use DeepInfra as an Inference Provider in its dedicated [documentation page](https://huggingface.co/docs/inference-providers/providers/deepinfra).\n\nSee the full list of models supported by DeepInfra [here](https://huggingface.co/models?inference_provider=deepinfra&sort=trending).\n\nFollow DeepInfra on Hugging Face: [https://huggingface.co/DeepInfra](https://huggingface.co/DeepInfra).\n\n## How it works\n\n### In the website UI\n\n1. In your user account settings, you are able to:\n\n- Set your own API keys for the providers you've signed up with. If no custom key is set, your requests will be routed through HF.\n- Order providers by preference. This applies to the widget and code snippets in the model pages.\n\n![Inference Providers](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/user-setting-v2.png)\n\n2. As mentioned, there are two modes when calling Inference Providers:\n\n- Custom key (calls go directly to the inference provider, using your own API key of the corresponding inference provider)\n- Routed by HF (in that case, you don't need a token from the provider, and the charges are applied directly to your HF account rather than the provider's account)\n\n![Inference Providers](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/explainer.png)\n\n3. Model pages showcase third-party inference providers (the ones that are compatible with the current model, sorted by user preference)\n\n![Inference Providers](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/inference-providers/model-widget-v2.png)\n\n### From the client SDKs\n\nDeepInfra is available through the Hugging Face SDKs - `huggingface_hub` (>= 1.11.2) for Python and `@huggingface/inference` for JavaScript.\n\nThe following examples show how to use [DeepSeek V4 Pro](https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro) through DeepInfra. Use a [Hugging Face token](https://huggingface.co/settings/tokens) to authenticate - the request will be routed to DeepInfra automatically.\n\n#### From your favorite Agent Harness\n\nHugging Face Inference Providers are integrated in most Agent Harnesses - including Pi, OpenCode, Hermes Agents, OpenClaw, and more. This means you can plug DeepInfra-hosted models straight into your favorite tools without any extra glue code. Browse the full list of integrations [here](https://huggingface.co/docs/inference-providers/en/integrations/index).\n\n#### from Python\n\n```python\nimport os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"https://router.huggingface.co/v1\",\n    api_key=os.environ[\"HF_TOKEN\"],\n)\n\ncompletion = client.chat.completions.create(\n    model=\"deepseek-ai/DeepSeek-V4-Pro:deepinfra\",\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": \"Write a Python function that returns the nth Fibonacci number using memoization.\"\n        }\n    ],\n)\n\nprint(completion.choices[0].message)\n```\n\n#### from JS\n\n```js\nimport { OpenAI } from \"openai\";\n\nconst client = new OpenAI({\n    baseURL: \"https://router.huggingface.co/v1\",\n    apiKey: process.env.HF_TOKEN,\n});\n\nconst chatCompletion = await client.chat.completions.create({\n    model: \"deepseek-ai/DeepSeek-V4-Pro:deepinfra\",\n    messages: [\n        {\n            role: \"user\",\n            content: \"Write a Python function that returns the nth Fibonacci number using memoization.\",\n        },\n    ],\n});\n\nconsole.log(chatCompletion.choices[0].message);\n```\n\n## Billing\n\nFor direct requests, i.e. when you use the key from an inference provider, you are billed by the corresponding provider. For instance, if you use a DeepInfra API key you're billed on your DeepInfra account.\n\nFor routed requests, i.e. when you authenticate via the Hugging Face Hub, you'll only pay the standard provider API rates. There's no additional markup from us; we just pass through the provider costs directly. (In the future, we may establish revenue-sharing agreements with our provider partners.)\n\n**Important Note** ‼️ PRO users get $2 worth of Inference credits every month. You can use them across providers. 🔥\n\nSubscribe to the [Hugging Face PRO plan](https://hf.co/subscribe/pro) to get access to Inference credits, ZeroGPU, Spaces Dev Mode, 20x higher limits, and more.\n\nWe also provide free inference with a small quota for our signed-in free users, but please upgrade to PRO if you can!\n\n## Feedback and next steps\n\nWe would love to get your feedback! Share your thoughts and/or comments here: [https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/49](https://huggingface.co/spaces/huggingface/HuggingDiscussions/discussions/49)\n",
  "dateCreated": "2026-10-19T01:26:53.998049939+00:00",
  "date_created": "2026-04-29T00:00:00+00:00",
  "date_modified": "2026-04-29T00:00:00+00:00",
  "date_published": "2026-04-29T00:00:00+00:00",
  "description": "We're thrilled to share that DeepInfra is now a supported Inference Provider on the Hugging Face Hub! DeepInfra joins our growing ecosystem, enhancing the breadth and capabilities of serverless inference directly on the Hub's model pages.…",
  "external_url": "https://huggingface.co/blog/inference-providers-deepinfra",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/huggingface-co/2026/04/2026-04-29-deepinfra-on-hugging-face-inference-providers-fire.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/huggingface-co/2026/04/2026-04-29-deepinfra-on-hugging-face-inference-providers-fire.md"
  },
  "id": "urn:aggr:item:920e022e3ad40eda46293b74ac8cc7dad2a89dba",
  "isBasedOn": {
    "@id": "https://huggingface.co/blog/inference-providers-deepinfra"
  },
  "mainEntity": {
    "@id": "https://huggingface.co/blog/inference-providers-deepinfra",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-04-29-deepinfra-on-hugging-face-inference-providers-fire/#webpage"
    },
    "dateModified": "2026-04-29T00:00:00+00:00",
    "datePublished": "2026-04-29T00:00:00+00:00",
    "headline": "DeepInfra on Hugging Face Inference Providers",
    "image": {
      "@type": "ImageObject",
      "caption": "banner image",
      "height": 90,
      "url": "https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg",
      "width": 160
    },
    "timeRequired": "PT4M",
    "url": "https://huggingface.co/blog/inference-providers-deepinfra",
    "wordCount": 714
  },
  "name": "Archived snapshot: DeepInfra on Hugging Face Inference Providers",
  "preview": {
    "alt": "banner image",
    "color": null,
    "height": 90,
    "placeholder": {
      "data_url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
      "hash": ""
    },
    "url": "https://huggingface.co/blog/assets/inference-providers/welcome-deepinfra.jpg",
    "width": 160
  },
  "reading_minutes": 4,
  "replicated_at": null,
  "source": "huggingface-co",
  "source_name": "Hugging Face - Blog",
  "summary": null,
  "tags": [],
  "temporalCoverage": "2026-10-19T01:26:53.998049939+00:00",
  "title": "DeepInfra on Hugging Face Inference Providers",
  "url": "https://aggr.aymericbeaumet.com/items/huggingface-co/2026-04-29-deepinfra-on-hugging-face-inference-providers-fire/",
  "word_count": 714
}