Function costOfUsageUSD

  • A finished call's cost: the provider's own costUSD when it reported one, else its tokens at the table's rates (an embedding prices its prompt tokens alone); undefined when neither is known. A reported cost that is not a finite number, zero or more, is not used: a budget would record nothing for a cost of NaN.

    Parameters

    • providerId: string
    • modelId: string
    • usage: undefined | {
          promptTokens?: number;
          completionTokens?: number;
          costUSD?: number;
      }
    • isEmbedding: boolean = false

    Returns number | undefined