You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are using the JavaScript `InferenceClient`, you can set the `billTo` attribute at a client level:
97
+
98
+
99
+
<hfoptionsid="python-clients">
100
+
101
+
<hfoptionid="huggingface_hub">
102
+
103
+
To bill your organization, use the `bill_to` parameter when initializing the client.
104
+
105
+
```python
106
+
from huggingface_hub import InferenceClient
107
+
108
+
client = InferenceClient(bill_to="my-org-name")
109
+
110
+
completion = client.chat.completions.create(
111
+
model="deepseek-ai/DeepSeek-V3-0324",
112
+
messages=[
113
+
{
114
+
"role": "user",
115
+
"content": "How many 'G's in 'huggingface'?"
116
+
}
117
+
],
118
+
)
119
+
120
+
print(completion.choices[0].message)
121
+
```
122
+
123
+
</hfoption>
124
+
125
+
<hfoptionid="openai">
126
+
127
+
To bill your organization when using OpenAI's Python client, set the `X-HF-Bill-To` header using `extra_headers` on the `completions.create` method call.
128
+
129
+
```python
130
+
import os
131
+
from openai import OpenAI
132
+
133
+
client = OpenAI(
134
+
base_url="https://router.huggingface.co/v1",
135
+
api_key=os.environ["HF_TOKEN"],
136
+
)
137
+
138
+
completion = client.chat.completions.create(
139
+
model="deepseek-ai/DeepSeek-V3-0324",
140
+
messages=[
141
+
{
142
+
"role": "user",
143
+
"content": "How many 'G's in 'huggingface'?"
144
+
}
145
+
],
146
+
extra_headers={"X-HF-Bill-To": "my-org-name"},
147
+
)
148
+
149
+
print(completion.choices[0].message)
150
+
```
151
+
152
+
</hfoption>
153
+
154
+
<hfoptionid="requests">
155
+
156
+
To bill your organization when making direct HTTP requests, include the `X-HF-Bill-To` header.
To bill your organization with the OpenAI JavaScript client, set the `X-HF-Bill-To` header using the `defaultHeaders` option on the `completions.create` method call.
0 commit comments