Skip to content

Commit c6af77f

Browse files
committed
better openai js snippet
1 parent 433c79f commit c6af77f

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

docs/inference-providers/pricing.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,26 @@ To bill your organization with the OpenAI JavaScript client, set the `X-HF-Bill-
216216
import OpenAI from "openai";
217217

218218
const client = new OpenAI({
219-
baseURL: "https://router.huggingface.co/v1",
220-
apiKey: process.env.HF_TOKEN,
221-
defaultHeaders: { "X-HF-Bill-To": "my-org-name" },
219+
baseURL: "https://router.huggingface.co/v1",
220+
apiKey: process.env.HF_TOKEN,
222221
});
223222

224-
const completion = await client.chat.completions.create({
225-
model: "deepseek-ai/DeepSeek-V3-0324",
226-
messages: [
227-
{
228-
role: "user",
229-
content: "How many 'G's in 'huggingface'?",
230-
},
231-
],
232-
});
223+
const completion = await client.chat.completions.create(
224+
{
225+
model: "deepseek-ai/DeepSeek-V3-0324",
226+
messages: [
227+
{
228+
role: "user",
229+
content: "How many 'G's in 'huggingface'?",
230+
},
231+
],
232+
},
233+
{
234+
headers: {
235+
"X-HF-Bill-To": "my-org-name",
236+
},
237+
}
238+
);
233239

234240
console.log(completion.choices[0].message.content);
235241
```

0 commit comments

Comments
 (0)