> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spoolpdf.nandra.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Node and PHP SDKs

> Official clients for POST /v1/render.

Exactly one of `html` or `url`. Both SDKs send the JSON body as-is, including sandbox, waits, cookies, inject, and metadata.

<Tabs>
  <Tab title="Node">
    ```bash theme={null}
    npm install @spoolpdf/sdk-node
    ```

    ```javascript theme={null}
    import { SpoolPdfClient } from "@spoolpdf/sdk-node";
    import { writeFileSync } from "node:fs";

    const client = new SpoolPdfClient({
      apiKey: process.env.SPOOLPDF_API_KEY,
    });

    const pdf = await client.render({
      html: "<h1>From Node</h1>",
      format: "A4",
      print_background: true,
    });
    writeFileSync("out.pdf", pdf);
    ```

    `renderWithMeta` also returns `requestId`, `usageCount`, and `contentType`. Local API: pass `baseUrl: "http://localhost:8080"`.
  </Tab>

  <Tab title="PHP">
    ```bash theme={null}
    composer require spoolpdf/sdk-php
    ```

    ```php theme={null}
    <?php
    require __DIR__ . '/vendor/autoload.php';

    use Spoolpdf\Sdk\Client;

    $client = new Client(getenv('SPOOLPDF_API_KEY') ?: '');
    $bytes = $client->render(['html' => '<h1>From PHP</h1>']);
    file_put_contents('out.pdf', $bytes);
    ```

    Local API: `new Client($key, 'http://localhost:8080')`.
  </Tab>
</Tabs>

Both throw on non-2xx. `401 unauthorized` means a bad or missing API key.
