# 推理端点

Inference Endpoints 提供了一种安全的生产级解决方案，可轻松将模型部署在由 Hugging Face 管理的专用且支持自动扩缩容的基础设施上。Inference Endpoint 基于 [Hub](https://huggingface.co/models) 上的模型构建。本页是 `huggingface_hub` 与 Inference Endpoints 集成的参考文档。有关 Inference Endpoints 产品的更多信息，请参阅其[官方文档](https://huggingface.co/docs/inference-endpoints/index)。

> [!TIP]
> 查看[相关指南](../guides/inference_endpoints)，了解如何使用`huggingface_hub`以编程方式管理您的 Inference Endpoints。

Inference Endpoints 可通过 API 完全进行管理。这些端点使用 [Swagger](https://api.endpoints.huggingface.cloud/) 进行了文档说明。[InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint) 类是基于该 API 构建的简单封装。

## 方法

[HfApi](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi) 中实现了 Inference Endpoint 的部分功能：

- 使用 [get_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.get_inference_endpoint) 和 [list_inference_endpoints()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.list_inference_endpoints) 获取有关您的 Inference Endpoints 的信息
- 使用 [list_inference_endpoints_hardware()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.list_inference_endpoints_hardware) 列出可用于部署 Inference Endpoint 的硬件
- 使用 [create_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.create_inference_endpoint)、[update_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.update_inference_endpoint) 和 [delete_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.delete_inference_endpoint) 来部署和管理 Inference Endpoints
- 使用 [list_inference_catalog()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.list_inference_catalog) 和 [create_inference_endpoint_from_catalog()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.create_inference_endpoint_from_catalog) 浏览并部署精选的 Model Catalog
- 使用 [pause_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.pause_inference_endpoint) 和 [resume_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.resume_inference_endpoint) 来暂停和恢复 Inference Endpoint
- 使用 [scale_to_zero_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.scale_to_zero_inference_endpoint) 手动将端点缩容至 0 个副本

## InferenceEndpoint[[huggingface_hub.InferenceEndpoint]]

主要数据类是 [InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint)。它包含已部署的 `InferenceEndpoint` 的相关信息，包括其配置和当前状态。部署完成后，您可以使用 [InferenceEndpoint.client](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.client) 和 [InferenceEndpoint.async_client](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.async_client) 属性在 Endpoint 上运行推理，它们分别返回一个 [InferenceClient](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_client#huggingface_hub.InferenceClient) 对象和一个 [AsyncInferenceClient](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_client#huggingface_hub.AsyncInferenceClient) 对象。

#### huggingface_hub.InferenceEndpoint[[huggingface_hub.InferenceEndpoint]]

```python
huggingface_hub.InferenceEndpoint(namespace: str, raw: dict, _token: str | bool | None, _api: HfApi)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L116)

**参数：**

name (`str`) : Inference Endpoint 的唯一名称。

namespace (`str`) : Inference Endpoint 所在的命名空间。

repository (`str`) : 部署在此推理端点上的模型仓库的名称。

status ([InferenceEndpointStatus](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointStatus))：推理端点的当前状态。

url (`str`, *可选*) : 推理端点的 URL（如果可用）。只有已部署的推理端点才会拥有 URL。

framework (`str`) : 模型所使用的机器学习框架。

revision (`str`) : 部署在 Inference Endpoint 上的特定模型修订版本。

task (`str`) : 与已部署模型关联的任务。

created_at (`datetime.datetime`) : 创建推理端点的时间戳。

updated_at (`datetime.datetime`) : Inference Endpoint 上次更新的时间戳。

type ([InferenceEndpointType](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointType))：推理端点的类型（public、authenticated、private）。

raw (`dict`) : 从 API 返回的原始字典数据。

token (`str` 或 `bool`，*可选*)：Inference Endpoint 的认证令牌，如果在请求 API 时已设置。如果未提供，则默认使用本地保存的令牌。如果不想将令牌发送到服务器，请传入 `token=False`。

包含已部署推理端点的相关信息。

示例：
```python
>>> from huggingface_hub import get_inference_endpoint
>>> endpoint = get_inference_endpoint("my-text-to-image")
>>> endpoint
InferenceEndpoint(name='my-text-to-image', ...)

# Get status
>>> endpoint.status
'running'
>>> endpoint.url
'https://68a0f3b5c6ee5c9dcc0e0a01.endpoints.huggingface.cloud'

# Run inference
>>> endpoint.client.text_to_image(...)

# Pause endpoint to save $$$
>>> endpoint.pause()

# ...
# Resume and wait for deployment
>>> endpoint.resume()
>>> endpoint.wait()
>>> endpoint.client.text_to_image(...)
```

#### from_raw[[huggingface_hub.InferenceEndpoint.from_raw]]

```python
from_raw(raw: dict, namespace: str, token: str | bool | None = None, api: typing.Optional[ForwardRef('HfApi')] = None)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L199)

从原始字典初始化对象。

#### client[[huggingface_hub.InferenceEndpoint.client]]

```python
client()
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L220)

**返回：** [InferenceClient](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_client#huggingface_hub.InferenceClient)

一个指向已部署端点的推理客户端。

**引发：** [InferenceEndpointError](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointError)

- [InferenceEndpointError](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointError) -- 如果推理端点尚未部署。

返回一个客户端，用于在此推理端点上执行预测。

#### async_client[[huggingface_hub.InferenceEndpoint.async_client]]

```python
async_client()
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L242)

**返回：** [AsyncInferenceClient](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_client#huggingface_hub.AsyncInferenceClient)

一个指向已部署端点的 asyncio 兼容推理客户端。

**引发：** [InferenceEndpointError](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointError)

- [InferenceEndpointError](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointError) -- 如果推理端点尚未部署。

返回一个客户端，用于在此推理端点上执行预测。

#### 删除[[huggingface_hub.InferenceEndpoint.delete]]

```python
delete()
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L487)

删除推理端点。

This operation is not reversible. If you don't want to be charged for an Inference Endpoint, it is preferable to pause it with [InferenceEndpoint.pause()](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.pause) or scale it to zero with [InferenceEndpoint.scale_to_zero()](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.scale_to_zero).

这是 [HfApi.delete_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.delete_inference_endpoint) 的别名。

#### fetch[[huggingface_hub.InferenceEndpoint.fetch]]

```python
fetch()
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L317)

**返回：** [InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint)

同一个 Inference Endpoint，使用最新数据就地更新。

获取有关推理端点的最新信息。

#### 暂停[[huggingface_hub.InferenceEndpoint.pause]]

```python
pause()
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L430)

**返回：** [InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint)

同一个 Inference Endpoint，使用最新数据就地更新。

暂停推理端点。

已暂停的 Inference Endpoint 不会产生费用。您可以随时使用 [InferenceEndpoint.resume()](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.resume) 将其恢复。这与使用 [InferenceEndpoint.scale_to_zero()](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.scale_to_zero) 将 Inference Endpoint 缩容至零不同，后者会在收到请求时自动重启。

这是 [HfApi.pause_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.pause_inference_endpoint) 的别名。当前对象会就地使用来自服务器的最新数据进行更新。

#### 恢复[[huggingface_hub.InferenceEndpoint.resume]]

```python
resume(running_ok: bool = True)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L448)

**参数：**

running_ok (`bool`, *可选*) : 如果为 `True`，当推理端点已在运行时，该方法不会引发错误。默认值为 `True`。

**返回：** [InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint)

同一个 Inference Endpoint，使用最新数据就地更新。

恢复推理端点。

这是 [HfApi.resume_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.resume_inference_endpoint) 的别名。当前对象会被就地修改，以包含来自服务器的最新数据。

#### scale_to_zero[[huggingface_hub.InferenceEndpoint.scale_to_zero]]

```python
scale_to_zero()
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L469)

**返回：** [InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint)

同一个 Inference Endpoint，使用最新数据就地更新。

将推理端点缩放到零。

缩放为零的推理端点不会产生费用。在收到下一个请求时，它将恢复运行，但会伴随冷启动延迟。这与使用 [InferenceEndpoint.pause()](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.pause) 暂停推理端点不同，后者需要通过 [InferenceEndpoint.resume()](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint.resume) 手动恢复。

This is an alias for [HfApi.scale_to_zero_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.scale_to_zero_inference_endpoint). The current object is mutated in place with the latest data from the server.

#### 更新[[huggingface_hub.InferenceEndpoint.update]]

```python
update(accelerator: str | None = None, instance_size: str | None = None, instance_type: str | None = None, min_replica: int | None = None, max_replica: int | None = None, scale_to_zero_timeout: int | None = None, repository: str | None = None, framework: str | None = None, revision: str | None = None, task: str | None = None, custom_image: dict | None = None, container_command: list[str] | None = None, container_args: list[str] | None = None, tensor_parallel_size: int | None = None, data_parallel_size: int | None = None, secrets: dict[str, str] | None = None)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L328)

**参数：**

accelerator (`str`, *可选*) : 用于推理的硬件加速器（例如 `"cpu"`）。

instance_size (`str`, *可选*) : 用于托管模型的实例的大小或类型（例如 `"x4"`）。

instance_type (`str`, *可选*) : 推理端点将部署到的云实例类型（例如 `"intel-icl"`）。

min_replica (`int`, *可选*) : 推理端点保持运行的最小副本（实例）数量。

max_replica (`int`, *可选*) : Inference Endpoint 可扩容到的最大副本（实例）数量。

scale_to_zero_timeout (`int`, *可选*) : 非活动端点缩容至零之前的持续时间（以分钟为单位）。

repository (`str`, *可选*) : 与推理端点关联的模型仓库名称（例如 `"gpt2"`）。

framework (`str`, *可选*) : 模型所使用的机器学习框架（例如 `"custom"`）。

revision (`str`, *可选*) : 要在 Inference Endpoint 上部署的特定模型修订版本（例如 `"6c0e6080953db56375760c0471a8c5f2929baf11"`）。

task (`str`，*可选*)：用于部署模型的任务（例如 `"text-classification"`）。

custom_image (`dict`, *可选*) : 要运行的容器镜像。可以是按镜像变体（例如 `{"vLLM": {"url": "vllm/vllm-openai:v0.23.0", "port": 8000}}`，也可以是 `sGLang`、`tgi`、`tei`、`llamacpp`、`hfServe` 等）为键的字典，该字典将原样转发；也可以是一个描述自定义容器的扁平字典（例如 `{"url": ..., "port": ...}`），该字典将作为 `{"custom": ...}` 发送。

container_command (`list[str]`, *可选*) : 覆盖容器入口点命令（对应 API 负载中的 `model.command`）。适用于托管引擎镜像（例如 vLLM、SGLang）和自定义镜像。

container_args (`list[str]`, *可选*) : 附加到容器入口点的参数（对应 API 负载中的 `model.args`）。适用于托管引擎镜像（例如 vLLM、SGLang）和自定义镜像。

tensor_parallel_size (`int`, *可选*) : 用于将单个模型副本分片到多少个加速器上（适用于 vLLM 和 SGLang 镜像）。当未提供 `custom_image` 时，将获取当前在端点上配置的镜像并就地更新，因为 API 要求将 `model.image` 作为整体处理。

data_parallel_size (`int`, *可选*) : 要运行的模型副本数量，每个加速器一个（vLLM 镜像）。

secrets (`dict[str, str]`，*可选*)：要注入到容器环境中的机密值。

**返回：** [InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint)

同一个 Inference Endpoint，使用最新数据就地更新。

更新推理端点。

此方法允许更新计算配置、已部署的模型，或两者同时更新。所有参数均为可选，但必须至少提供一个。

这是 [HfApi.update_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.update_inference_endpoint) 的别名。当前对象会就地使用来自服务器的最新数据进行更新。

#### 等待[[huggingface_hub.InferenceEndpoint.wait]]

```python
wait(timeout: int | None = None, refresh_every: int = 5)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L264)

**参数：**

timeout (`int`, *可选*) : 等待 Inference Endpoint 部署完成的最长时间，单位为秒。如果为 `None`，则会无限期等待。

refresh_every (`int`, *可选*) : 每次获取 Inference Endpoint 状态之间的等待时间，单位为秒。默认值为 5 秒。

**返回：** [InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint)

同一个 Inference Endpoint，使用最新数据就地更新。

**引发：** [InferenceEndpointError](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointError) 或 `InferenceEndpointTimeoutError`

- [InferenceEndpointError](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpointError) -- 如果推理端点最终进入失败状态。
- `InferenceEndpointTimeoutError` -- 如果在 `timeout` 秒后 Inference Endpoint 仍未部署完成。

等待推理端点部署完成。

服务器信息将每 1 秒获取一次。如果在 `timeout` 秒后 Inference Endpoint 仍未部署完成，则会引发 `InferenceEndpointTimeoutError`。[InferenceEndpoint](/docs/huggingface_hub/v2.4.0/zh/package_reference/inference_endpoints#huggingface_hub.InferenceEndpoint) 将就地更新为最新数据。

## InferenceEndpointHardware[[huggingface_hub.InferenceEndpointHardware]]

#### huggingface_hub.InferenceEndpointHardware[[huggingface_hub.InferenceEndpointHardware]]

```python
huggingface_hub.InferenceEndpointHardware(id: str, vendor: str, region: str, accelerator: str, instance_type: str, instance_size: str, architecture: str, num_accelerators: int, num_cpus: int | None, memory_gb: float, gpu_memory_gb: int | None, price_per_hour: float, status: str, max_accelerators: int, used_accelerators: int)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L519)

**参数：**

id (`str`) : 唯一的硬件标识符，例如 `"aws-us-east-1-nvidia-l4-x1"`。

vendor (`str`) : 托管硬件的云服务商，例如 `"aws"`。

region (`str`) : 硬件可用的云区域，例如 `"us-east-1"`。

accelerator (`str`) : 硬件加速器的类型，例如 `"cpu"`、`"gpu"` 或 `"neuron"`。

instance_type (`str`) : 云实例类型，例如 `"nvidia-l4"`。

instance_size (`str`) : 实例大小乘数，例如 `"x1"`。

architecture (`str`) : 人类可读的硬件描述，例如 `"Nvidia L4"`。

num_accelerators (`int`) : 每个副本的加速器单元数量。

num_cpus (`int`, *可选*) : 每个副本的 vCPU 数量。

memory_gb (`float`) : 每个副本的 RAM，单位为 GB。

gpu_memory_gb (`int`, *可选*) : 每个副本的总 GPU 内存，单位为 GB（即对 `num_accelerators` 求和）。非 GPU 硬件为 `None`。

price_per_hour (`float`) : 每个副本每小时的成本，以美元计。

status (`str`) : 硬件的可用性： `"available"`、`"low_availability"`、`"not_available"`、`"reserved"` 或 `"deprecated"`。

max_accelerators (`int`) : 该命名空间允许运行的此类型加速器的最大数量。

used_accelerators (`int`) : 当前命名空间正在使用的此类型加速器的数量。

包含可用于推理端点的硬件配置信息。

`vendor`、`region`、`accelerator`、`instance_type` 和 `instance_size` 字段正是传递给 [create_inference_endpoint()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.create_inference_endpoint)（或 `hf endpoints deploy`）以在此硬件上部署所需的值。

示例：
```python
>>> from huggingface_hub import list_inference_endpoints_hardware
>>> hardware = list_inference_endpoints_hardware()
>>> hardware[0]
InferenceEndpointHardware(id='aws-us-east-1-nvidia-l4-x1', vendor='aws', region='us-east-1', ...)
```

#### from_raw[[huggingface_hub.InferenceEndpointHardware.from_raw]]

```python
from_raw(raw: dict, vendor: str, region: str)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L584)

从 API 响应中嵌套在供应商和区域下的原始计算字典初始化对象。

## InferenceCatalogModel[[huggingface_hub.InferenceCatalogModel]]

#### huggingface_hub.InferenceCatalogModel[[huggingface_hub.InferenceCatalogModel]]

```python
huggingface_hub.InferenceCatalogModel(repo_id: str, name: str, author: str, license: str, task: str, created_at: datetime, recipes: list)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L647)

**参数：**

repo_id (`str`) : Hub 上模型仓库的 id，例如 `"meta-llama/Llama-3.1-8B-Instruct"`。

name (`str`) : 模型名称，即 `repo_id` 中作者之后的部分，例如 `"Llama-3.1-8B-Instruct"`。

author (`str`) : 模型仓库的作者，例如 `"meta-llama"`。

license (`str`) : 模型的许可证，例如 `"Apache 2.0"`。

task (`str`) : 模型部署所执行的任务，例如 `"text-generation"`。

created_at (`datetime`) : 该模型被添加到目录中的日期。

recipes (`list[InferenceCatalogRecipe]`)：此模型经过测试的部署方式。

包含推理目录中可用模型的相关信息。

示例：
```python
>>> from huggingface_hub import list_inference_catalog
>>> catalog = list_inference_catalog(engine="vllm")
>>> catalog[0]
InferenceCatalogModel(repo_id='Qwen/Qwen2.5-Coder-7B-Instruct', name='Qwen2.5-Coder-7B-Instruct', ...)
```

#### from_raw[[huggingface_hub.InferenceCatalogModel.from_raw]]

```python
from_raw(raw: dict)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L684)

从原始目录项字典初始化对象。

## InferenceCatalogRecipe[[huggingface_hub.InferenceCatalogRecipe]]

#### huggingface_hub.InferenceCatalogRecipe[[huggingface_hub.InferenceCatalogRecipe]]

```python
huggingface_hub.InferenceCatalogRecipe(id: str, accelerator: str, engine: str, gguf_file: str | None, revision: str | None)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L608)

**参数：**

id (`str`) : The public recipe id, to pass to [create_inference_endpoint_from_catalog()](/docs/huggingface_hub/v2.4.0/zh/package_reference/hf_api#huggingface_hub.HfApi.create_inference_endpoint_from_catalog) as `recipe_id`.

accelerator (`str`) : 配方运行的硬件加速器类型，例如 `"cpu"`、`"gpu"` 或 `"neuron"`。

engine (`str`) : 配方所运行的推理引擎，例如 `"vllm"`、`"llamacpp"`、`"tei"` 或 `"sglang"`。

gguf_file (`str`，*可选*)：由配方部署的 GGUF 文件。仅针对 `"llamacpp"` 配方设置。

revision (`str`, *可选*) : 配方所固定的模型修订版本（如果有的话）。

包含有关从推理目录部署模型的预测试方法的信息。

配方（recipe）是 Inference Endpoints 团队针对特定模型测试过的硬件与引擎组合。一个模型通常只有一个配方，但也可能有多个（例如一个 GPU 配方和一个 Neuron 配方，或每个 GGUF 量化版本各有一个配方）。

#### from_raw[[huggingface_hub.InferenceCatalogRecipe.from_raw]]

```python
from_raw(raw: dict)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L634)

从 API 响应中嵌套在模型下的原始配方字典初始化对象。

## InferenceEndpointStatus[[huggingface_hub.InferenceEndpointStatus]]

#### huggingface_hub.InferenceEndpointStatus[[huggingface_hub.InferenceEndpointStatus]]

```python
huggingface_hub.InferenceEndpointStatus(value, names = None, module = None, qualname = None, type = None, start = 1)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L93)

一个枚举。

## InferenceEndpointType[[huggingface_hub.InferenceEndpointType]]

#### huggingface_hub.InferenceEndpointType[[huggingface_hub.InferenceEndpointType]]

```python
huggingface_hub.InferenceEndpointType(value, names = None, module = None, qualname = None, type = None, start = 1)
```

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/_inference_endpoints.py#L104)

一个枚举。

## InferenceEndpointError[[huggingface_hub.InferenceEndpointError]]

#### huggingface_hub.InferenceEndpointError[[huggingface_hub.InferenceEndpointError]]

[源代码](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/errors.py#L162)

处理推理端点时出现的通用异常。

