Skip to content

Commit

Permalink
added x cost support (#3151)
Browse files Browse the repository at this point in the history
  • Loading branch information
chitalian authored Jan 21, 2025
1 parent 7ba8e3f commit 1f094fd
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 0 deletions.
49 changes: 49 additions & 0 deletions bifrost/packages/cost/providers/x/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
*
* DO NOT EDIT THIS FILE UNLESS IT IS IN /costs
*/

import { ModelRow } from "../../interfaces/Cost";

export const costs: ModelRow[] = [
{
model: {
operator: "equals",
value: "grok-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-vision-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-2-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
{
model: {
operator: "equals",
value: "grok-2-vision-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
];
9 changes: 9 additions & 0 deletions costs/src/providers/mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { openAIProvider } from "./openai";
import { anthropicProvider } from "./anthropic";
import { costs as awsBedrockCosts } from "./awsBedrock";
import { costs as deepseekCosts } from "./deepseek";
import { costs as xCosts } from "./x";

const openAiPattern = /^https:\/\/api\.openai\.com/;
const anthropicPattern = /^https:\/\/api\.anthropic\.com/;
Expand Down Expand Up @@ -52,6 +53,8 @@ const firecrawl = /^https:\/\/api\.firecrawl\.dev/;
const awsBedrock = /^https:\/\/bedrock-runtime\.[a-z0-9-]+\.amazonaws\.com\/.*/;
// https://api.deepseek.com
const deepseek = /^https:\/\/api\.deepseek\.com/;
// https://api.x.ai
const x = /^https:\/\/api\.x\.ai/;

export const providersNames = [
"OPENAI",
Expand All @@ -78,6 +81,7 @@ export const providersNames = [
"FIRECRAWL",
"AWS",
"DEEPSEEK",
"X",
] as const;

export type ProviderName = (typeof providersNames)[number];
Expand Down Expand Up @@ -127,6 +131,11 @@ export const providers: {
pattern: cloudflareAiGatewayPattern,
provider: "CLOUDFLARE",
},
{
pattern: x,
provider: "X",
costs: xCosts,
},
{
pattern: twoYFV,
provider: "2YFV",
Expand Down
49 changes: 49 additions & 0 deletions valhalla/jawn/src/packages/cost/providers/x/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
*
* DO NOT EDIT THIS FILE UNLESS IT IS IN /costs
*/

import { ModelRow } from "../../interfaces/Cost";

export const costs: ModelRow[] = [
{
model: {
operator: "equals",
value: "grok-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-vision-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-2-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
{
model: {
operator: "equals",
value: "grok-2-vision-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
];
49 changes: 49 additions & 0 deletions web/packages/cost/providers/x/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
*
* DO NOT EDIT THIS FILE UNLESS IT IS IN /costs
*/

import { ModelRow } from "../../interfaces/Cost";

export const costs: ModelRow[] = [
{
model: {
operator: "equals",
value: "grok-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-vision-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-2-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
{
model: {
operator: "equals",
value: "grok-2-vision-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
];
49 changes: 49 additions & 0 deletions worker/src/packages/cost/providers/x/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
*
* DO NOT EDIT THIS FILE UNLESS IT IS IN /costs
*/

import { ModelRow } from "../../interfaces/Cost";

export const costs: ModelRow[] = [
{
model: {
operator: "equals",
value: "grok-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-vision-beta",
},
cost: {
prompt_token: 0.000005,
completion_token: 0.000015,
},
},
{
model: {
operator: "equals",
value: "grok-2-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
{
model: {
operator: "equals",
value: "grok-2-vision-1212",
},
cost: {
prompt_token: 0.000002,
completion_token: 0.00001,
},
},
];

0 comments on commit 1f094fd

Please sign in to comment.