Skip to content

Commit 9a9b8c1

Browse files
authored
Document the difference between model and base_url (#2431)
* Document the difference between model and base_url * include feedback
1 parent 328d0d4 commit 9a9b8c1

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/huggingface_hub/inference/_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ class InferenceClient:
132132
or a URL to a deployed Inference Endpoint. Defaults to None, in which case a recommended model is
133133
automatically selected for the task.
134134
Note: for better compatibility with OpenAI's client, `model` has been aliased as `base_url`. Those 2
135-
arguments are mutually exclusive and have the exact same behavior.
135+
arguments are mutually exclusive. If using `base_url` for chat completion, the `/chat/completions` suffix
136+
path will be appended to the base URL (see the [TGI Messages API](https://huggingface.co/docs/text-generation-inference/en/messages_api)
137+
documentation for details). When passing a URL as `model`, the client will not append any suffix path to it.
136138
token (`str` or `bool`, *optional*):
137139
Hugging Face token. Will default to the locally saved token if not provided.
138140
Pass `token=False` if you don't want to send your token to the server.
@@ -172,7 +174,8 @@ def __init__(
172174
raise ValueError(
173175
"Received both `model` and `base_url` arguments. Please provide only one of them."
174176
" `base_url` is an alias for `model` to make the API compatible with OpenAI's client."
175-
" It has the exact same behavior as `model`."
177+
" If using `base_url` for chat completion, the `/chat/completions` suffix path will be appended to the base url."
178+
" When passing a URL as `model`, the client will not append any suffix path to it."
176179
)
177180
if token is not None and api_key is not None:
178181
raise ValueError(

src/huggingface_hub/inference/_generated/_async_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ class AsyncInferenceClient:
117117
or a URL to a deployed Inference Endpoint. Defaults to None, in which case a recommended model is
118118
automatically selected for the task.
119119
Note: for better compatibility with OpenAI's client, `model` has been aliased as `base_url`. Those 2
120-
arguments are mutually exclusive and have the exact same behavior.
120+
arguments are mutually exclusive. If using `base_url` for chat completion, the `/chat/completions` suffix
121+
path will be appended to the base URL (see the [TGI Messages API](https://huggingface.co/docs/text-generation-inference/en/messages_api)
122+
documentation for details). When passing a URL as `model`, the client will not append any suffix path to it.
121123
token (`str` or `bool`, *optional*):
122124
Hugging Face token. Will default to the locally saved token if not provided.
123125
Pass `token=False` if you don't want to send your token to the server.
@@ -157,7 +159,8 @@ def __init__(
157159
raise ValueError(
158160
"Received both `model` and `base_url` arguments. Please provide only one of them."
159161
" `base_url` is an alias for `model` to make the API compatible with OpenAI's client."
160-
" It has the exact same behavior as `model`."
162+
" If using `base_url` for chat completion, the `/chat/completions` suffix path will be appended to the base url."
163+
" When passing a URL as `model`, the client will not append any suffix path to it."
161164
)
162165
if token is not None and api_key is not None:
163166
raise ValueError(

0 commit comments

Comments
 (0)