Skip to content

Commit 2e99c0d

Browse files
committed
python example where possible
1 parent 668df05 commit 2e99c0d

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

docs/api-inference/hub-api.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Finally, you can select all models served by at least one inference provider:
5656

5757
If you are interested by a specific model and want to check if at least 1 provider serves it, you can request the `inference` attribute in the model info endpoint:
5858

59+
<inferencesnippet>
60+
61+
<curl>
62+
5963
```sh
6064
# Get google/gemma-3-27b-it inference status (warm)
6165
~ curl -s https://huggingface.co/api/models/google/gemma-3-27b-it?expand[]=inference
@@ -65,9 +69,30 @@ If you are interested by a specific model and want to check if at least 1 provid
6569
"inference": "warm"
6670
}
6771
```
72+
</curl>
73+
74+
<python>
75+
76+
In the `huggingface_hub`, use `model_info` with the expand parameter:
77+
78+
```py
79+
>>> from huggingface_hub import model_info
80+
81+
>>> info = model_info("google/gemma-3-27b-it", expand="inference")
82+
>>> info.inference
83+
'warm'
84+
```
85+
86+
</python>
87+
88+
</inferencesnippet>
6889

6990
Inference status is either "warm" or undefined:
7091

92+
<inferencesnippet>
93+
94+
<curl>
95+
7196
```sh
7297
# Get inference status (not warm)
7398
~ curl -s https://huggingface.co/api/models/manycore-research/SpatialLM-Llama-1B?expand[]=inference
@@ -77,10 +102,32 @@ Inference status is either "warm" or undefined:
77102
}
78103
```
79104

105+
</curl>
106+
107+
<python>
108+
109+
In the `huggingface_hub`, use `model_info` with the expand parameter:
110+
111+
```py
112+
>>> from huggingface_hub import model_info
113+
114+
>>> info = model_info("manycore-research/SpatialLM-Llama-1B", expand="inference")
115+
>>> info.inference_provider_mapping
116+
None
117+
```
118+
119+
</python>
120+
121+
</inferencesnippet>
122+
80123
## Get model providers
81124

82125
If you are interested by a specific model and want to check the list of providers serving it, you can request the `inferenceProviderMapping` attribute in the model info endpoint:
83126

127+
<inferencesnippet>
128+
129+
<curl>
130+
84131
```sh
85132
# List google/gemma-3-27b-it providers
86133
~ curl -s https://huggingface.co/api/models/google/gemma-3-27b-it?expand[]=inferenceProviderMapping
@@ -101,5 +148,26 @@ If you are interested by a specific model and want to check the list of provider
101148
}
102149
}
103150
```
151+
</curl>
152+
153+
<python>
154+
155+
In the `huggingface_hub`, use `model_info` with the expand parameter:
156+
157+
```py
158+
>>> from huggingface_hub import model_info
159+
160+
>>> info = model_info("google/gemma-3-27b-it", expand="inferenceProviderMapping")
161+
>>> info.inference_provider_mapping
162+
{
163+
'hf-inference': InferenceProviderMapping(status='live', provider_id='google/gemma-3-27b-it', task='conversational'),
164+
'nebius': InferenceProviderMapping(status='live', provider_id='google/gemma-3-27b-it-fast', task='conversational'),
165+
}
166+
```
167+
168+
</python>
169+
170+
</inferencesnippet>
171+
104172

105173
For each provider, you get the status (`staging` or `live`), the related task (here, `conversational`) and the providerId. In practice, this information is mostly relevant for the JS and Python clients. The relevant part is to know that the listed providers are the ones serving the model.

0 commit comments

Comments
 (0)