Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Mistral AI cost table and vendor integration #357

Merged
merged 6 commits into from
Nov 21, 2024
Merged
2 changes: 2 additions & 0 deletions components/shared/vendor-metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ export function VendorLogo({
);
}



if (vendor.includes("xai")) {
const color = vendorColor("vercel");
return (
Expand Down
43 changes: 43 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,49 @@ export const OPENAI_PRICING: Record<string, CostTableEntry> = {

};

export const MISTRAL_PRICING: Record<string, CostTableEntry> = {
"mistral-large-latest": {
input: 0.002,
output: 0.006,
},
"pixtral-large-latest": {
input: 0.002,
output: 0.006,
},
"mistral-small-latest": {
input: 0.0002,
output: 0.0006,
},
"codestral-latest": {
input: 0.0002,
output: 0.0006,
},
"ministral-8b-latest": {
input: 0.0001,
output: 0.0001,
},
"ministral-3b-latest": {
input: 0.00004,
output: 0.00004,
},
"mistral-embed": {
input: 0.0001,
output: 0,
},
"open-mistral-7b": {
input: 0.00025,
output: 0.00025,
},
"open-mixtral-8x7b": {
input: 0.0007,
output: 0.0007,
},
"open-mixtral-8x22b": {
input: 0.002,
output: 0.006,
},
};

export const XAI_PRICING: Record<string, CostTableEntry> = {
"grok-beta": {
input: 0.005,
Expand Down
9 changes: 7 additions & 2 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
CostTableEntry,
GROQ_PRICING,
LangTraceAttributes,
MISTRAL_PRICING,
OPENAI_PRICING,
PERPLEXITY_PRICING,
SpanStatusCode,
Expand Down Expand Up @@ -526,8 +527,8 @@ export function calculatePriceFromUsage(
vendor = "openai";
} else if (model.includes("claude")) {
vendor = "anthropic";
} else if (model.includes("mistral")) {
vendor = "mistral"; // Assuming there is a MISTRAL_PRICING object
} else if (model.includes("tral")) {
vendor = "mistral";
} else if (model.includes("grok")) {
vendor = "xai";
} else if (model.includes("gemini")) {
Expand Down Expand Up @@ -581,6 +582,8 @@ export function calculatePriceFromUsage(
costTable = GEMINI_PRICING[model];
} else if (model.includes("grok")) {
costTable = XAI_PRICING[model];
} else if (model.includes("tral")) {
costTable = MISTRAL_PRICING[model];
}
} else if (vendor === "openai") {
// check if model is present as key in OPENAI_PRICING
Expand Down Expand Up @@ -642,6 +645,8 @@ export function calculatePriceFromUsage(
costTable = GEMINI_PRICING[model];
} else if (vendor === "xai") {
costTable = XAI_PRICING[model];
} else if (vendor === "mistral") {
costTable = MISTRAL_PRICING[model];
}
if (costTable) {
const total =
Expand Down