Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.4 KB
Raw Blame
import { describe, expect, it } from 'vitest';

import { allModels } from './xai';

describe('xai model cards', () => {
  /** @see https://docs.x.ai/developers/pricing */
  it('bills grok-4.5 prompts of 200K+ tokens at double rates', () => {
    const card = allModels.find((model) => model.id === 'grok-4.5');

    expect(card?.pricing?.units).toEqual([
      {
        name: 'textInput_cacheRead',
        strategy: 'tiered',
        tiers: [
          { rate: 0.3, upTo: 199_999 },
          { rate: 0.6, upTo: 'infinity' },
        ],
        unit: 'millionTokens',
      },
      {
        name: 'textInput',
        strategy: 'tiered',
        tiers: [
          { rate: 2, upTo: 199_999 },
          { rate: 4, upTo: 'infinity' },
        ],
        unit: 'millionTokens',
      },
      {
        name: 'textOutput',
        strategy: 'tiered',
        tiers: [
          { rate: 6, upTo: 199_999 },
          { rate: 12, upTo: 'infinity' },
        ],
        unit: 'millionTokens',
      },
    ]);
  });

  /**
   * Consumers size per-request output budgets from `maxOutput`, so every
   * official chat card must declare it.
   */
  it('declares maxOutput on every official chat card', () => {
    const missing = allModels
      .filter((model) => model.type === 'chat' && model.isOfficial && model.maxOutput == null)
      .map((model) => model.id);

    expect(missing).toEqual([]);
  });
});