Class: ReductoAI::Resources::Parse
- Inherits:
-
Object
- Object
- ReductoAI::Resources::Parse
- Defined in:
- lib/reducto_ai/resources/parse.rb
Overview
Each parse operation consumes credits based on document complexity. See Reducto documentation for pricing details.
Parse resource for document parsing operations.
Converts documents (PDFs, images, etc.) into structured formats like Markdown, JSON, or HTML. Supports both synchronous and asynchronous modes.
Instance Method Summary collapse
-
#async(input:, async: nil, **options) ⇒ Hash
Parses a document asynchronously.
-
#initialize(client) ⇒ Parse
constructor
private
A new instance of Parse.
-
#sync(input:, **options) ⇒ Hash
Parses a document synchronously.
Constructor Details
#initialize(client) ⇒ Parse
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 Parse.
34 35 36 |
# File 'lib/reducto_ai/resources/parse.rb', line 34 def initialize(client) @client = client end |
Instance Method Details
#async(input:, async: nil, **options) ⇒ Hash
Parses a document asynchronously.
Returns immediately with a job_id. Poll with Jobs#retrieve to get results.
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/reducto_ai/resources/parse.rb', line 101 def async(input:, async: nil, **) raise ArgumentError, "input is required" if input.nil? normalized_input = normalize_input(input) payload = { input: normalized_input } payload[:async] = async unless async.nil? payload.merge!(.compact) @client.post("/parse_async", payload) end |
#sync(input:, **options) ⇒ Hash
Parses a document synchronously.
Blocks until parsing completes and returns the full result.
66 67 68 69 70 71 72 |
# File 'lib/reducto_ai/resources/parse.rb', line 66 def sync(input:, **) raise ArgumentError, "input is required" if input.nil? normalized_input = normalize_input(input) payload = { input: normalized_input, ** }.compact @client.post("/parse", payload) end |