@printwithsynergy/codex-client
v1.21.1
Published
TypeScript client for the codex-pdf HTTP API + cross-stack shared utilities (RFC 7807 Problem Details). Mirrors the Python codex_pdf.client surface.
Readme
@printwithsynergy/codex-client
TypeScript client for the codex-pdf
HTTP API. Mirrors codex_pdf.client.HttpClient (Python).
Install
npm install @printwithsynergy/codex-clientUsage
import { HttpClient } from "@printwithsynergy/codex-client";
const codex = new HttpClient({
baseUrl: process.env.CODEX_API_BASE,
bearerToken: process.env.CODEX_BEARER_TOKEN,
});
const png = await codex.renderPage(pdfBytes, { page: 1, dpi: 300 });
const seps = await codex.renderSeparations(pdfBytes, { page: 1 });
const sample = await codex.sampleDensity(pdfBytes, { x: 100, y: 200 });Standard data request — requestAsset
The one call every consumer should use to fetch a PDF's facts. Cache hit returns the document inline in one round-trip; miss pulls it in the background (speculator) and polls until it lands. Repeat requests for the same PDF are served from codex's cache — no re-extract.
const asset = await codex.requestAsset(pdfBytes, { pollMs: 1500, timeoutMs: 60_000 });
if (asset.status === "complete") {
useDocument(asset.document);
}
// By hash, once the bytes have been uploaded once:
const again = await codex.requestAsset({ sha256 });
// Lower-level: ingestAsset / getAsset / getAssetSignals.See the canonical data-requests.md for the full contract, response shapes, and the viewer backfill pattern.
The client supports CODEX_API_BASE, CODEX_BEARER_TOKEN,
CODEX_API_KEY, CODEX_INTERNAL_TOKEN, and CODEX_TIMEOUT_MS from
the environment when the matching options aren't passed.
There is no local fallback: codex byte-level work happens
server-side. Construct the client with baseUrl set to your codex
deployment URL and let the typed methods do the rest.
