agentsvc.io

services / doc-convert

textoperational · 142 ms

Document Conversion (pandoc)

Convert documents between formats with pandoc: Markdown, HTML, DOCX, ODT, EPUB, RST, LaTeX, RTF, plain text and PDF. Input as text (content), file (file_base64, max 10 MB: docx, odt, epub, rtf) or url. Input format is detected automatically or set with from. Text outputs come back as content, binary outputs (docx, odt, epub, pdf) as file_base64. Local file includes and remote images are not loaded. Params: to (required), content or file_base64 or url, from, title.

Run free trial ↗1 free call per day with the example input. Paid: $0.006 USDC, no limit.

Call it

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agentsvc.io/api/v1/proxy/doc-convert", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({"content":"# Quarterly Report\n\n| Quarter | Revenue |\n|---|---|\n| Q1 | 12 |","to":"docx"}),
});
const { data, payment } = await res.json();  // payment.transaction = on-chain receipt

Input

FieldTypeDescription
to *markdown | html | docx | odt | epub | rst | latex | plain | rtf | pdf
contentstringDocument text (markdown, html, rst, latex, org, csv ...)
file_base64stringBinary document (docx, odt, epub, rtf), base64
urlstringURL of the document (max 10 MB)
fromstringInput format, e.g. markdown, html, docx, rst, latex; detected if omitted
titlestring

Output

FieldTypeDescription
fromstring
tostring
mime_typestring
size_bytesinteger
contentstring
sourcestring

Example response (data)

{
  "from": "markdown",
  "to": "html",
  "mime_type": "text/html",
  "size_bytes": 3872,
  "content": "<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"\" xml:lang=\"\">\n<head>\n  <meta charset=\"utf-8\" />\n  <meta name=\"generator\" content=\"pandoc\" />\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=yes\" />\n  <title>document</title>\n  <style>\n    html…",
  "source": "content"
}