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

# Structured Extraction

> Extract structured JSON from images, documents, audio, and video with the classic generate API.

Use the [Generate](/api-reference/v1/post-image-generate) endpoints to extract structured JSON from images, documents, audio, and video.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  from pathlib import Path
  from vlmrun.client import VLMRun
  from vlmrun.client.types import PredictionResponse

  # Initialize the client
  client = VLMRun(api_key="<VLMRUN_API_KEY>")

  # Document -> JSON
  response: PredictionResponse = client.document.generate(
      file=Path("path/to/document.pdf"),
      model="vlm-1",
      domain="document.invoice",
  )
  ```

  ```javascript Node.js theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  import { VLMRun } from "vlmrun";

  // Initialize the client
  const client = new VLMRun({
      apiKey: "<VLMRUN_API_KEY>",
  });

  // Upload a document
  const file = await client.files.upload({
    filePath: "path/to/invoice.pdf",
  });

  // Process a document using file ID
  const response = await client.document.generate({
    fileId: file.id,
    model: "vlm-1",
    domain: "document.markdown",
  });
  console.log(response);
  ```

  ```bash CLI theme={"theme":{"light":"github-light","dark":"dark-plus"}}
  vlmrun generate -i path/to/document.pdf --domain document.invoice
  ```
</CodeGroup>

## Related

<CardGroup cols={2}>
  <Card title="Image → JSON" icon="image" href="/api-reference/v1/post-image-generate?legacy=1">
    Extract structured JSON from an image.
  </Card>

  <Card title="Doc → JSON" icon="file-lines" href="/api-reference/v1/post-document-generate?legacy=1">
    Extract structured JSON from a document.
  </Card>

  <Card title="Audio → JSON" icon="microphone" href="/api-reference/v1/post-audio-generate?legacy=1">
    Extract structured JSON from audio.
  </Card>

  <Card title="Video → JSON" icon="video" href="/api-reference/v1/post-video-generate?legacy=1">
    Extract structured JSON from video.
  </Card>

  <Card title="Get Prediction by ID" icon="magnifying-glass" href="/api-reference/v1/predictions/get-predictions-by-id?legacy=1">
    Fetch the result of a generate request.
  </Card>

  <Card title="Get Predictions" icon="list" href="/api-reference/v1/predictions/get-predictions-list?legacy=1">
    List your generate requests.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.