Skip to content

@modelschemas/client RateCard type does not fit evaluateCard from @modelschemas/rate-card #494

Closed

Description

@tombeckenham

Problem

The RateCard from @modelschemas/client does not fit evaluateCard from @modelschemas/rate-card. Both are 0.2.1. The client's type is generated from OpenAPI (price: unknown, tables: { [key: string]: unknown }). The evaluator's type has price: RateCardPrice and tables: Record<string, Table>.

import { createModelschemasClient, getModel } from '@modelschemas/client'
import { evaluateCard } from '@modelschemas/rate-card/evaluator'

const client = createModelschemasClient({ baseUrl: 'https://modelschemas.com' })
const { data } = await getModel({ client, path: { provider: 'anthropic', modelId: 'claude-sonnet-5-5' } })
if (data?.pricing && 'price' in data.pricing) {
  evaluateCard(data.pricing, { usage: { input_tokens: 1000, output_tokens: 100 } })
}
error TS2345: Argument of type '.../@modelschemas/client/dist/generated/types.gen").RateCard'
is not assignable to parameter of type '.../@modelschemas/rate-card/dist/card").RateCard'.

So a caller must cast, or parse every card with rateCardSchema (which needs zod), to price a card that the client just returned. TanStack AI's docs page (TanStack/ai#1308, docs/advanced/model-prices.md) parses with rateCardSchema for this reason.

Ask

  • Make the two types one type. For example, the client re-exports RateCard from @modelschemas/rate-card, or the OpenAPI schema for pricing is generated from rateCardSchema.
  • Keep RateCard | CompactPricing | null on list rows, but let a caller narrow it to a card that evaluateCard accepts with no cast.

Acceptance

  • The snippet above type-checks with no as and no rateCardSchema call.
  • getModel on a detail row returns a pricing that evaluateCard accepts directly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions