Information about an available model
| 719 | |
| 720 | @dataclass |
| 721 | class ModelInfo: |
| 722 | """Information about an available model""" |
| 723 | |
| 724 | id: str # Model identifier (e.g., "claude-sonnet-4.5") |
| 725 | name: str # Display name |
| 726 | capabilities: ModelCapabilities # Model capabilities and limits |
| 727 | policy: ModelPolicy | None = None # Policy state |
| 728 | billing: ModelBilling | None = None # Billing information |
| 729 | # Supported reasoning effort levels (only present if model supports reasoning effort) |
| 730 | supported_reasoning_efforts: list[str] | None = None |
| 731 | # Default reasoning effort level (only present if model supports reasoning effort) |
| 732 | default_reasoning_effort: str | None = None |
| 733 | |
| 734 | @staticmethod |
| 735 | def from_dict(obj: Any) -> ModelInfo: |
| 736 | assert isinstance(obj, dict) |
| 737 | id = obj.get("id") |
| 738 | name = obj.get("name") |
| 739 | capabilities_dict = obj.get("capabilities") |
| 740 | if id is None or name is None or capabilities_dict is None: |
| 741 | raise ValueError( |
| 742 | f"Missing required fields in ModelInfo: id={id}, name={name}, " |
| 743 | f"capabilities={capabilities_dict}" |
| 744 | ) |
| 745 | capabilities = ModelCapabilities.from_dict(capabilities_dict) |
| 746 | policy_dict = obj.get("policy") |
| 747 | policy = ModelPolicy.from_dict(policy_dict) if policy_dict else None |
| 748 | billing_dict = obj.get("billing") |
| 749 | billing = ModelBilling.from_dict(billing_dict) if billing_dict else None |
| 750 | supported_reasoning_efforts = obj.get("supportedReasoningEfforts") |
| 751 | default_reasoning_effort = obj.get("defaultReasoningEffort") |
| 752 | return ModelInfo( |
| 753 | id=str(id), |
| 754 | name=str(name), |
| 755 | capabilities=capabilities, |
| 756 | policy=policy, |
| 757 | billing=billing, |
| 758 | supported_reasoning_efforts=supported_reasoning_efforts, |
| 759 | default_reasoning_effort=default_reasoning_effort, |
| 760 | ) |
| 761 | |
| 762 | def to_dict(self) -> dict: |
| 763 | result: dict = {} |
| 764 | result["id"] = self.id |
| 765 | result["name"] = self.name |
| 766 | result["capabilities"] = self.capabilities.to_dict() |
| 767 | if self.policy is not None: |
| 768 | result["policy"] = self.policy.to_dict() |
| 769 | if self.billing is not None: |
| 770 | result["billing"] = self.billing.to_dict() |
| 771 | if self.supported_reasoning_efforts is not None: |
| 772 | result["supportedReasoningEfforts"] = self.supported_reasoning_efforts |
| 773 | if self.default_reasoning_effort is not None: |
| 774 | result["defaultReasoningEffort"] = self.default_reasoning_effort |
| 775 | return result |
| 776 | |
| 777 | |
| 778 | # ============================================================================ |
no outgoing calls
searching dependent graphs…