@@ -357,8 +357,8 @@ public function textGeneration(array $messages, string $model): array
357357 * @throws \RuntimeException
358358 * **/
359359
360- public function imageToText (string $ imageUrl , string $ requestQuery ): array
361- {
360+ public function imageToText (string $ imageUrl , string $ requestQuery ): array
361+ {
362362 try {
363363 $ payload = [
364364 'image_url ' => $ imageUrl ,
@@ -370,13 +370,36 @@ public function imageToText(string $imageUrl, string $requestQuery): array
370370 ]);
371371
372372 return $ this ->decodeResponse ($ response );
373-
374373 } catch (\JsonException $ e ) {
375374 throw new \RuntimeException ("Failed to encode messages: " . $ e ->getMessage ());
376375 } catch (GuzzleException $ e ) {
377376 throw new \RuntimeException ("Failed to extract text: " . $ e ->getMessage ());
378377 }
379378 }
380379
380+ /**
381+ * Convert a resource (file, web, image) to Markdown
382+ *
383+ * @param string $resource The resource URL (file, web page, or image)
384+ * @param string $resourceType The type of resource: "file", "web", or "image"
385+ * @return array<string, mixed> Response from the API containing response, tokens, and success status
386+ * @throws \RuntimeException
387+ */
388+ public function markdownConverter (string $ resource , string $ resourceType ): array
389+ {
390+ try {
391+ $ payload = [
392+ 'link ' => $ resource ,
393+ 'resource_type ' => $ resourceType ,
394+ ];
395+
396+ $ response = $ this ->client ->post ('/v2/markdown-converter/ ' , [
397+ 'json ' => $ payload ,
398+ ]);
381399
400+ return $ this ->decodeResponse ($ response );
401+ } catch (GuzzleException $ e ) {
402+ throw new \RuntimeException ("Failed to convert resource to Markdown: " . $ e ->getMessage ());
403+ }
404+ }
382405}
0 commit comments