langfuse-js icon indicating copy to clipboard operation
langfuse-js copied to clipboard

feat(api): update API spec from langfuse/langfuse ad16fa0

Open langfuse-bot opened this issue 3 months ago • 1 comments

[!IMPORTANT] Introduces tiered pricing model with new interfaces and updates Model and Client to support conditional pricing.

  • Behavior:
    • Introduces tiered pricing model in Model.ts, replacing flat pricing.
    • Adds pricingTiers to Model interface for conditional pricing.
    • Updates CreateModelRequest to support pricingTiers.
  • Models:
    • Adds PricingTier, PricingTierCondition, PricingTierInput, and PricingTierOperator interfaces.
  • Client:
    • Updates create method in Client.ts to handle pricingTiers in model creation.
  • Misc:
    • Exports new interfaces in index.ts.

This description was created by Ellipsis for ba947b6f4493804ff065688999912d3f78b68978. You can customize this summary. It will automatically update as commits are pushed.

Disclaimer: Experimental PR review

Greptile Overview

Greptile Summary

This PR introduces a tiered pricing system for LLM models to support usage-based pricing variations. The changes add new TypeScript types for pricing tiers with conditional matching based on usage patterns (e.g., different rates for high-volume usage or large context windows).

Key changes:

  • Added PricingTier, PricingTierCondition, PricingTierInput, and PricingTierOperator types
  • Extended Model interface with pricingTiers array and createdAt timestamp
  • Deprecated flat pricing fields (inputPrice, outputPrice, totalPrice) in favor of tiered pricing
  • Maintained backward compatibility by populating legacy price fields from the default tier
  • Updated CreateModelRequest to accept either flat prices or pricing tiers (mutually exclusive)

The implementation is well-documented with comprehensive JSDoc comments explaining tier matching logic, priority ordering, and usage examples. All files are auto-generated from the API specification, ensuring consistency with the backend.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk as it consists of auto-generated TypeScript type definitions
  • The changes are auto-generated from the API specification, adding new types without modifying existing logic. The implementation maintains backward compatibility through deprecated fields and includes comprehensive documentation. No runtime code changes or complex logic alterations are present.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/core/src/api/api/resources/commons/types/Model.ts 5/5 Added createdAt field and pricingTiers array with comprehensive documentation explaining tiered pricing system
packages/core/src/api/api/resources/commons/types/PricingTier.ts 5/5 New type defining pricing tiers with conditional pricing logic and priority-based evaluation
packages/core/src/api/api/resources/commons/types/PricingTierCondition.ts 5/5 New type for tier matching conditions using regex patterns, operators, and threshold values
packages/core/src/api/api/resources/models/types/CreateModelRequest.ts 5/5 Deprecated flat pricing fields in favor of pricingTiers array with detailed documentation

Sequence Diagram

sequenceDiagram
    participant Client
    participant API
    participant Model
    participant PricingTier
    
    Client->>API: CreateModelRequest
    Note over Client,API: With pricingTiers[] or legacy flat prices
    
    alt Using pricingTiers
        API->>Model: Create with pricingTiers array
        Model->>PricingTier: Validate default tier exists
        Note over Model,PricingTier: Must have exactly one with<br/>isDefault=true, priority=0, conditions=[]
        Model->>PricingTier: Store conditional tiers
        Note over Model,PricingTier: Ordered by priority for matching
        Model->>Model: Populate legacy prices field<br/>from default tier
    else Using legacy flat prices
        API->>Model: Create with inputPrice/outputPrice/totalPrice
        Model->>PricingTier: Auto-create default tier named "Standard"
        Model->>Model: Store in pricingTiers array
    end
    
    Model-->>API: Return Model with both formats
    API-->>Client: Model response
    Note over Client,API: Model has both pricingTiers[]<br/>and legacy prices for compatibility

langfuse-bot avatar Nov 26 '25 15:11 langfuse-bot

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
langfuse-js Ready Ready Preview Nov 26, 2025 3:07pm

vercel[bot] avatar Nov 26 '25 15:11 vercel[bot]