Context7

Intelligent development with AI-augmented context

What is Context7?

LLMs rely on outdated or generic information about the libraries you use.

Context7 pulls up-to-date, version-specific documentation and code examples directly from the source. Paste accurate, relevant documentation directly into tools like Cursor, Claude, or any LLM. Get better answers, no hallucinations and an AI that actually understands your stack.

How to use Context7 with Scan Documents?

To use Context7 with Scan Documents, you can follow these steps:

  1. Install the Context7 MCP Server: Check out the Installation Guide for detailed instructions on how to set up the Context7 in your preferred environment.
  2. Prompt the AI: Use the context7 tool in your AI development agent to provide the necessary context. End your prompt with use context7.
Create a function that uses Scan Documents to render a pdf file. use context7
  1. AI Response: The AI will respond with a code snippet that uses the Scan Documents API to render a pdf file.

Example: Render PDF pages as images Agent response

Below is a ready-to-use TypeScript helper that calls the Scan Documents POST /v1/pdf-operations/render endpoint to rasterize (render) specific pages of a PDF into images. It returns the created task; you can poll the task (or rely on the provided callback URL) to obtain the rendered image outputs once processing completes.

/**
 * Creates a render task to convert PDF pages into images.
 * Returns the task JSON described in the API docs.
 */
export async function renderPdf({
  apiKey,
  fileId,
  pages,
  dpi = 300,
  callbackUrl,
  apiBase = "https://api.scan-documents.com",
}: {
  apiKey: string;                     // Your Scan Documents API key
  fileId: `file_${string}` | `task_${string}`; // Source file (or prior task output) id
  pages?: string;                     // Optional pages spec (e.g. "1", "1-3", "1,3,5", "1,3-5")
  dpi?: number;                       // Optional DPI (72-600, default 300)
  callbackUrl: string;                // Your webhook to receive task completion events
  apiBase?: string;                   // Override base URL for self-host / staging
}) {
  const res = await fetch(`${apiBase}/v1/pdf-operations/render`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      input: fileId,
      pages,        // optional
      dpi,          // optional, defaults to 300
      callback_url: callbackUrl,
    }),
  });

  if (!res.ok) {
    const errBody = await res.json().catch(() => undefined);
    throw new Error(`Render task failed (${res.status}): ${JSON.stringify(errBody)}`);
  }
  return res.json();
}

// Example usage:
// const task = await renderPdf({
//   apiKey: process.env.SCAN_DOCS_API_KEY!,
//   fileId: "file_avyrvozb9302uwhq",
//   pages: "1-3,5",
//   dpi: 300,
//   callbackUrl: "https://yourapp.com/webhooks/scan-documents",
// });
// console.log("Render task created:", task.id);