anthropic 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +1 -1
  4. data/lib/anthropic/client.rb +8 -0
  5. data/lib/anthropic/helpers/bedrock/client.rb +5 -0
  6. data/lib/anthropic/helpers/bedrock/mantle_client.rb +5 -0
  7. data/lib/anthropic/helpers/stainless_helper_header.rb +1 -0
  8. data/lib/anthropic/helpers/threads/beta_message_thread.rb +635 -0
  9. data/lib/anthropic/helpers/tools/runner.rb +79 -11
  10. data/lib/anthropic/helpers/vertex/client.rb +5 -0
  11. data/lib/anthropic/internal/report_page_cursor.rb +2 -2
  12. data/lib/anthropic/internal/tracing.rb +2 -0
  13. data/lib/anthropic/models/anthropic_beta.rb +6 -0
  14. data/lib/anthropic/models/beta/beta_message_thread_param.rb +61 -0
  15. data/lib/anthropic/models/beta/beta_thread_continue_params.rb +29 -0
  16. data/lib/anthropic/models/beta/beta_thread_create_params.rb +21 -0
  17. data/lib/anthropic/models/beta/message_create_params.rb +13 -1
  18. data/lib/anthropic/models/beta/messages/batch_create_params.rb +13 -1
  19. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_cost_group.rb +271 -0
  20. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_cost_group_by.rb +40 -0
  21. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_cost_item.rb +57 -0
  22. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_cost_metrics.rb +57 -0
  23. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_cost_order_by.rb +22 -0
  24. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_usage_group.rb +247 -0
  25. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_usage_group_by.rb +38 -0
  26. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_usage_item.rb +57 -0
  27. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_usage_metrics.rb +79 -0
  28. data/lib/anthropic/models/beta/organization/analytics/beta_analytics_usage_order_by.rb +24 -0
  29. data/lib/anthropic/models/beta/organization/analytics/cost_list_params.rb +360 -0
  30. data/lib/anthropic/models/beta/organization/analytics/usage_list_params.rb +353 -0
  31. data/lib/anthropic/models/beta/organization/beta_analytics_actor.rb +81 -0
  32. data/lib/anthropic/models/beta/organization/beta_analytics_actor_type.rb +22 -0
  33. data/lib/anthropic/models/beta/organization/beta_analytics_api_actor.rb +27 -0
  34. data/lib/anthropic/models/beta/organization/beta_analytics_federated_actor.rb +42 -0
  35. data/lib/anthropic/models/beta/organization/beta_analytics_federated_actor_aws_provider.rb +35 -0
  36. data/lib/anthropic/models/beta/organization/beta_analytics_federated_actor_azure_provider.rb +27 -0
  37. data/lib/anthropic/models/beta/organization/beta_analytics_federated_actor_gcp_provider.rb +27 -0
  38. data/lib/anthropic/models/beta/organization/beta_analytics_federated_actor_oidc_provider.rb +27 -0
  39. data/lib/anthropic/models/beta/organization/beta_analytics_federated_actor_provider.rb +72 -0
  40. data/lib/anthropic/models/beta/organization/beta_analytics_grouped_cost_type.rb +21 -0
  41. data/lib/anthropic/models/beta/organization/beta_analytics_report_user_actor.rb +65 -0
  42. data/lib/anthropic/models/beta/organization/beta_analytics_service_account_actor.rb +27 -0
  43. data/lib/anthropic/models/beta/organization/beta_analytics_service_tier.rb +23 -0
  44. data/lib/anthropic/models/beta/organization/beta_analytics_speed.rb +19 -0
  45. data/lib/anthropic/models/beta/organization/beta_analytics_time_bucket_width.rb +20 -0
  46. data/lib/anthropic/models/beta/organization/beta_analytics_usage_cost_inference_geo.rb +19 -0
  47. data/lib/anthropic/models/beta/organization/beta_analytics_usage_cost_product_filter.rb +34 -0
  48. data/lib/anthropic/models/beta/organization/beta_analytics_usage_cost_sort_order.rb +19 -0
  49. data/lib/anthropic/models/beta/organization/beta_organization_rate_limit.rb +2 -1
  50. data/lib/anthropic/models/beta/organization/beta_plugin.rb +12 -6
  51. data/lib/anthropic/models/beta/organization/beta_plugin_content_scan.rb +11 -5
  52. data/lib/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit.rb +2 -1
  53. data/lib/anthropic/models/organization/organization_rate_limit.rb +2 -1
  54. data/lib/anthropic/models/organization/workspaces/workspace_rate_limit.rb +2 -1
  55. data/lib/anthropic/resources/beta/messages.rb +78 -4
  56. data/lib/anthropic/resources/beta/organization/analytics/cost.rb +175 -0
  57. data/lib/anthropic/resources/beta/organization/analytics/cost_report.rb +13 -6
  58. data/lib/anthropic/resources/beta/organization/analytics/usage.rb +176 -0
  59. data/lib/anthropic/resources/beta/organization/analytics/usage_report.rb +9 -2
  60. data/lib/anthropic/resources/beta/organization/analytics/user_cost_report.rb +12 -5
  61. data/lib/anthropic/resources/beta/organization/analytics/user_usage_report.rb +15 -8
  62. data/lib/anthropic/resources/beta/organization/analytics.rb +8 -0
  63. data/lib/anthropic/resources/beta/organization/plugin_marketplaces.rb +6 -6
  64. data/lib/anthropic/resources/beta/organization/plugins.rb +12 -9
  65. data/lib/anthropic/version.rb +1 -1
  66. data/lib/anthropic.rb +36 -0
  67. data/rbi/anthropic/client.rbi +5 -0
  68. data/rbi/anthropic/helpers/bedrock/client.rbi +5 -0
  69. data/rbi/anthropic/helpers/bedrock/mantle_client.rbi +5 -0
  70. data/rbi/anthropic/helpers/threads/beta_message_thread.rbi +100 -0
  71. data/rbi/anthropic/helpers/vertex/client.rbi +5 -0
  72. data/rbi/anthropic/internal/tracing.rbi +4 -0
  73. data/rbi/anthropic/models/anthropic_beta.rbi +10 -0
  74. data/rbi/anthropic/models/beta/beta_message_thread_param.rbi +80 -0
  75. data/rbi/anthropic/models/beta/beta_thread_continue_params.rbi +43 -0
  76. data/rbi/anthropic/models/beta/beta_thread_create_params.rbi +31 -0
  77. data/rbi/anthropic/models/beta/message_create_params.rbi +37 -0
  78. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +37 -0
  79. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_cost_group.rbi +439 -0
  80. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_cost_group_by.rbi +140 -0
  81. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_cost_item.rbi +110 -0
  82. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_cost_metrics.rbi +79 -0
  83. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_cost_order_by.rbi +50 -0
  84. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_usage_group.rbi +399 -0
  85. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_usage_group_by.rbi +130 -0
  86. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_usage_item.rbi +110 -0
  87. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_usage_metrics.rbi +120 -0
  88. data/rbi/anthropic/models/beta/organization/analytics/beta_analytics_usage_order_by.rbi +60 -0
  89. data/rbi/anthropic/models/beta/organization/analytics/cost_list_params.rbi +624 -0
  90. data/rbi/anthropic/models/beta/organization/analytics/usage_list_params.rbi +612 -0
  91. data/rbi/anthropic/models/beta/organization/beta_analytics_actor.rbi +134 -0
  92. data/rbi/anthropic/models/beta/organization/beta_analytics_actor_type.rbi +54 -0
  93. data/rbi/anthropic/models/beta/organization/beta_analytics_api_actor.rbi +40 -0
  94. data/rbi/anthropic/models/beta/organization/beta_analytics_federated_actor.rbi +75 -0
  95. data/rbi/anthropic/models/beta/organization/beta_analytics_federated_actor_aws_provider.rbi +54 -0
  96. data/rbi/anthropic/models/beta/organization/beta_analytics_federated_actor_azure_provider.rbi +42 -0
  97. data/rbi/anthropic/models/beta/organization/beta_analytics_federated_actor_gcp_provider.rbi +42 -0
  98. data/rbi/anthropic/models/beta/organization/beta_analytics_federated_actor_oidc_provider.rbi +42 -0
  99. data/rbi/anthropic/models/beta/organization/beta_analytics_federated_actor_provider.rbi +107 -0
  100. data/rbi/anthropic/models/beta/organization/beta_analytics_grouped_cost_type.rbi +53 -0
  101. data/rbi/anthropic/models/beta/organization/beta_analytics_report_user_actor.rbi +94 -0
  102. data/rbi/anthropic/models/beta/organization/beta_analytics_service_account_actor.rbi +42 -0
  103. data/rbi/anthropic/models/beta/organization/beta_analytics_service_tier.rbi +63 -0
  104. data/rbi/anthropic/models/beta/organization/beta_analytics_speed.rbi +40 -0
  105. data/rbi/anthropic/models/beta/organization/beta_analytics_time_bucket_width.rbi +48 -0
  106. data/rbi/anthropic/models/beta/organization/beta_analytics_usage_cost_inference_geo.rbi +43 -0
  107. data/rbi/anthropic/models/beta/organization/beta_analytics_usage_cost_product_filter.rbi +98 -0
  108. data/rbi/anthropic/models/beta/organization/beta_analytics_usage_cost_sort_order.rbi +43 -0
  109. data/rbi/anthropic/models/beta/organization/beta_organization_rate_limit.rbi +4 -2
  110. data/rbi/anthropic/models/beta/organization/beta_plugin.rbi +20 -8
  111. data/rbi/anthropic/models/beta/organization/beta_plugin_content_scan.rbi +15 -6
  112. data/rbi/anthropic/models/beta/organization/workspaces/beta_workspace_rate_limit.rbi +4 -2
  113. data/rbi/anthropic/models/organization/organization_rate_limit.rbi +4 -2
  114. data/rbi/anthropic/models/organization/workspaces/workspace_rate_limit.rbi +4 -2
  115. data/rbi/anthropic/resources/beta/messages.rbi +191 -0
  116. data/rbi/anthropic/resources/beta/organization/analytics/cost.rbi +245 -0
  117. data/rbi/anthropic/resources/beta/organization/analytics/cost_report.rbi +12 -5
  118. data/rbi/anthropic/resources/beta/organization/analytics/usage.rbi +240 -0
  119. data/rbi/anthropic/resources/beta/organization/analytics/usage_report.rbi +9 -2
  120. data/rbi/anthropic/resources/beta/organization/analytics/user_cost_report.rbi +12 -5
  121. data/rbi/anthropic/resources/beta/organization/analytics/user_usage_report.rbi +14 -7
  122. data/rbi/anthropic/resources/beta/organization/analytics.rbi +10 -0
  123. data/rbi/anthropic/resources/beta/organization/plugin_marketplaces.rbi +6 -6
  124. data/rbi/anthropic/resources/beta/organization/plugins.rbi +12 -9
  125. data/rbi/lib/anthropic/helpers/stainless_helper_header.rbi +2 -0
  126. data/sig/anthropic/client.rbs +2 -0
  127. data/sig/anthropic/helpers/bedrock/client.rbs +2 -0
  128. data/sig/anthropic/helpers/threads/beta_message_thread.rbs +40 -0
  129. data/sig/anthropic/helpers/tools/runner.rbs +40 -0
  130. data/sig/anthropic/helpers/vertex/client.rbs +2 -0
  131. data/sig/anthropic/internal/tracing.rbs +2 -0
  132. data/sig/anthropic/models/anthropic_beta.rbs +4 -0
  133. data/sig/anthropic/models/beta/beta_message_thread_param.rbs +40 -0
  134. data/sig/anthropic/models/beta/beta_thread_continue_params.rbs +20 -0
  135. data/sig/anthropic/models/beta/beta_thread_create_params.rbs +17 -0
  136. data/sig/anthropic/models/beta/message_create_params.rbs +5 -0
  137. data/sig/anthropic/models/beta/messages/batch_create_params.rbs +5 -0
  138. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_cost_group.rbs +126 -0
  139. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_cost_group_by.rbs +60 -0
  140. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_cost_item.rbs +41 -0
  141. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_cost_metrics.rbs +41 -0
  142. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_cost_order_by.rbs +21 -0
  143. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_usage_group.rbs +116 -0
  144. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_usage_group_by.rbs +56 -0
  145. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_usage_item.rbs +41 -0
  146. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_usage_metrics.rbs +56 -0
  147. data/sig/anthropic/models/beta/organization/analytics/beta_analytics_usage_order_by.rbs +28 -0
  148. data/sig/anthropic/models/beta/organization/analytics/cost_list_params.rbs +188 -0
  149. data/sig/anthropic/models/beta/organization/analytics/usage_list_params.rbs +188 -0
  150. data/sig/anthropic/models/beta/organization/beta_analytics_actor.rbs +67 -0
  151. data/sig/anthropic/models/beta/organization/beta_analytics_actor_type.rbs +21 -0
  152. data/sig/anthropic/models/beta/organization/beta_analytics_api_actor.rbs +19 -0
  153. data/sig/anthropic/models/beta/organization/beta_analytics_federated_actor.rbs +34 -0
  154. data/sig/anthropic/models/beta/organization/beta_analytics_federated_actor_aws_provider.rbs +30 -0
  155. data/sig/anthropic/models/beta/organization/beta_analytics_federated_actor_azure_provider.rbs +20 -0
  156. data/sig/anthropic/models/beta/organization/beta_analytics_federated_actor_gcp_provider.rbs +20 -0
  157. data/sig/anthropic/models/beta/organization/beta_analytics_federated_actor_oidc_provider.rbs +20 -0
  158. data/sig/anthropic/models/beta/organization/beta_analytics_federated_actor_provider.rbs +60 -0
  159. data/sig/anthropic/models/beta/organization/beta_analytics_grouped_cost_type.rbs +21 -0
  160. data/sig/anthropic/models/beta/organization/beta_analytics_report_user_actor.rbs +44 -0
  161. data/sig/anthropic/models/beta/organization/beta_analytics_service_account_actor.rbs +26 -0
  162. data/sig/anthropic/models/beta/organization/beta_analytics_service_tier.rbs +28 -0
  163. data/sig/anthropic/models/beta/organization/beta_analytics_speed.rbs +18 -0
  164. data/sig/anthropic/models/beta/organization/beta_analytics_time_bucket_width.rbs +19 -0
  165. data/sig/anthropic/models/beta/organization/beta_analytics_usage_cost_inference_geo.rbs +18 -0
  166. data/sig/anthropic/models/beta/organization/beta_analytics_usage_cost_product_filter.rbs +40 -0
  167. data/sig/anthropic/models/beta/organization/beta_analytics_usage_cost_sort_order.rbs +18 -0
  168. data/sig/anthropic/resources/beta/messages.rbs +33 -0
  169. data/sig/anthropic/resources/beta/organization/analytics/cost.rbs +46 -0
  170. data/sig/anthropic/resources/beta/organization/analytics/usage.rbs +46 -0
  171. data/sig/anthropic/resources/beta/organization/analytics.rbs +4 -0
  172. metadata +111 -2
@@ -0,0 +1,271 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ module Organization
7
+ module Analytics
8
+ class BetaAnalyticsCostGroup < Anthropic::Internal::Type::BaseModel
9
+ # @!attribute actor
10
+ # The identity the usage is attributed to: the user if one is attributed, else the
11
+ # service account, else the federated (cloud-platform) identity, else the API key.
12
+ # Populated only when `actor` is in `group_by[]`; null for usage with no
13
+ # attributable identity, and for users' and federated identities' usage when the
14
+ # reader is a member who can see only some workspaces. Distinct identities the
15
+ # server cannot render also read null, each as its own row.
16
+ #
17
+ # @return [Anthropic::Models::Beta::Organization::BetaAnalyticsReportUserActor, Anthropic::Models::Beta::Organization::BetaAnalyticsServiceAccountActor, Anthropic::Models::Beta::Organization::BetaAnalyticsFederatedActor, Anthropic::Models::Beta::Organization::BetaAnalyticsAPIActor, nil]
18
+ required :actor, union: -> { Anthropic::Beta::Organization::BetaAnalyticsActor }, nil?: true
19
+
20
+ # @!attribute actor_type
21
+ # Kind of identity the usage is attributed to; matches `actor.type` when `actor`
22
+ # is set. Populated only when `actor_type` is in `group_by[]`.
23
+ #
24
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsActorType, nil]
25
+ required :actor_type,
26
+ enum: -> {
27
+ Anthropic::Beta::Organization::BetaAnalyticsActorType
28
+ },
29
+ nil?: true
30
+
31
+ # @!attribute agent_id
32
+ # Claude Managed Agents agent whose session incurred the usage. Populated only
33
+ # when `agent_id` is in `group_by[]`; null for usage outside a managed session.
34
+ #
35
+ # @return [String, nil]
36
+ required :agent_id, String, nil?: true
37
+
38
+ # @!attribute api_key_id
39
+ # API key that authenticated the requests, as a tagged API key ID, whichever
40
+ # identity `actor` resolves to. Populated only when `api_key_id` is in
41
+ # `group_by[]`; null for usage not authenticated by an API key.
42
+ #
43
+ # @return [String, nil]
44
+ required :api_key_id, String, nil?: true
45
+
46
+ # @!attribute claude_tag_category
47
+ # Claude Tag (Claude in Slack) spend category: `engaged` (a person addressed
48
+ # Claude in a channel or thread), `proactive` (Claude responded without being
49
+ # addressed), `scheduled` (a scheduled routine ran), `monitoring` (Claude watching
50
+ # a channel it was asked to monitor), or `dm` (direct messages with Claude).
51
+ # Populated only when `claude_tag_category` is in `group_by[]`; null for usage
52
+ # that is not Claude Tag. Direct-message usage is billed to the individual user
53
+ # and is reported under that user's product, not under `claude_tag`. New
54
+ # categories may be added over time.
55
+ #
56
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsClaudeTagCategory, nil]
57
+ required :claude_tag_category,
58
+ enum: -> { Anthropic::Beta::Organization::BetaAnalyticsClaudeTagCategory },
59
+ nil?: true
60
+
61
+ # @!attribute claude_tag_user_id
62
+ # Slack user ID (for example `U0123ABCDEF`) of the member the Claude Tag (Claude
63
+ # in Slack) usage is attributed to, not a claude.ai user ID. Populated only when
64
+ # `claude_tag_user_id` is in `group_by[]`; null for usage that is not Claude Tag
65
+ # and for Claude Tag usage that is not attributed to a single user (for example
66
+ # `monitoring`, and `proactive` usage Claude initiated), so per-user rows can sum
67
+ # to less than the Claude Tag total. Cannot be combined with
68
+ # `group_by[]=rbac_group_id` or the `rbac_group_ids[]` filter.
69
+ #
70
+ # @return [String, nil]
71
+ required :claude_tag_user_id, String, nil?: true
72
+
73
+ # @!attribute context_window
74
+ # Context-window pricing tier of the usage or cost. Null unless `context_window`
75
+ # is in `group_by[]`; it can also be null on grouped rows with no context-window
76
+ # tier, such as code execution.
77
+ #
78
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsContextWindow, nil]
79
+ required :context_window,
80
+ enum: -> { Anthropic::Beta::Organization::BetaAnalyticsContextWindow },
81
+ nil?: true
82
+
83
+ # @!attribute cost_type
84
+ # Cost component breakdown; null when returning the combined total.
85
+ #
86
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsGroupedCostType, nil]
87
+ required :cost_type,
88
+ enum: -> {
89
+ Anthropic::Beta::Organization::BetaAnalyticsGroupedCostType
90
+ },
91
+ nil?: true
92
+
93
+ # @!attribute deployment_id
94
+ # Deployment that started the Claude Managed Agents session. Populated only when
95
+ # `deployment_id` is in `group_by[]`; null for usage outside a managed session and
96
+ # for sessions no deployment started.
97
+ #
98
+ # @return [String, nil]
99
+ required :deployment_id, String, nil?: true
100
+
101
+ # @!attribute environment_id
102
+ # Claude Managed Agents environment the session ran in. Populated only when
103
+ # `environment_id` is in `group_by[]`; null for usage outside a managed session.
104
+ #
105
+ # @return [String, nil]
106
+ required :environment_id, String, nil?: true
107
+
108
+ # @!attribute inference_geo
109
+ # Inference region of the usage or cost. Null unless `inference_geo` is in
110
+ # `group_by[]`; it can also be null on grouped rows where the region is not set
111
+ # (the rows that `inference_geos[]=not_available` matches).
112
+ #
113
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsUsageCostInferenceGeo, nil]
114
+ required :inference_geo,
115
+ enum: -> { Anthropic::Beta::Organization::BetaAnalyticsUsageCostInferenceGeo },
116
+ nil?: true
117
+
118
+ # @!attribute model
119
+ # Model that produced the usage or cost, as a model name in the form the
120
+ # `models[]` filter accepts (for example, `claude-opus-5-5`). Null unless `model`
121
+ # is in `group_by[]`; it can also be null on grouped rows whose usage or cost is
122
+ # not attributed to a specific model, such as code execution.
123
+ #
124
+ # @return [String, nil]
125
+ required :model, String, nil?: true
126
+
127
+ # @!attribute product
128
+ # Product surface that produced the usage or cost. Null unless product is in
129
+ # `group_by[]`; it can also be null on grouped rows whose usage cannot be
130
+ # attributed to a known surface. Values include `chat`, `claude_code`, `cowork`,
131
+ # `office_agent`, `claude_in_chrome`, `claude_design`, `claude_tag`, and
132
+ # `chat_cowork_unified`. `claude_tag` is Claude Tag, the Claude product in Slack.
133
+ # `chat_cowork_unified` is Chat and Cowork unified, Cowork's features inside
134
+ # claude.ai chat: chat and Cowork usage by a member who has it turned on is
135
+ # reported under this value instead of `chat` or `cowork`. It is accepted as a
136
+ # filter only on deployments that offer Chat and Cowork unified. Some unattributed
137
+ # usage is reported as "other".
138
+ #
139
+ # @return [String, nil]
140
+ required :product, String, nil?: true
141
+
142
+ # @!attribute rbac_group_id
143
+ # RBAC group (team) the usage is attributed to, in the public tagged
144
+ # `rbac_group_...` spelling — the same spelling the activity resources use for
145
+ # this key, so the same team has one id across resources and it round-trips as an
146
+ # `rbac_group_ids[]` filter value. Populated only when `rbac_group_id` is in
147
+ # `group_by[]`. Any-membership semantics: a user in several groups contributes
148
+ # their full usage to each of those groups' rows, so the named-group rows overlap
149
+ # and their sum can exceed the org total. A null value is the single unassigned
150
+ # row: users in no group on that (UTC) day. For the true org total, run the same
151
+ # query without `group_by[]`.
152
+ #
153
+ # @return [String, nil]
154
+ required :rbac_group_id, String, nil?: true
155
+
156
+ # @!attribute service_tier
157
+ # Service tier the usage was served at. Populated only when `service_tier` is in
158
+ # `group_by[]`; null for usage with no service tier (for example, code execution)
159
+ # and for Claude Enterprise usage.
160
+ #
161
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsServiceTier, nil]
162
+ required :service_tier,
163
+ enum: -> {
164
+ Anthropic::Beta::Organization::BetaAnalyticsServiceTier
165
+ },
166
+ nil?: true
167
+
168
+ # @!attribute session_id
169
+ # Claude Managed Agents session that incurred the usage. Populated only when
170
+ # `session_id` is in `group_by[]`; null for usage outside a managed session.
171
+ #
172
+ # @return [String, nil]
173
+ required :session_id, String, nil?: true
174
+
175
+ # @!attribute slack_channel_id
176
+ # Slack channel the usage originated from. Populated only when `slack_channel_id`
177
+ # is in `group_by[]`; null for usage outside Slack (and for rows recorded before
178
+ # channel attribution was enabled).
179
+ #
180
+ # @return [String, nil]
181
+ required :slack_channel_id, String, nil?: true
182
+
183
+ # @!attribute speed
184
+ # Inference speed mode of the usage or cost: `fast` or `standard`. Null unless
185
+ # `speed` is in `group_by[]`.
186
+ #
187
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsSpeed, nil]
188
+ required :speed, enum: -> { Anthropic::Beta::Organization::BetaAnalyticsSpeed }, nil?: true
189
+
190
+ # @!attribute token_type
191
+ # Token type when `cost_type` is `tokens`; null otherwise.
192
+ #
193
+ # @return [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsTokenType, nil]
194
+ required :token_type,
195
+ enum: -> {
196
+ Anthropic::Beta::Organization::BetaAnalyticsTokenType
197
+ },
198
+ nil?: true
199
+
200
+ # @!attribute user_profile_id
201
+ # User profile the usage was attributed to, as a tagged `uprof_` ID. Populated
202
+ # only when `user_profile_id` is in `group_by[]`; null for usage that named no
203
+ # profile and for Claude Enterprise usage.
204
+ #
205
+ # @return [String, nil]
206
+ required :user_profile_id, String, nil?: true
207
+
208
+ # @!attribute workspace_id
209
+ # Workspace the usage occurred in, as a tagged workspace ID, including the
210
+ # organization's default workspace. Populated only when `workspace_id` is in
211
+ # `group_by[]`; null for Claude Enterprise usage.
212
+ #
213
+ # @return [String, nil]
214
+ required :workspace_id, String, nil?: true
215
+
216
+ # @!method initialize(actor:, actor_type:, agent_id:, api_key_id:, claude_tag_category:, claude_tag_user_id:, context_window:, cost_type:, deployment_id:, environment_id:, inference_geo:, model:, product:, rbac_group_id:, service_tier:, session_id:, slack_channel_id:, speed:, token_type:, user_profile_id:, workspace_id:)
217
+ # The dimension values one cost row is broken out by, including `cost_type` and
218
+ # `token_type`.
219
+ #
220
+ # Some parameter documentations has been truncated, see
221
+ # {Anthropic::Models::Beta::Organization::Analytics::BetaAnalyticsCostGroup} for
222
+ # more details.
223
+ #
224
+ # @param actor [Anthropic::Models::Beta::Organization::BetaAnalyticsReportUserActor, Anthropic::Models::Beta::Organization::BetaAnalyticsServiceAccountActor, Anthropic::Models::Beta::Organization::BetaAnalyticsFederatedActor, Anthropic::Models::Beta::Organization::BetaAnalyticsAPIActor, nil] The identity the usage is attributed to: the user if one is attributed, else the
225
+ #
226
+ # @param actor_type [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsActorType, nil] Kind of identity the usage is attributed to; matches `actor.type` when `actor` i
227
+ #
228
+ # @param agent_id [String, nil] Claude Managed Agents agent whose session incurred the usage. Populated only whe
229
+ #
230
+ # @param api_key_id [String, nil] API key that authenticated the requests, as a tagged API key ID, whichever ident
231
+ #
232
+ # @param claude_tag_category [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsClaudeTagCategory, nil] Claude Tag (Claude in Slack) spend category: `engaged` (a person addressed Claud
233
+ #
234
+ # @param claude_tag_user_id [String, nil] Slack user ID (for example `U0123ABCDEF`) of the member the Claude Tag (Claude i
235
+ #
236
+ # @param context_window [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsContextWindow, nil] Context-window pricing tier of the usage or cost. Null unless `context_window` i
237
+ #
238
+ # @param cost_type [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsGroupedCostType, nil] Cost component breakdown; null when returning the combined total.
239
+ #
240
+ # @param deployment_id [String, nil] Deployment that started the Claude Managed Agents session. Populated only when `
241
+ #
242
+ # @param environment_id [String, nil] Claude Managed Agents environment the session ran in. Populated only when `envir
243
+ #
244
+ # @param inference_geo [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsUsageCostInferenceGeo, nil] Inference region of the usage or cost. Null unless `inference_geo` is in
245
+ # `group\_
246
+ #
247
+ # @param model [String, nil] Model that produced the usage or cost, as a model name in the form the `models[]
248
+ #
249
+ # @param product [String, nil] Product surface that produced the usage or cost. Null unless product is in `grou
250
+ #
251
+ # @param rbac_group_id [String, nil] RBAC group (team) the usage is attributed to, in the public tagged `rbac*group*.
252
+ #
253
+ # @param service_tier [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsServiceTier, nil] Service tier the usage was served at. Populated only when `service_tier` is in `
254
+ #
255
+ # @param session_id [String, nil] Claude Managed Agents session that incurred the usage. Populated only when `sess
256
+ #
257
+ # @param slack_channel_id [String, nil] Slack channel the usage originated from. Populated only when `slack_channel_id`
258
+ #
259
+ # @param speed [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsSpeed, nil] Inference speed mode of the usage or cost: `fast` or `standard`. Null unless `sp
260
+ #
261
+ # @param token_type [Symbol, Anthropic::Models::Beta::Organization::BetaAnalyticsTokenType, nil] Token type when `cost_type` is `tokens`; null otherwise.
262
+ #
263
+ # @param user_profile_id [String, nil] User profile the usage was attributed to, as a tagged `uprof_` ID. Populated onl
264
+ #
265
+ # @param workspace_id [String, nil] Workspace the usage occurred in, as a tagged workspace ID, including the organiz
266
+ end
267
+ end
268
+ end
269
+ end
270
+ end
271
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ module Organization
7
+ module Analytics
8
+ module BetaAnalyticsCostGroupBy
9
+ extend Anthropic::Internal::Type::Enum
10
+
11
+ ACTOR = :actor
12
+ ACTOR_TYPE = :actor_type
13
+ AGENT_ID = :agent_id
14
+ API_KEY_ID = :api_key_id
15
+ CLAUDE_TAG_CATEGORY = :claude_tag_category
16
+ CLAUDE_TAG_USER_ID = :claude_tag_user_id
17
+ CONTEXT_WINDOW = :context_window
18
+ COST_TYPE = :cost_type
19
+ DEPLOYMENT_ID = :deployment_id
20
+ ENVIRONMENT_ID = :environment_id
21
+ INFERENCE_GEO = :inference_geo
22
+ MODEL = :model
23
+ PRODUCT = :product
24
+ RBAC_GROUP_ID = :rbac_group_id
25
+ SERVICE_TIER = :service_tier
26
+ SESSION_ID = :session_id
27
+ SLACK_CHANNEL_ID = :slack_channel_id
28
+ SPEED = :speed
29
+ TOKEN_TYPE = :token_type
30
+ USER_PROFILE_ID = :user_profile_id
31
+ WORKSPACE_ID = :workspace_id
32
+
33
+ # @!method self.values
34
+ # @return [Array<Symbol>]
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ module Organization
7
+ module Analytics
8
+ # @see Anthropic::Resources::Beta::Organization::Analytics::Cost#list
9
+ class BetaAnalyticsCostItem < Anthropic::Internal::Type::BaseModel
10
+ # @!attribute cost
11
+ # Cost for this row.
12
+ #
13
+ # @return [Anthropic::Models::Beta::Organization::Analytics::BetaAnalyticsCostMetrics]
14
+ required :cost, -> { Anthropic::Beta::Organization::Analytics::BetaAnalyticsCostMetrics }
15
+
16
+ # @!attribute ending_at
17
+ # End of the period this row covers (exclusive), as an RFC 3339 UTC timestamp: the
18
+ # end of the row's time bucket when a time-bucket width is set; otherwise the
19
+ # requested `ending_at` (or, when omitted, the earlier of now and `starting_at`
20
+ # plus 31 days) rounded down to the hour, because without a time bucket the report
21
+ # covers whole hours.
22
+ #
23
+ # @return [Time]
24
+ required :ending_at, Time
25
+
26
+ # @!attribute group
27
+ # The dimension values this row's cost is broken out by.
28
+ #
29
+ # @return [Anthropic::Models::Beta::Organization::Analytics::BetaAnalyticsCostGroup]
30
+ required :group, -> { Anthropic::Beta::Organization::Analytics::BetaAnalyticsCostGroup }
31
+
32
+ # @!attribute starting_at
33
+ # Start of the period this row covers (inclusive), as an RFC 3339 UTC timestamp:
34
+ # the start of the row's time bucket when a time-bucket width is set, otherwise
35
+ # the requested `starting_at` rounded down to the hour.
36
+ #
37
+ # @return [Time]
38
+ required :starting_at, Time
39
+
40
+ # @!method initialize(cost:, ending_at:, group:, starting_at:)
41
+ # Some parameter documentations has been truncated, see
42
+ # {Anthropic::Models::Beta::Organization::Analytics::BetaAnalyticsCostItem} for
43
+ # more details.
44
+ #
45
+ # @param cost [Anthropic::Models::Beta::Organization::Analytics::BetaAnalyticsCostMetrics] Cost for this row.
46
+ #
47
+ # @param ending_at [Time] End of the period this row covers (exclusive), as an RFC 3339 UTC timestamp: the
48
+ #
49
+ # @param group [Anthropic::Models::Beta::Organization::Analytics::BetaAnalyticsCostGroup] The dimension values this row's cost is broken out by.
50
+ #
51
+ # @param starting_at [Time] Start of the period this row covers (inclusive), as an RFC 3339 UTC timestamp: t
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ module Organization
7
+ module Analytics
8
+ class BetaAnalyticsCostMetrics < Anthropic::Internal::Type::BaseModel
9
+ # @!attribute amount
10
+ # Amount (post-discount, pre-credit) in fractional cents (minor units).
11
+ #
12
+ # @return [String]
13
+ required :amount, String
14
+
15
+ # @!attribute currency
16
+ # Currency code for the cost amount. Currently always `"USD"`.
17
+ #
18
+ # @return [String]
19
+ required :currency, String
20
+
21
+ # @!attribute list_amount
22
+ # List-price amount (pre-discount) in fractional cents.
23
+ #
24
+ # @return [String]
25
+ required :list_amount, String
26
+
27
+ # @!attribute requests
28
+ # Number of API requests in this row's scope. Null when `group_by` includes
29
+ # `cost_type` or `token_type` (the count has no per-component attribution; read it
30
+ # from the ungrouped response). For sandbox / code-execution events, this counts
31
+ # execution spans rather than HTTP requests (these rows surface with
32
+ # `product: null`).
33
+ #
34
+ # @return [Integer, nil]
35
+ required :requests, Integer, nil?: true
36
+
37
+ # @!method initialize(amount:, currency:, list_amount:, requests:)
38
+ # The cost of one row.
39
+ #
40
+ # Some parameter documentations has been truncated, see
41
+ # {Anthropic::Models::Beta::Organization::Analytics::BetaAnalyticsCostMetrics} for
42
+ # more details.
43
+ #
44
+ # @param amount [String] Amount (post-discount, pre-credit) in fractional cents (minor units).
45
+ #
46
+ # @param currency [String] Currency code for the cost amount. Currently always `"USD"`.
47
+ #
48
+ # @param list_amount [String] List-price amount (pre-discount) in fractional cents.
49
+ #
50
+ # @param requests [Integer, nil] Number of API requests in this row's scope. Null when `group_by` includes
51
+ # `cost\_
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ module Organization
7
+ module Analytics
8
+ module BetaAnalyticsCostOrderBy
9
+ extend Anthropic::Internal::Type::Enum
10
+
11
+ AMOUNT = :amount
12
+ LIST_AMOUNT = :list_amount
13
+ TIME = :time
14
+
15
+ # @!method self.values
16
+ # @return [Array<Symbol>]
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end