safetykit 0.57.0 → 0.58.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.
@@ -5,9 +5,9 @@ module SafetyKit
5
5
  # Classify user-authored text and images synchronously and receive a decision in
6
6
  # the response.
7
7
  class Content
8
- # Classify a piece of content synchronously. Send user-authored text, images, or
9
- # both, and receive per-policy results in the response. Requests have a maximum
10
- # size of 6MB.
8
+ # Classify a piece of content synchronously. Send text and image parts and receive
9
+ # per-label results in the response. Requests have a maximum size of 6MB. API
10
+ # version 2026-08-11; see the API versioning guide for superseded versions.
11
11
  #
12
12
  # Errors: 400 for an invalid body or images, with the failing field in the
13
13
  # message. 401 for a missing or invalid API key. 413 for requests over 6MB. 503
@@ -15,26 +15,33 @@ module SafetyKit
15
15
  # not processed and is safe to retry.
16
16
  sig do
17
17
  params(
18
+ content:
19
+ T::Array[
20
+ T.any(
21
+ SafetyKit::ContentCreateParams::Content::UnionMember0::OrHash,
22
+ SafetyKit::ContentCreateParams::Content::UnionMember1::OrHash
23
+ )
24
+ ],
18
25
  user_id: String,
19
26
  content_id: String,
20
- images: T::Array[String],
21
27
  metadata: T::Hash[Symbol, T.nilable(T.anything)],
22
- text: String,
28
+ safety_kit_version:
29
+ SafetyKit::ContentCreateParams::SafetyKitVersion::OrSymbol,
23
30
  request_options: SafetyKit::RequestOptions::OrHash
24
31
  ).returns(SafetyKit::Models::ContentCreateResponse)
25
32
  end
26
33
  def create(
27
- # Your stable identifier for the user this content belongs to.
34
+ # Body param: Content parts to classify together. At most 20 images.
35
+ content:,
36
+ # Body param: Your stable identifier for the user this content belongs to.
28
37
  user_id:,
29
- # Your content identifier.
38
+ # Body param: Your content identifier.
30
39
  content_id: nil,
31
- # Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
32
- # most 5MB each.
33
- images: nil,
34
- # Additional product context for this content. At most 8KB when serialized.
40
+ # Body param: Additional product context for this content. At most 8KB when
41
+ # serialized.
35
42
  metadata: nil,
36
- # User-authored text to classify.
37
- text: nil,
43
+ # Header param: The API version this operation is defined against.
44
+ safety_kit_version: nil,
38
45
  request_options: {}
39
46
  )
40
47
  end
@@ -2,11 +2,11 @@ module SafetyKit
2
2
  module Models
3
3
  type content_create_params =
4
4
  {
5
+ content: ::Array[SafetyKit::Models::ContentCreateParams::content],
5
6
  user_id: String,
6
7
  content_id: String,
7
- images: ::Array[String],
8
8
  metadata: ::Hash[Symbol, top?],
9
- text: String
9
+ safety_kit_version: SafetyKit::Models::ContentCreateParams::safety_kit_version
10
10
  }
11
11
  & SafetyKit::Internal::Type::request_parameters
12
12
 
@@ -14,41 +14,171 @@ module SafetyKit
14
14
  extend SafetyKit::Internal::Type::RequestParameters::Converter
15
15
  include SafetyKit::Internal::Type::RequestParameters
16
16
 
17
+ attr_accessor content: ::Array[SafetyKit::Models::ContentCreateParams::content]
18
+
17
19
  attr_accessor user_id: String
18
20
 
19
21
  attr_reader content_id: String?
20
22
 
21
23
  def content_id=: (String) -> String
22
24
 
23
- attr_reader images: ::Array[String]?
24
-
25
- def images=: (::Array[String]) -> ::Array[String]
26
-
27
25
  attr_reader metadata: ::Hash[Symbol, top?]?
28
26
 
29
27
  def metadata=: (::Hash[Symbol, top?]) -> ::Hash[Symbol, top?]
30
28
 
31
- attr_reader text: String?
29
+ attr_reader safety_kit_version: SafetyKit::Models::ContentCreateParams::safety_kit_version?
32
30
 
33
- def text=: (String) -> String
31
+ def safety_kit_version=: (
32
+ SafetyKit::Models::ContentCreateParams::safety_kit_version
33
+ ) -> SafetyKit::Models::ContentCreateParams::safety_kit_version
34
34
 
35
35
  def initialize: (
36
+ content: ::Array[SafetyKit::Models::ContentCreateParams::content],
36
37
  user_id: String,
37
38
  ?content_id: String,
38
- ?images: ::Array[String],
39
39
  ?metadata: ::Hash[Symbol, top?],
40
- ?text: String,
40
+ ?safety_kit_version: SafetyKit::Models::ContentCreateParams::safety_kit_version,
41
41
  ?request_options: SafetyKit::request_opts
42
42
  ) -> void
43
43
 
44
44
  def to_hash: -> {
45
+ content: ::Array[SafetyKit::Models::ContentCreateParams::content],
45
46
  user_id: String,
46
47
  content_id: String,
47
- images: ::Array[String],
48
48
  metadata: ::Hash[Symbol, top?],
49
- text: String,
49
+ safety_kit_version: SafetyKit::Models::ContentCreateParams::safety_kit_version,
50
50
  request_options: SafetyKit::RequestOptions
51
51
  }
52
+
53
+ type content =
54
+ SafetyKit::ContentCreateParams::Content::UnionMember0
55
+ | SafetyKit::ContentCreateParams::Content::UnionMember1
56
+
57
+ module Content
58
+ extend SafetyKit::Internal::Type::Union
59
+
60
+ type union_member0 =
61
+ {
62
+ text: String,
63
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember0::type_,
64
+ key: String
65
+ }
66
+
67
+ class UnionMember0 < SafetyKit::Internal::Type::BaseModel
68
+ attr_accessor text: String
69
+
70
+ attr_accessor type: SafetyKit::Models::ContentCreateParams::Content::UnionMember0::type_
71
+
72
+ attr_reader key: String?
73
+
74
+ def key=: (String) -> String
75
+
76
+ def initialize: (
77
+ text: String,
78
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember0::type_,
79
+ ?key: String
80
+ ) -> void
81
+
82
+ def to_hash: -> {
83
+ text: String,
84
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember0::type_,
85
+ key: String
86
+ }
87
+
88
+ type type_ = :text
89
+
90
+ module Type
91
+ extend SafetyKit::Internal::Type::Enum
92
+
93
+ TEXT: :text
94
+
95
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateParams::Content::UnionMember0::type_]
96
+ end
97
+ end
98
+
99
+ type union_member1 =
100
+ {
101
+ source: SafetyKit::ContentCreateParams::Content::UnionMember1::Source,
102
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::type_,
103
+ key: String
104
+ }
105
+
106
+ class UnionMember1 < SafetyKit::Internal::Type::BaseModel
107
+ attr_accessor source: SafetyKit::ContentCreateParams::Content::UnionMember1::Source
108
+
109
+ attr_accessor type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::type_
110
+
111
+ attr_reader key: String?
112
+
113
+ def key=: (String) -> String
114
+
115
+ def initialize: (
116
+ source: SafetyKit::ContentCreateParams::Content::UnionMember1::Source,
117
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::type_,
118
+ ?key: String
119
+ ) -> void
120
+
121
+ def to_hash: -> {
122
+ source: SafetyKit::ContentCreateParams::Content::UnionMember1::Source,
123
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::type_,
124
+ key: String
125
+ }
126
+
127
+ type source =
128
+ {
129
+ data: String,
130
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::Source::type_
131
+ }
132
+
133
+ class Source < SafetyKit::Internal::Type::BaseModel
134
+ attr_accessor data: String
135
+
136
+ attr_accessor type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::Source::type_
137
+
138
+ def initialize: (
139
+ data: String,
140
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::Source::type_
141
+ ) -> void
142
+
143
+ def to_hash: -> {
144
+ data: String,
145
+ type: SafetyKit::Models::ContentCreateParams::Content::UnionMember1::Source::type_
146
+ }
147
+
148
+ type type_ = :base64
149
+
150
+ module Type
151
+ extend SafetyKit::Internal::Type::Enum
152
+
153
+ BASE64: :base64
154
+
155
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateParams::Content::UnionMember1::Source::type_]
156
+ end
157
+ end
158
+
159
+ type type_ = :image
160
+
161
+ module Type
162
+ extend SafetyKit::Internal::Type::Enum
163
+
164
+ IMAGE: :image
165
+
166
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateParams::Content::UnionMember1::type_]
167
+ end
168
+ end
169
+
170
+ def self?.variants: -> ::Array[SafetyKit::Models::ContentCreateParams::content]
171
+ end
172
+
173
+ type safety_kit_version = :"2026-08-11"
174
+
175
+ module SafetyKitVersion
176
+ extend SafetyKit::Internal::Type::Enum
177
+
178
+ SAFETY_KIT_VERSION_2026_08_11: :"2026-08-11"
179
+
180
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateParams::safety_kit_version]
181
+ end
52
182
  end
53
183
  end
54
184
  end
@@ -3,105 +3,199 @@ module SafetyKit
3
3
  type content_create_response =
4
4
  {
5
5
  content_id: String,
6
- policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy],
7
- reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
8
- user_id: String
6
+ labels: ::Array[SafetyKit::Models::ContentCreateResponse::label],
7
+ user_id: String,
8
+ version: String
9
9
  }
10
10
 
11
11
  class ContentCreateResponse < SafetyKit::Internal::Type::BaseModel
12
12
  attr_accessor content_id: String
13
13
 
14
- attr_accessor policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy]
15
-
16
- attr_accessor reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch]
14
+ attr_accessor labels: ::Array[SafetyKit::Models::ContentCreateResponse::label]
17
15
 
18
16
  attr_accessor user_id: String
19
17
 
18
+ attr_accessor version: String
19
+
20
20
  def initialize: (
21
21
  content_id: String,
22
- policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy],
23
- reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
24
- user_id: String
22
+ labels: ::Array[SafetyKit::Models::ContentCreateResponse::label],
23
+ user_id: String,
24
+ version: String
25
25
  ) -> void
26
26
 
27
27
  def to_hash: -> {
28
28
  content_id: String,
29
- policies: ::Array[SafetyKit::Models::ContentCreateResponse::Policy],
30
- reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
31
- user_id: String
29
+ labels: ::Array[SafetyKit::Models::ContentCreateResponse::label],
30
+ user_id: String,
31
+ version: String
32
32
  }
33
33
 
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
- }
34
+ type label =
35
+ SafetyKit::Models::ContentCreateResponse::Label::UnionMember0
36
+ | SafetyKit::Models::ContentCreateResponse::Label::UnionMember1
42
37
 
43
- class Policy < SafetyKit::Internal::Type::BaseModel
44
- attr_accessor decision: SafetyKit::Models::ContentCreateResponse::Policy::decision
38
+ module Label
39
+ extend SafetyKit::Internal::Type::Union
45
40
 
46
- attr_accessor escalation: SafetyKit::Models::ContentCreateResponse::Policy::escalation
41
+ type union_member0 =
42
+ {
43
+ decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::decision,
44
+ escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::escalation,
45
+ label: String,
46
+ score: Float?,
47
+ type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::type_
48
+ }
47
49
 
48
- attr_accessor policy_id: String
50
+ class UnionMember0 < SafetyKit::Internal::Type::BaseModel
51
+ attr_accessor decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::decision
49
52
 
50
- attr_accessor score: Float?
53
+ attr_accessor escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::escalation
51
54
 
52
- attr_accessor version: String
55
+ attr_accessor label: String
53
56
 
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
57
+ attr_accessor score: Float?
61
58
 
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
- }
59
+ attr_accessor type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::type_
69
60
 
70
- type decision = :match | :not_match | :review
61
+ def initialize: (
62
+ decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::decision,
63
+ escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::escalation,
64
+ label: String,
65
+ score: Float?,
66
+ type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::type_
67
+ ) -> void
71
68
 
72
- module Decision
73
- extend SafetyKit::Internal::Type::Enum
69
+ def to_hash: -> {
70
+ decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::decision,
71
+ escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::escalation,
72
+ label: String,
73
+ score: Float?,
74
+ type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::type_
75
+ }
74
76
 
75
- MATCH: :match
76
- NOT_MATCH: :not_match
77
- REVIEW: :review
77
+ type decision = :match | :not_match | :review
78
78
 
79
- def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Policy::decision]
80
- end
79
+ module Decision
80
+ extend SafetyKit::Internal::Type::Enum
81
+
82
+ MATCH: :match
83
+ NOT_MATCH: :not_match
84
+ REVIEW: :review
85
+
86
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::decision]
87
+ end
88
+
89
+ type escalation = :none | :completed | :error
90
+
91
+ module Escalation
92
+ extend SafetyKit::Internal::Type::Enum
93
+
94
+ NONE: :none
95
+ COMPLETED: :completed
96
+ ERROR: :error
81
97
 
82
- type escalation = :none | :completed | :error
98
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::escalation]
99
+ end
83
100
 
84
- module Escalation
85
- extend SafetyKit::Internal::Type::Enum
101
+ type type_ = :classifier
86
102
 
87
- NONE: :none
88
- COMPLETED: :completed
89
- ERROR: :error
103
+ module Type
104
+ extend SafetyKit::Internal::Type::Enum
90
105
 
91
- def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Policy::escalation]
106
+ CLASSIFIER: :classifier
107
+
108
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Label::UnionMember0::type_]
109
+ end
92
110
  end
93
- end
94
111
 
95
- type reference_set_match = { set_id: String, similarity: Float }
112
+ type union_member1 =
113
+ {
114
+ decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::decision,
115
+ escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::escalation,
116
+ label: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::label,
117
+ score: Float,
118
+ set_id: String,
119
+ type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::type_
120
+ }
121
+
122
+ class UnionMember1 < SafetyKit::Internal::Type::BaseModel
123
+ attr_accessor decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::decision
124
+
125
+ attr_accessor escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::escalation
126
+
127
+ attr_accessor label: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::label
128
+
129
+ attr_accessor score: Float
130
+
131
+ attr_accessor set_id: String
132
+
133
+ attr_accessor type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::type_
96
134
 
97
- class ReferenceSetMatch < SafetyKit::Internal::Type::BaseModel
98
- attr_accessor set_id: String
135
+ def initialize: (
136
+ decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::decision,
137
+ escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::escalation,
138
+ label: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::label,
139
+ score: Float,
140
+ set_id: String,
141
+ type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::type_
142
+ ) -> void
99
143
 
100
- attr_accessor similarity: Float
144
+ def to_hash: -> {
145
+ decision: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::decision,
146
+ escalation: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::escalation,
147
+ label: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::label,
148
+ score: Float,
149
+ set_id: String,
150
+ type: SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::type_
151
+ }
101
152
 
102
- def initialize: (set_id: String, similarity: Float) -> void
153
+ type decision = :match | :not_match | :review
154
+
155
+ module Decision
156
+ extend SafetyKit::Internal::Type::Enum
157
+
158
+ MATCH: :match
159
+ NOT_MATCH: :not_match
160
+ REVIEW: :review
161
+
162
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::decision]
163
+ end
164
+
165
+ type escalation = :none | :completed | :error
166
+
167
+ module Escalation
168
+ extend SafetyKit::Internal::Type::Enum
169
+
170
+ NONE: :none
171
+ COMPLETED: :completed
172
+ ERROR: :error
173
+
174
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::escalation]
175
+ end
176
+
177
+ type label = :reference_set_match
178
+
179
+ module Label
180
+ extend SafetyKit::Internal::Type::Enum
181
+
182
+ REFERENCE_SET_MATCH: :reference_set_match
183
+
184
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::label]
185
+ end
186
+
187
+ type type_ = :similarity
188
+
189
+ module Type
190
+ extend SafetyKit::Internal::Type::Enum
191
+
192
+ SIMILARITY: :similarity
193
+
194
+ def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::Label::UnionMember1::type_]
195
+ end
196
+ end
103
197
 
104
- def to_hash: -> { set_id: String, similarity: Float }
198
+ def self?.variants: -> ::Array[SafetyKit::Models::ContentCreateResponse::label]
105
199
  end
106
200
  end
107
201
  end
@@ -2,11 +2,11 @@ module SafetyKit
2
2
  module Resources
3
3
  class Content
4
4
  def create: (
5
+ content: ::Array[SafetyKit::Models::ContentCreateParams::content],
5
6
  user_id: String,
6
7
  ?content_id: String,
7
- ?images: ::Array[String],
8
8
  ?metadata: ::Hash[Symbol, top?],
9
- ?text: String,
9
+ ?safety_kit_version: SafetyKit::Models::ContentCreateParams::safety_kit_version,
10
10
  ?request_options: SafetyKit::request_opts
11
11
  ) -> SafetyKit::Models::ContentCreateResponse
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safetykit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.57.0
4
+ version: 0.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Safetykit