safetykit 0.52.0 → 0.54.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb740cd06fd2147d66523afd833977860625eba2fa2b3b85dba5933a46f68a74
4
- data.tar.gz: 49974de3af4a1b8188a16cd72999a6eb822338e4f2cb5b5ee80739885f550aad
3
+ metadata.gz: 3940fe0cd96efc27d41bf5e435769504809af46453f457e210009cc7984054f7
4
+ data.tar.gz: 1091f431d55165f712b327cb01b806eea5df1c0a3f9591d47ddc6d9d92090ece
5
5
  SHA512:
6
- metadata.gz: bd4c8bf187f42c1ddbff83a393afd6c3e177414a1c37f62b6d1847c8457cc2de4d570d5941c6a81f13701006cd77c80f62b7919bcc26459418b6f9ca5b572fe8
7
- data.tar.gz: 9bd4562815b061c8d5995cf75aa02752726f66e55cb2d8ecd5bd8893f434bd0470e403cef886e004214f20c04b35565096d731b539b27285444364e36d042989
6
+ metadata.gz: 7b4103c14298b4ca6bccf47cb52d3f093a9864d00d85242587b36f3029ac8ecee8097dd7413e7506f4abd4a16dec273041e0cd9b70f7493d666128bb3003c777
7
+ data.tar.gz: b67aa63c04b3e02921d364e307baafa4508a3dea6fd3ead32cd2f8f392873b5c65ca8dc6b17726c4c64d13f53cbc356340de536032a6a96ee3772b03b11af308
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.54.0 (2026-08-06)
4
+
5
+ Full Changelog: [v0.53.0...v0.54.0](https://github.com/GetSafetyKit/safetykit-ruby/compare/v0.53.0...v0.54.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** api update ([d4f948d](https://github.com/GetSafetyKit/safetykit-ruby/commit/d4f948d151496411504a069e14144de5fbe6e9ce))
10
+
11
+ ## 0.53.0 (2026-08-06)
12
+
13
+ Full Changelog: [v0.52.0...v0.53.0](https://github.com/GetSafetyKit/safetykit-ruby/compare/v0.52.0...v0.53.0)
14
+
15
+ ### Features
16
+
17
+ * **api:** api update ([4c74263](https://github.com/GetSafetyKit/safetykit-ruby/commit/4c74263a51e3176b1ff3660c1b5ac14d0dcd3559))
18
+
3
19
  ## 0.52.0 (2026-08-05)
4
20
 
5
21
  Full Changelog: [v0.51.0...v0.52.0](https://github.com/GetSafetyKit/safetykit-ruby/compare/v0.51.0...v0.52.0)
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "safetykit", "~> 0.52.0"
20
+ gem "safetykit", "~> 0.54.0"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -7,23 +7,21 @@ module SafetyKit
7
7
  extend SafetyKit::Internal::Type::RequestParameters::Converter
8
8
  include SafetyKit::Internal::Type::RequestParameters
9
9
 
10
- # @!attribute entity_id
11
- # Your stable identifier for the entity this content belongs to, such as a user,
12
- # listing, or message thread.
10
+ # @!attribute user_id
11
+ # Your stable identifier for the user this content belongs to.
13
12
  #
14
13
  # @return [String]
15
- required :entity_id, String
14
+ required :user_id, String
16
15
 
17
16
  # @!attribute content_id
18
- # Your identifier for this content, matching the content_id sent on /v1/events.
19
- # Prevents double-counting content submitted to both endpoints.
17
+ # Your content identifier.
20
18
  #
21
19
  # @return [String, nil]
22
20
  optional :content_id, String
23
21
 
24
22
  # @!attribute images
25
23
  # Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
26
- # most 4 images, 5MB each.
24
+ # most 5MB each.
27
25
  #
28
26
  # @return [Array<String>, nil]
29
27
  optional :images, SafetyKit::Internal::Type::ArrayOf[String]
@@ -35,25 +33,24 @@ module SafetyKit
35
33
  optional :metadata, SafetyKit::Internal::Type::HashOf[SafetyKit::Internal::Type::Unknown, nil?: true]
36
34
 
37
35
  # @!attribute text
38
- # User-authored text to classify. At most 20000 characters. Classification is
39
- # based on the first 16,000 characters.
36
+ # User-authored text to classify.
40
37
  #
41
38
  # @return [String, nil]
42
39
  optional :text, String
43
40
 
44
- # @!method initialize(entity_id:, content_id: nil, images: nil, metadata: nil, text: nil, request_options: {})
41
+ # @!method initialize(user_id:, content_id: nil, images: nil, metadata: nil, text: nil, request_options: {})
45
42
  # Some parameter documentations has been truncated, see
46
43
  # {SafetyKit::Models::ContentCreateParams} for more details.
47
44
  #
48
- # @param entity_id [String] Your stable identifier for the entity this content belongs to, such as a user, l
45
+ # @param user_id [String] Your stable identifier for the user this content belongs to.
49
46
  #
50
- # @param content_id [String] Your identifier for this content, matching the content_id sent on /v1/events. Pr
47
+ # @param content_id [String] Your content identifier.
51
48
  #
52
49
  # @param images [Array<String>] Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
53
50
  #
54
51
  # @param metadata [Hash{Symbol=>Object, nil}] Additional product context for this content. At most 8KB when serialized.
55
52
  #
56
- # @param text [String] User-authored text to classify. At most 20000 characters. Classification is base
53
+ # @param text [String] User-authored text to classify.
57
54
  #
58
55
  # @param request_options [SafetyKit::RequestOptions, Hash{Symbol=>Object}]
59
56
  end
@@ -10,31 +10,12 @@ module SafetyKit
10
10
  # @return [String]
11
11
  required :content_id, String
12
12
 
13
- # @!attribute decision
14
- # SafetyKit's decision for the submitted content: approve (no violation found),
15
- # reject (violating), or review (needs human review).
13
+ # @!attribute policies
14
+ # Per-policy results for the submitted content.
16
15
  #
17
- # @return [Symbol, SafetyKit::Models::ContentCreateResponse::Decision]
18
- required :decision, enum: -> { SafetyKit::Models::ContentCreateResponse::Decision }
19
-
20
- # @!attribute entity_id
21
- # The entity_id from the request.
22
- #
23
- # @return [String]
24
- required :entity_id, String
25
-
26
- # @!attribute escalation
27
- # Escalation outcome: none (no escalation ran), completed (verdict reflected in
28
- # decision), or timed_out (decision is a provisional review).
29
- #
30
- # @return [Symbol, SafetyKit::Models::ContentCreateResponse::Escalation]
31
- required :escalation, enum: -> { SafetyKit::Models::ContentCreateResponse::Escalation }
32
-
33
- # @!attribute mirrored
34
- # Whether SafetyKit mirrored the submitted content for later review.
35
- #
36
- # @return [Boolean]
37
- required :mirrored, SafetyKit::Internal::Type::Boolean
16
+ # @return [Array<SafetyKit::Models::ContentCreateResponse::Policy>]
17
+ required :policies,
18
+ -> { SafetyKit::Internal::Type::ArrayOf[SafetyKit::Models::ContentCreateResponse::Policy] }
38
19
 
39
20
  # @!attribute reference_set_matches
40
21
  # Reference set matches found for the submitted content.
@@ -43,61 +24,94 @@ module SafetyKit
43
24
  required :reference_set_matches,
44
25
  -> { SafetyKit::Internal::Type::ArrayOf[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch] }
45
26
 
46
- # @!attribute scores
47
- # Classifier scores produced for the submitted content.
27
+ # @!attribute user_id
28
+ # The user_id from the request.
48
29
  #
49
- # @return [Array<SafetyKit::Models::ContentCreateResponse::Score>]
50
- required :scores,
51
- -> { SafetyKit::Internal::Type::ArrayOf[SafetyKit::Models::ContentCreateResponse::Score] }
30
+ # @return [String]
31
+ required :user_id, String
52
32
 
53
- # @!method initialize(content_id:, decision:, entity_id:, escalation:, mirrored:, reference_set_matches:, scores:)
54
- # Some parameter documentations has been truncated, see
55
- # {SafetyKit::Models::ContentCreateResponse} for more details.
56
- #
33
+ # @!method initialize(content_id:, policies:, reference_set_matches:, user_id:)
57
34
  # Synchronous classification result for the submitted content.
58
35
  #
59
36
  # @param content_id [String] SafetyKit identifier for the classified content.
60
37
  #
61
- # @param decision [Symbol, SafetyKit::Models::ContentCreateResponse::Decision] SafetyKit's decision for the submitted content: approve (no violation found), re
62
- #
63
- # @param entity_id [String] The entity_id from the request.
64
- #
65
- # @param escalation [Symbol, SafetyKit::Models::ContentCreateResponse::Escalation] Escalation outcome: none (no escalation ran), completed (verdict reflected in de
66
- #
67
- # @param mirrored [Boolean] Whether SafetyKit mirrored the submitted content for later review.
38
+ # @param policies [Array<SafetyKit::Models::ContentCreateResponse::Policy>] Per-policy results for the submitted content.
68
39
  #
69
40
  # @param reference_set_matches [Array<SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch>] Reference set matches found for the submitted content.
70
41
  #
71
- # @param scores [Array<SafetyKit::Models::ContentCreateResponse::Score>] Classifier scores produced for the submitted content.
42
+ # @param user_id [String] The user_id from the request.
72
43
 
73
- # SafetyKit's decision for the submitted content: approve (no violation found),
74
- # reject (violating), or review (needs human review).
75
- #
76
- # @see SafetyKit::Models::ContentCreateResponse#decision
77
- module Decision
78
- extend SafetyKit::Internal::Type::Enum
44
+ class Policy < SafetyKit::Internal::Type::BaseModel
45
+ # @!attribute decision
46
+ # Whether the submitted content violates the policy.
47
+ #
48
+ # @return [Symbol, SafetyKit::Models::ContentCreateResponse::Policy::Decision]
49
+ required :decision, enum: -> { SafetyKit::Models::ContentCreateResponse::Policy::Decision }
79
50
 
80
- APPROVE = :approve
81
- REJECT = :reject
82
- REVIEW = :review
51
+ # @!attribute escalation
52
+ # Escalation outcome for this policy.
53
+ #
54
+ # @return [Symbol, SafetyKit::Models::ContentCreateResponse::Policy::Escalation]
55
+ required :escalation, enum: -> { SafetyKit::Models::ContentCreateResponse::Policy::Escalation }
83
56
 
84
- # @!method self.values
85
- # @return [Array<Symbol>]
86
- end
57
+ # @!attribute policy_id
58
+ # Identifier of the policy.
59
+ #
60
+ # @return [String]
61
+ required :policy_id, String
87
62
 
88
- # Escalation outcome: none (no escalation ran), completed (verdict reflected in
89
- # decision), or timed_out (decision is a provisional review).
90
- #
91
- # @see SafetyKit::Models::ContentCreateResponse#escalation
92
- module Escalation
93
- extend SafetyKit::Internal::Type::Enum
63
+ # @!attribute score
64
+ # Policy score between 0 and 1. Higher means more likely violating.
65
+ #
66
+ # @return [Float]
67
+ required :score, Float
68
+
69
+ # @!attribute version
70
+ # Version of the policy.
71
+ #
72
+ # @return [String]
73
+ required :version, String
74
+
75
+ # @!method initialize(decision:, escalation:, policy_id:, score:, version:)
76
+ # Result for one policy evaluated against the submitted content.
77
+ #
78
+ # @param decision [Symbol, SafetyKit::Models::ContentCreateResponse::Policy::Decision] Whether the submitted content violates the policy.
79
+ #
80
+ # @param escalation [Symbol, SafetyKit::Models::ContentCreateResponse::Policy::Escalation] Escalation outcome for this policy.
81
+ #
82
+ # @param policy_id [String] Identifier of the policy.
83
+ #
84
+ # @param score [Float] Policy score between 0 and 1. Higher means more likely violating.
85
+ #
86
+ # @param version [String] Version of the policy.
87
+
88
+ # Whether the submitted content violates the policy.
89
+ #
90
+ # @see SafetyKit::Models::ContentCreateResponse::Policy#decision
91
+ module Decision
92
+ extend SafetyKit::Internal::Type::Enum
93
+
94
+ MATCH = :match
95
+ NOT_MATCH = :not_match
96
+ REVIEW = :review
94
97
 
95
- NONE = :none
96
- COMPLETED = :completed
97
- TIMED_OUT = :timed_out
98
+ # @!method self.values
99
+ # @return [Array<Symbol>]
100
+ end
98
101
 
99
- # @!method self.values
100
- # @return [Array<Symbol>]
102
+ # Escalation outcome for this policy.
103
+ #
104
+ # @see SafetyKit::Models::ContentCreateResponse::Policy#escalation
105
+ module Escalation
106
+ extend SafetyKit::Internal::Type::Enum
107
+
108
+ NONE = :none
109
+ COMPLETED = :completed
110
+ TIMED_OUT = :timed_out
111
+
112
+ # @!method self.values
113
+ # @return [Array<Symbol>]
114
+ end
101
115
  end
102
116
 
103
117
  class ReferenceSetMatch < SafetyKit::Internal::Type::BaseModel
@@ -120,35 +134,6 @@ module SafetyKit
120
134
  #
121
135
  # @param similarity [Float] Similarity between the submitted content and the matched reference set entry.
122
136
  end
123
-
124
- class Score < SafetyKit::Internal::Type::BaseModel
125
- # @!attribute classifier_id
126
- # Identifier of the classifier that produced this score.
127
- #
128
- # @return [String]
129
- required :classifier_id, String
130
-
131
- # @!attribute score
132
- # Classifier score between 0 and 1. Higher means more likely violating.
133
- #
134
- # @return [Float]
135
- required :score, Float
136
-
137
- # @!attribute version
138
- # Version of the classifier that produced this score.
139
- #
140
- # @return [String]
141
- required :version, String
142
-
143
- # @!method initialize(classifier_id:, score:, version:)
144
- # Score produced by one classifier for the submitted content.
145
- #
146
- # @param classifier_id [String] Identifier of the classifier that produced this score.
147
- #
148
- # @param score [Float] Classifier score between 0 and 1. Higher means more likely violating.
149
- #
150
- # @param version [String] Version of the classifier that produced this score.
151
- end
152
137
  end
153
138
  end
154
139
  end
@@ -9,20 +9,20 @@ module SafetyKit
9
9
  # {SafetyKit::Models::ContentCreateParams} for more details.
10
10
  #
11
11
  # Classify a piece of content synchronously. Send user-authored text, images, or
12
- # both, and receive a decision (approve, reject, or review) with classifier scores
13
- # and reference set matches in the response. Requests have a maximum size of 6MB.
12
+ # both, and receive per-policy results in the response. Requests have a maximum
13
+ # size of 6MB.
14
14
  #
15
- # @overload create(entity_id:, content_id: nil, images: nil, metadata: nil, text: nil, request_options: {})
15
+ # @overload create(user_id:, content_id: nil, images: nil, metadata: nil, text: nil, request_options: {})
16
16
  #
17
- # @param entity_id [String] Your stable identifier for the entity this content belongs to, such as a user, l
17
+ # @param user_id [String] Your stable identifier for the user this content belongs to.
18
18
  #
19
- # @param content_id [String] Your identifier for this content, matching the content_id sent on /v1/events. Pr
19
+ # @param content_id [String] Your content identifier.
20
20
  #
21
21
  # @param images [Array<String>] Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
22
22
  #
23
23
  # @param metadata [Hash{Symbol=>Object, nil}] Additional product context for this content. At most 8KB when serialized.
24
24
  #
25
- # @param text [String] User-authored text to classify. At most 20000 characters. Classification is base
25
+ # @param text [String] User-authored text to classify.
26
26
  #
27
27
  # @param request_options [SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil]
28
28
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SafetyKit
4
- VERSION = "0.52.0"
4
+ VERSION = "0.54.0"
5
5
  end
@@ -11,13 +11,11 @@ module SafetyKit
11
11
  T.any(SafetyKit::ContentCreateParams, SafetyKit::Internal::AnyHash)
12
12
  end
13
13
 
14
- # Your stable identifier for the entity this content belongs to, such as a user,
15
- # listing, or message thread.
14
+ # Your stable identifier for the user this content belongs to.
16
15
  sig { returns(String) }
17
- attr_accessor :entity_id
16
+ attr_accessor :user_id
18
17
 
19
- # Your identifier for this content, matching the content_id sent on /v1/events.
20
- # Prevents double-counting content submitted to both endpoints.
18
+ # Your content identifier.
21
19
  sig { returns(T.nilable(String)) }
22
20
  attr_reader :content_id
23
21
 
@@ -25,7 +23,7 @@ module SafetyKit
25
23
  attr_writer :content_id
26
24
 
27
25
  # Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
28
- # most 4 images, 5MB each.
26
+ # most 5MB each.
29
27
  sig { returns(T.nilable(T::Array[String])) }
30
28
  attr_reader :images
31
29
 
@@ -39,8 +37,7 @@ module SafetyKit
39
37
  sig { params(metadata: T::Hash[Symbol, T.nilable(T.anything)]).void }
40
38
  attr_writer :metadata
41
39
 
42
- # User-authored text to classify. At most 20000 characters. Classification is
43
- # based on the first 16,000 characters.
40
+ # User-authored text to classify.
44
41
  sig { returns(T.nilable(String)) }
45
42
  attr_reader :text
46
43
 
@@ -49,7 +46,7 @@ module SafetyKit
49
46
 
50
47
  sig do
51
48
  params(
52
- entity_id: String,
49
+ user_id: String,
53
50
  content_id: String,
54
51
  images: T::Array[String],
55
52
  metadata: T::Hash[Symbol, T.nilable(T.anything)],
@@ -58,19 +55,16 @@ module SafetyKit
58
55
  ).returns(T.attached_class)
59
56
  end
60
57
  def self.new(
61
- # Your stable identifier for the entity this content belongs to, such as a user,
62
- # listing, or message thread.
63
- entity_id:,
64
- # Your identifier for this content, matching the content_id sent on /v1/events.
65
- # Prevents double-counting content submitted to both endpoints.
58
+ # Your stable identifier for the user this content belongs to.
59
+ user_id:,
60
+ # Your content identifier.
66
61
  content_id: nil,
67
62
  # Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
68
- # most 4 images, 5MB each.
63
+ # most 5MB each.
69
64
  images: nil,
70
65
  # Additional product context for this content. At most 8KB when serialized.
71
66
  metadata: nil,
72
- # User-authored text to classify. At most 20000 characters. Classification is
73
- # based on the first 16,000 characters.
67
+ # User-authored text to classify.
74
68
  text: nil,
75
69
  request_options: {}
76
70
  )
@@ -79,7 +73,7 @@ module SafetyKit
79
73
  sig do
80
74
  override.returns(
81
75
  {
82
- entity_id: String,
76
+ user_id: String,
83
77
  content_id: String,
84
78
  images: T::Array[String],
85
79
  metadata: T::Hash[Symbol, T.nilable(T.anything)],
@@ -15,31 +15,11 @@ module SafetyKit
15
15
  sig { returns(String) }
16
16
  attr_accessor :content_id
17
17
 
18
- # SafetyKit's decision for the submitted content: approve (no violation found),
19
- # reject (violating), or review (needs human review).
18
+ # Per-policy results for the submitted content.
20
19
  sig do
21
- returns(
22
- SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
23
- )
20
+ returns(T::Array[SafetyKit::Models::ContentCreateResponse::Policy])
24
21
  end
25
- attr_accessor :decision
26
-
27
- # The entity_id from the request.
28
- sig { returns(String) }
29
- attr_accessor :entity_id
30
-
31
- # Escalation outcome: none (no escalation ran), completed (verdict reflected in
32
- # decision), or timed_out (decision is a provisional review).
33
- sig do
34
- returns(
35
- SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
36
- )
37
- end
38
- attr_accessor :escalation
39
-
40
- # Whether SafetyKit mirrored the submitted content for later review.
41
- sig { returns(T::Boolean) }
42
- attr_accessor :mirrored
22
+ attr_accessor :policies
43
23
 
44
24
  # Reference set matches found for the submitted content.
45
25
  sig do
@@ -49,45 +29,32 @@ module SafetyKit
49
29
  end
50
30
  attr_accessor :reference_set_matches
51
31
 
52
- # Classifier scores produced for the submitted content.
53
- sig { returns(T::Array[SafetyKit::Models::ContentCreateResponse::Score]) }
54
- attr_accessor :scores
32
+ # The user_id from the request.
33
+ sig { returns(String) }
34
+ attr_accessor :user_id
55
35
 
56
36
  # Synchronous classification result for the submitted content.
57
37
  sig do
58
38
  params(
59
39
  content_id: String,
60
- decision:
61
- SafetyKit::Models::ContentCreateResponse::Decision::OrSymbol,
62
- entity_id: String,
63
- escalation:
64
- SafetyKit::Models::ContentCreateResponse::Escalation::OrSymbol,
65
- mirrored: T::Boolean,
40
+ policies:
41
+ T::Array[SafetyKit::Models::ContentCreateResponse::Policy::OrHash],
66
42
  reference_set_matches:
67
43
  T::Array[
68
44
  SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch::OrHash
69
45
  ],
70
- scores:
71
- T::Array[SafetyKit::Models::ContentCreateResponse::Score::OrHash]
46
+ user_id: String
72
47
  ).returns(T.attached_class)
73
48
  end
74
49
  def self.new(
75
50
  # SafetyKit identifier for the classified content.
76
51
  content_id:,
77
- # SafetyKit's decision for the submitted content: approve (no violation found),
78
- # reject (violating), or review (needs human review).
79
- decision:,
80
- # The entity_id from the request.
81
- entity_id:,
82
- # Escalation outcome: none (no escalation ran), completed (verdict reflected in
83
- # decision), or timed_out (decision is a provisional review).
84
- escalation:,
85
- # Whether SafetyKit mirrored the submitted content for later review.
86
- mirrored:,
52
+ # Per-policy results for the submitted content.
53
+ policies:,
87
54
  # Reference set matches found for the submitted content.
88
55
  reference_set_matches:,
89
- # Classifier scores produced for the submitted content.
90
- scores:
56
+ # The user_id from the request.
57
+ user_id:
91
58
  )
92
59
  end
93
60
 
@@ -95,96 +62,176 @@ module SafetyKit
95
62
  override.returns(
96
63
  {
97
64
  content_id: String,
98
- decision:
99
- SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol,
100
- entity_id: String,
101
- escalation:
102
- SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol,
103
- mirrored: T::Boolean,
65
+ policies:
66
+ T::Array[SafetyKit::Models::ContentCreateResponse::Policy],
104
67
  reference_set_matches:
105
68
  T::Array[
106
69
  SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch
107
70
  ],
108
- scores: T::Array[SafetyKit::Models::ContentCreateResponse::Score]
71
+ user_id: String
109
72
  }
110
73
  )
111
74
  end
112
75
  def to_hash
113
76
  end
114
77
 
115
- # SafetyKit's decision for the submitted content: approve (no violation found),
116
- # reject (violating), or review (needs human review).
117
- module Decision
118
- extend SafetyKit::Internal::Type::Enum
119
-
120
- TaggedSymbol =
78
+ class Policy < SafetyKit::Internal::Type::BaseModel
79
+ OrHash =
121
80
  T.type_alias do
122
- T.all(Symbol, SafetyKit::Models::ContentCreateResponse::Decision)
81
+ T.any(
82
+ SafetyKit::Models::ContentCreateResponse::Policy,
83
+ SafetyKit::Internal::AnyHash
84
+ )
123
85
  end
124
- OrSymbol = T.type_alias { T.any(Symbol, String) }
125
86
 
126
- APPROVE =
127
- T.let(
128
- :approve,
129
- SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
130
- )
131
- REJECT =
132
- T.let(
133
- :reject,
134
- SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
135
- )
136
- REVIEW =
137
- T.let(
138
- :review,
139
- SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
87
+ # Whether the submitted content violates the policy.
88
+ sig do
89
+ returns(
90
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision::TaggedSymbol
140
91
  )
92
+ end
93
+ attr_accessor :decision
141
94
 
95
+ # Escalation outcome for this policy.
142
96
  sig do
143
- override.returns(
144
- T::Array[
145
- SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
146
- ]
97
+ returns(
98
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation::TaggedSymbol
147
99
  )
148
100
  end
149
- def self.values
150
- end
151
- end
101
+ attr_accessor :escalation
152
102
 
153
- # Escalation outcome: none (no escalation ran), completed (verdict reflected in
154
- # decision), or timed_out (decision is a provisional review).
155
- module Escalation
156
- extend SafetyKit::Internal::Type::Enum
103
+ # Identifier of the policy.
104
+ sig { returns(String) }
105
+ attr_accessor :policy_id
157
106
 
158
- TaggedSymbol =
159
- T.type_alias do
160
- T.all(Symbol, SafetyKit::Models::ContentCreateResponse::Escalation)
161
- end
162
- OrSymbol = T.type_alias { T.any(Symbol, String) }
107
+ # Policy score between 0 and 1. Higher means more likely violating.
108
+ sig { returns(Float) }
109
+ attr_accessor :score
163
110
 
164
- NONE =
165
- T.let(
166
- :none,
167
- SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
168
- )
169
- COMPLETED =
170
- T.let(
171
- :completed,
172
- SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
173
- )
174
- TIMED_OUT =
175
- T.let(
176
- :timed_out,
177
- SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
178
- )
111
+ # Version of the policy.
112
+ sig { returns(String) }
113
+ attr_accessor :version
114
+
115
+ # Result for one policy evaluated against the submitted content.
116
+ sig do
117
+ params(
118
+ decision:
119
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision::OrSymbol,
120
+ escalation:
121
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation::OrSymbol,
122
+ policy_id: String,
123
+ score: Float,
124
+ version: String
125
+ ).returns(T.attached_class)
126
+ end
127
+ def self.new(
128
+ # Whether the submitted content violates the policy.
129
+ decision:,
130
+ # Escalation outcome for this policy.
131
+ escalation:,
132
+ # Identifier of the policy.
133
+ policy_id:,
134
+ # Policy score between 0 and 1. Higher means more likely violating.
135
+ score:,
136
+ # Version of the policy.
137
+ version:
138
+ )
139
+ end
179
140
 
180
141
  sig do
181
142
  override.returns(
182
- T::Array[
183
- SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
184
- ]
143
+ {
144
+ decision:
145
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision::TaggedSymbol,
146
+ escalation:
147
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation::TaggedSymbol,
148
+ policy_id: String,
149
+ score: Float,
150
+ version: String
151
+ }
185
152
  )
186
153
  end
187
- def self.values
154
+ def to_hash
155
+ end
156
+
157
+ # Whether the submitted content violates the policy.
158
+ module Decision
159
+ extend SafetyKit::Internal::Type::Enum
160
+
161
+ TaggedSymbol =
162
+ T.type_alias do
163
+ T.all(
164
+ Symbol,
165
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision
166
+ )
167
+ end
168
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
169
+
170
+ MATCH =
171
+ T.let(
172
+ :match,
173
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision::TaggedSymbol
174
+ )
175
+ NOT_MATCH =
176
+ T.let(
177
+ :not_match,
178
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision::TaggedSymbol
179
+ )
180
+ REVIEW =
181
+ T.let(
182
+ :review,
183
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision::TaggedSymbol
184
+ )
185
+
186
+ sig do
187
+ override.returns(
188
+ T::Array[
189
+ SafetyKit::Models::ContentCreateResponse::Policy::Decision::TaggedSymbol
190
+ ]
191
+ )
192
+ end
193
+ def self.values
194
+ end
195
+ end
196
+
197
+ # Escalation outcome for this policy.
198
+ module Escalation
199
+ extend SafetyKit::Internal::Type::Enum
200
+
201
+ TaggedSymbol =
202
+ T.type_alias do
203
+ T.all(
204
+ Symbol,
205
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation
206
+ )
207
+ end
208
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
209
+
210
+ NONE =
211
+ T.let(
212
+ :none,
213
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation::TaggedSymbol
214
+ )
215
+ COMPLETED =
216
+ T.let(
217
+ :completed,
218
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation::TaggedSymbol
219
+ )
220
+ TIMED_OUT =
221
+ T.let(
222
+ :timed_out,
223
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation::TaggedSymbol
224
+ )
225
+
226
+ sig do
227
+ override.returns(
228
+ T::Array[
229
+ SafetyKit::Models::ContentCreateResponse::Policy::Escalation::TaggedSymbol
230
+ ]
231
+ )
232
+ end
233
+ def self.values
234
+ end
188
235
  end
189
236
  end
190
237
 
@@ -221,52 +268,6 @@ module SafetyKit
221
268
  def to_hash
222
269
  end
223
270
  end
224
-
225
- class Score < SafetyKit::Internal::Type::BaseModel
226
- OrHash =
227
- T.type_alias do
228
- T.any(
229
- SafetyKit::Models::ContentCreateResponse::Score,
230
- SafetyKit::Internal::AnyHash
231
- )
232
- end
233
-
234
- # Identifier of the classifier that produced this score.
235
- sig { returns(String) }
236
- attr_accessor :classifier_id
237
-
238
- # Classifier score between 0 and 1. Higher means more likely violating.
239
- sig { returns(Float) }
240
- attr_accessor :score
241
-
242
- # Version of the classifier that produced this score.
243
- sig { returns(String) }
244
- attr_accessor :version
245
-
246
- # Score produced by one classifier for the submitted content.
247
- sig do
248
- params(classifier_id: String, score: Float, version: String).returns(
249
- T.attached_class
250
- )
251
- end
252
- def self.new(
253
- # Identifier of the classifier that produced this score.
254
- classifier_id:,
255
- # Classifier score between 0 and 1. Higher means more likely violating.
256
- score:,
257
- # Version of the classifier that produced this score.
258
- version:
259
- )
260
- end
261
-
262
- sig do
263
- override.returns(
264
- { classifier_id: String, score: Float, version: String }
265
- )
266
- end
267
- def to_hash
268
- end
269
- end
270
271
  end
271
272
  end
272
273
  end
@@ -6,11 +6,11 @@ module SafetyKit
6
6
  # the response.
7
7
  class Content
8
8
  # Classify a piece of content synchronously. Send user-authored text, images, or
9
- # both, and receive a decision (approve, reject, or review) with classifier scores
10
- # and reference set matches in the response. Requests have a maximum size of 6MB.
9
+ # both, and receive per-policy results in the response. Requests have a maximum
10
+ # size of 6MB.
11
11
  sig do
12
12
  params(
13
- entity_id: String,
13
+ user_id: String,
14
14
  content_id: String,
15
15
  images: T::Array[String],
16
16
  metadata: T::Hash[Symbol, T.nilable(T.anything)],
@@ -19,19 +19,16 @@ module SafetyKit
19
19
  ).returns(SafetyKit::Models::ContentCreateResponse)
20
20
  end
21
21
  def create(
22
- # Your stable identifier for the entity this content belongs to, such as a user,
23
- # listing, or message thread.
24
- entity_id:,
25
- # Your identifier for this content, matching the content_id sent on /v1/events.
26
- # Prevents double-counting content submitted to both endpoints.
22
+ # Your stable identifier for the user this content belongs to.
23
+ user_id:,
24
+ # Your content identifier.
27
25
  content_id: nil,
28
26
  # Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
29
- # most 4 images, 5MB each.
27
+ # most 5MB each.
30
28
  images: nil,
31
29
  # Additional product context for this content. At most 8KB when serialized.
32
30
  metadata: nil,
33
- # User-authored text to classify. At most 20000 characters. Classification is
34
- # based on the first 16,000 characters.
31
+ # User-authored text to classify.
35
32
  text: nil,
36
33
  request_options: {}
37
34
  )
@@ -2,7 +2,7 @@ module SafetyKit
2
2
  module Models
3
3
  type content_create_params =
4
4
  {
5
- entity_id: String,
5
+ user_id: String,
6
6
  content_id: String,
7
7
  images: ::Array[String],
8
8
  metadata: ::Hash[Symbol, top?],
@@ -14,7 +14,7 @@ module SafetyKit
14
14
  extend SafetyKit::Internal::Type::RequestParameters::Converter
15
15
  include SafetyKit::Internal::Type::RequestParameters
16
16
 
17
- attr_accessor entity_id: String
17
+ attr_accessor user_id: String
18
18
 
19
19
  attr_reader content_id: String?
20
20
 
@@ -33,7 +33,7 @@ module SafetyKit
33
33
  def text=: (String) -> String
34
34
 
35
35
  def initialize: (
36
- entity_id: String,
36
+ user_id: String,
37
37
  ?content_id: String,
38
38
  ?images: ::Array[String],
39
39
  ?metadata: ::Hash[Symbol, top?],
@@ -42,7 +42,7 @@ module SafetyKit
42
42
  ) -> void
43
43
 
44
44
  def to_hash: -> {
45
- entity_id: String,
45
+ user_id: String,
46
46
  content_id: String,
47
47
  images: ::Array[String],
48
48
  metadata: ::Hash[Symbol, top?],
@@ -3,71 +3,93 @@ module SafetyKit
3
3
  type content_create_response =
4
4
  {
5
5
  content_id: String,
6
- decision: SafetyKit::Models::ContentCreateResponse::decision,
7
- entity_id: String,
8
- escalation: SafetyKit::Models::ContentCreateResponse::escalation,
9
- mirrored: bool,
6
+ policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy],
10
7
  reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
11
- scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
8
+ user_id: String
12
9
  }
13
10
 
14
11
  class ContentCreateResponse < SafetyKit::Internal::Type::BaseModel
15
12
  attr_accessor content_id: String
16
13
 
17
- attr_accessor decision: SafetyKit::Models::ContentCreateResponse::decision
18
-
19
- attr_accessor entity_id: String
20
-
21
- attr_accessor escalation: SafetyKit::Models::ContentCreateResponse::escalation
22
-
23
- attr_accessor mirrored: bool
14
+ attr_accessor policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy]
24
15
 
25
16
  attr_accessor reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch]
26
17
 
27
- attr_accessor scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
18
+ attr_accessor user_id: String
28
19
 
29
20
  def initialize: (
30
21
  content_id: String,
31
- decision: SafetyKit::Models::ContentCreateResponse::decision,
32
- entity_id: String,
33
- escalation: SafetyKit::Models::ContentCreateResponse::escalation,
34
- mirrored: bool,
22
+ policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy],
35
23
  reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
36
- scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
24
+ user_id: String
37
25
  ) -> void
38
26
 
39
27
  def to_hash: -> {
40
28
  content_id: String,
41
- decision: SafetyKit::Models::ContentCreateResponse::decision,
42
- entity_id: String,
43
- escalation: SafetyKit::Models::ContentCreateResponse::escalation,
44
- mirrored: bool,
29
+ policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy],
45
30
  reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
46
- scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
31
+ user_id: String
47
32
  }
48
33
 
49
- type decision = :approve | :reject | :review
34
+ type policy =
35
+ {
36
+ decision: SafetyKit::Models::ContentCreateResponse::Policy::decision,
37
+ escalation: SafetyKit::Models::ContentCreateResponse::Policy::escalation,
38
+ policy_id: String,
39
+ score: Float,
40
+ version: String
41
+ }
50
42
 
51
- module Decision
52
- extend SafetyKit::Internal::Type::Enum
43
+ class Policy < SafetyKit::Internal::Type::BaseModel
44
+ attr_accessor decision: SafetyKit::Models::ContentCreateResponse::Policy::decision
53
45
 
54
- APPROVE: :approve
55
- REJECT: :reject
56
- REVIEW: :review
46
+ attr_accessor escalation: SafetyKit::Models::ContentCreateResponse::Policy::escalation
57
47
 
58
- def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::decision]
59
- end
48
+ attr_accessor policy_id: String
49
+
50
+ attr_accessor score: Float
51
+
52
+ attr_accessor version: String
53
+
54
+ def initialize: (
55
+ decision: SafetyKit::Models::ContentCreateResponse::Policy::decision,
56
+ escalation: SafetyKit::Models::ContentCreateResponse::Policy::escalation,
57
+ policy_id: String,
58
+ score: Float,
59
+ version: String
60
+ ) -> void
61
+
62
+ def to_hash: -> {
63
+ decision: SafetyKit::Models::ContentCreateResponse::Policy::decision,
64
+ escalation: SafetyKit::Models::ContentCreateResponse::Policy::escalation,
65
+ policy_id: String,
66
+ score: Float,
67
+ version: String
68
+ }
60
69
 
61
- type escalation = :none | :completed | :timed_out
70
+ type decision = :match | :not_match | :review
62
71
 
63
- module Escalation
64
- extend SafetyKit::Internal::Type::Enum
72
+ module Decision
73
+ extend SafetyKit::Internal::Type::Enum
65
74
 
66
- NONE: :none
67
- COMPLETED: :completed
68
- TIMED_OUT: :timed_out
75
+ MATCH: :match
76
+ NOT_MATCH: :not_match
77
+ REVIEW: :review
69
78
 
70
- def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::escalation]
79
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Policy::decision]
80
+ end
81
+
82
+ type escalation = :none | :completed | :timed_out
83
+
84
+ module Escalation
85
+ extend SafetyKit::Internal::Type::Enum
86
+
87
+ NONE: :none
88
+ COMPLETED: :completed
89
+ TIMED_OUT: :timed_out
90
+
91
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Policy::escalation]
92
+ end
71
93
  end
72
94
 
73
95
  type reference_set_match = { set_id: String, similarity: Float }
@@ -81,24 +103,6 @@ module SafetyKit
81
103
 
82
104
  def to_hash: -> { set_id: String, similarity: Float }
83
105
  end
84
-
85
- type score = { classifier_id: String, score: Float, version: String }
86
-
87
- class Score < SafetyKit::Internal::Type::BaseModel
88
- attr_accessor classifier_id: String
89
-
90
- attr_accessor score: Float
91
-
92
- attr_accessor version: String
93
-
94
- def initialize: (
95
- classifier_id: String,
96
- score: Float,
97
- version: String
98
- ) -> void
99
-
100
- def to_hash: -> { classifier_id: String, score: Float, version: String }
101
- end
102
106
  end
103
107
  end
104
108
  end
@@ -2,7 +2,7 @@ module SafetyKit
2
2
  module Resources
3
3
  class Content
4
4
  def create: (
5
- entity_id: String,
5
+ user_id: String,
6
6
  ?content_id: String,
7
7
  ?images: ::Array[String],
8
8
  ?metadata: ::Hash[Symbol, top?],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safetykit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.52.0
4
+ version: 0.54.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Safetykit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-05 00:00:00.000000000 Z
11
+ date: 2026-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cgi