Class: SafetyKit::Resources::Content
- Inherits:
-
Object
- Object
- SafetyKit::Resources::Content
- Defined in:
- lib/safety_kit/resources/content.rb,
sig/safety_kit/resources/content.rbs
Overview
Classify user-authored text and images synchronously and receive a decision in the response.
Instance Method Summary collapse
-
#create(content:, user_id:, content_id: nil, metadata: nil, safety_kit_version: nil, request_options: {}) ⇒ SafetyKit::Models::ContentCreateResponse
Some parameter documentations has been truncated, see Models::ContentCreateParams for more details.
-
#initialize(client:) ⇒ Content
constructor
private
A new instance of Content.
Constructor Details
#initialize(client:) ⇒ Content
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Content.
56 57 58 |
# File 'lib/safety_kit/resources/content.rb', line 56 def initialize(client:) @client = client end |
Instance Method Details
#create(content:, user_id:, content_id: nil, metadata: nil, safety_kit_version: nil, request_options: {}) ⇒ SafetyKit::Models::ContentCreateResponse
Some parameter documentations has been truncated, see Models::ContentCreateParams for more details.
Classify a piece of content synchronously. Send text and image parts and receive per-label results in the response. Any metadata you send is echoed back on the response, so a decision can be matched to your own request without a side lookup. Requests have a maximum size of 6MB. API version 2026-08-11; see the API versioning guide for superseded versions.
Errors: 400 for an invalid body or images, with the failing field in the message. 401 for a missing or invalid API key. 413 for requests over 6MB. 429 when too many requests are in flight for your account, with a Retry-After header. 503 when classification is temporarily unavailable. In both cases the request was not processed and is safe to retry.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/safety_kit/resources/content.rb', line 40 def create(params) parsed, = SafetyKit::ContentCreateParams.dump_request(params) header_params = {safety_kit_version: "safetykit-version"} @client.request( method: :post, path: "v1/content", headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: SafetyKit::Models::ContentCreateResponse, options: ) end |