Skip to content

Commit 3b8e145

Browse files
[ENG-1639] Grok3 cost support (#3805)
* [ENG-1737] Include Claude 4 Pricing * manual logging in session example * fix build * fix * add grok 3 * lol --------- Co-authored-by: charlie wu <hcharlie1201@gmail.com>
1 parent c006320 commit 3b8e145

File tree

5 files changed

+164
-74
lines changed

5 files changed

+164
-74
lines changed

bifrost/app/llm-cost/provider/[provider]/model/[model]/page.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
} from "../../../../utils";
1111
import { notFound } from "next/navigation";
1212
import { providers } from "@helicone-package/cost/providers/mappings";
13-
1413
export default async function ModelCostPage({
1514
params,
1615
}: {
@@ -22,16 +21,13 @@ export default async function ModelCostPage({
2221
const { provider, model } = params;
2322
const decodedModel = decodeURIComponent(model || "");
2423
const decodedProvider = decodeURIComponent(provider || "");
25-
2624
const initialCostData = getInitialCostData();
2725
const providerWithModels = getProviderWithModelsData(initialCostData);
28-
2926
const modelExists = initialCostData.some(
3027
(d: CostData) =>
3128
d.provider.toLowerCase() === decodedProvider.toLowerCase() &&
3229
d.model.toLowerCase() === decodedModel.toLowerCase()
3330
);
34-
3531
if (!modelExists) {
3632
const providerExists = providerWithModels.some(
3733
(p: ProviderWithModels) =>

examples/session_example/index.ts

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,51 @@ require("dotenv").config({
55
import { randomUUID } from "crypto";
66
import { OpenAI } from "openai";
77

8+
import { HeliconeManualLogger } from "@helicone/helpers";
9+
10+
async function manualLoggerTest() {
11+
const heliconeLogger = new HeliconeManualLogger({
12+
apiKey: process.env.HELICONE_API_KEY ?? "", // Can be set as env variable
13+
headers: {},
14+
loggingEndpoint: `${process.env.HELICONE_BASE_LOGGING_URL}`
15+
});
16+
17+
const reqBody = {
18+
"messages": [
19+
{
20+
"role": "user",
21+
"content": "What is the meaning of life, the universe, and everything?"
22+
}
23+
],
24+
"model": "grok-3",
25+
"stream": false,
26+
"temperature": 0.7
27+
};
28+
29+
const res = await heliconeLogger.logRequest(
30+
reqBody,
31+
async (resultRecorder) => {
32+
const r = await fetch("https://api.x.ai/v1/chat/completions", {
33+
method: "POST",
34+
headers: {
35+
"Content-Type": "application/json",
36+
Authorization: `Bearer ${process.env.XAI_API_KEY}`
37+
},
38+
body: JSON.stringify(reqBody)
39+
});
40+
const resBody = await r.json();
41+
resultRecorder.appendResults(resBody as any);
42+
return resBody;
43+
},
44+
{
45+
"Helicone-Session-Id": "123",
46+
"Helicone-Session-Name": "test",
47+
}
48+
);
49+
50+
console.log(res);
51+
}
52+
853
async function main() {
954
const openai = new OpenAI({
1055
apiKey: process.env.OPENAI_API_KEY,
@@ -22,7 +67,7 @@ async function main() {
2267
messages: [
2368
{
2469
role: "user",
25-
content: "Generate an abstract for a course on space.",
70+
content: "whats good shawty bobfbe",
2671
},
2772
],
2873
model: "gpt-4",
@@ -32,6 +77,8 @@ async function main() {
3277
"Helicone-Session-Id": session,
3378
"Helicone-Session-Name": sessionName,
3479
"Helicone-Session-Path": "/abstract",
80+
"Helicone-Cache-Enabled": "true",
81+
"Helicone-Cache-Max-Bucket-Size": "3",
3582
},
3683
}
3784
);
@@ -136,4 +183,5 @@ async function main() {
136183
);
137184
}
138185

139-
main();
186+
manualLoggerTest();
187+
// main();

examples/session_example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@helicone/helicone": "^2.1.18",
16+
"@helicone/helpers": "^1.1.0",
1617
"dateformat": "^5.0.3",
1718
"dotenv": "^16.4.5",
1819
"openai": "^4.45.0",

0 commit comments

Comments
 (0)