> ## Documentation Index
> Fetch the complete documentation index at: https://docs.promptguard.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Hugging Face

> Scan Hugging Face Inference Providers traffic through the PromptGuard proxy with any OpenAI client

## Proxy

<Note>
  **Proxy Base URL:** `https://api.promptguard.co/api/v1`

  Point your LLM SDK's `base_url` / `baseURL` to this endpoint. Your existing provider API key goes in the `Authorization` header as usual; add your PromptGuard key via `X-API-Key`.
</Note>

Hub model ids starting `microsoft/phi`, `deepseek-ai/`, `mistralai/`, `tiiuae/`, `bigscience/`, `google/gemma`, `huggingfaceh4/` or `hf/` go to Hugging Face's Inference Providers router. Ids starting `meta-llama/` or `qwen/` do not: [Groq](/integrations/providers/groq) is checked first and claims them.

Hugging Face speaks OpenAI's wire format, so PromptGuard forwards your request to `router.huggingface.co/v1` as you sent it and returns Hugging Face's reply unchanged. Any OpenAI client works.

<CodeGroup>
  ```python Python theme={"system"}
  import os
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.promptguard.co/api/v1",
      api_key=os.environ["HF_TOKEN"],  # forwarded to Hugging Face
      default_headers={"X-API-Key": os.environ["PROMPTGUARD_API_KEY"]},
  )

  response = client.chat.completions.create(
      model="deepseek-ai/DeepSeek-R1",
      messages=[{"role": "user", "content": "Hello!"}],
  )
  print(response.choices[0].message.content)
  ```

  ```typescript Node.js theme={"system"}
  import OpenAI from 'openai';

  const client = new OpenAI({
    baseURL: 'https://api.promptguard.co/api/v1',
    apiKey: process.env.HF_TOKEN, // forwarded to Hugging Face
    defaultHeaders: { 'X-API-Key': process.env.PROMPTGUARD_API_KEY },
  });

  const response = await client.chat.completions.create({
    model: 'deepseek-ai/DeepSeek-R1',
    messages: [{ role: 'user', content: 'Hello!' }],
  });
  console.log(response.choices[0].message.content);
  ```

  ```bash cURL theme={"system"}
  curl https://api.promptguard.co/api/v1/chat/completions \
    -H "X-API-Key: $PROMPTGUARD_API_KEY" \
    -H "Authorization: Bearer $HF_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"model": "deepseek-ai/DeepSeek-R1", "messages": [{"role": "user", "content": "Hello!"}]}'
  ```
</CodeGroup>

To keep the Hugging Face key out of your application, [store it as a provider key](/gateway/provider-keys) under `huggingface`. PromptGuard then sends the stored key and ignores the `Authorization` header you send.

## Auto-instrumentation

The SDKs do not patch `huggingface_hub`. Use the proxy.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.