# frozen_string_literal: true module Dispatch module Adapter class Claude < Base module ModelCatalog module_function # Build a ModelInfo for a given model id using the bundled pricing table. # # @param id [String] a model id present in PricingTable # @return [Dispatch::Adapter::ModelInfo] def build(id) ModelInfo.new( id: id, name: id, max_context_tokens: PricingTable.context_window(id) || 200_000, supports_vision: true, supports_tool_use: true, supports_streaming: true, premium_request_multiplier: nil, pricing: PricingTable.lookup(id) ) end # Build a ModelInfo from a runtime API entry (from GET /v1/models). # # If the model is in the bundled pricing table, pricing data and # context-window size are taken from there; the runtime display_name # overrides the name. For unknown models, pricing is nil and a # default context window of 200_000 is used. # # @param api_entry [Hash] one element of the "data" array from GET /v1/models # @return [Dispatch::Adapter::ModelInfo] def build_from_api(api_entry) id = api_entry["id"].to_s display_name = api_entry["display_name"].to_s display_name = id if display_name.empty? pricing = PricingTable.lookup(id) context_win = PricingTable.context_window(id) || 200_000 name = if pricing.nil? "(unrated) #{display_name}" else display_name end ModelInfo.new( id: id, name: name, max_context_tokens: context_win, supports_vision: true, supports_tool_use: true, supports_streaming: true, premium_request_multiplier: nil, pricing: pricing ) end end end end end