Browse the docsDefault

Image

POSThttps://labs-api.petpooja.com/v1/extract/chat/completions

Identical wire format to OpenWorld - so the OpenAI SDK works unchanged, just with base_url set to …/v1/extract. The difference is server-side: your text and system messages are discarded and the fixed extraction prompt runs against each image on its own.

Text is ignored

Sending "text": "only give me the invoice number" here does nothing - it is dropped before inference. If you need instruction-guided output, use OpenWorld.

import base64, mimetypes
from openai import OpenAI

API_KEY  = "Your API Key"
BASE_URL = "https://labs-api.petpooja.com/v1/extract"
MODEL    = "chitragupta"

client = OpenAI(api_key=API_KEY, base_url=BASE_URL)

IMAGE_PATH = "<IMAGE_PATH>"

mime = mimetypes.guess_type(IMAGE_PATH)[0] or "image/jpeg"
img_b64 = base64.b64encode(open(IMAGE_PATH, "rb").read()).decode()
image_data_uri = f"data:{mime};base64,{img_b64}"

response = client.chat.completions.create(
  model=MODEL,
  messages=[{
    "role": "user",
    "content": [
      {"type": "text", "text": ""},
      {"type": "image_url", "image_url": {"url": image_data_uri}},
    ],
  }],
)
print(response)

PDF

POSThttps://labs-api.petpooja.com/v1/extract/chat/completions

Each page of each PDF becomes its own model call, dispatched concurrently, and the per-page results are concatenated in order. A large batch costs roughly the wall-clock of a single page, and one unreadable page never poisons the rest of the document.

Fan-out limit

LimitValueOn breach
Pages + images per request25413 page_limit_exceeded
import base64
from openai import OpenAI

API_KEY  = "Your API Key"
BASE_URL = "https://labs-api.petpooja.com/v1/extract"
MODEL    = "chitragupta"

client = OpenAI(api_key=API_KEY, base_url=BASE_URL)

PDF_PATH = "<PDF_PATH>"

pdf_b64 = base64.b64encode(open(PDF_PATH, "rb").read()).decode()
pdf_data_uri = f"data:application/pdf;base64,{pdf_b64}"

response = client.chat.completions.create(
  model=MODEL,
  messages=[{
    "role": "user",
    "content": [
      {"type": "text", "text": "Extract the invoice information from this document as JSON."},
      {"type": "file", "file": {"filename": "invoice.pdf", "file_data": pdf_data_uri}},
    ],
  }],
)

print(response)

Model response

Both endpoints return a standard chat.completion object. Default packs its per-page results into the single assistant message, each block prefixed with its source tag so you can trace any extracted value back to the exact page it came from.

FieldTypeDescription
idstringCompletion id.
modelstringAlways the logical name chitragupta. The underlying provider is never exposed.
choices[0].message.contentstringThe extracted content. For Default, blocks tagged pdf1_page1:, image1:, in request order.
choices[0].finish_reasonstringstop - the model finished. length - output was cut short at a token limit.
usageobjectprompt_tokens, completion_tokens, total_tokens - reported for observability. Billing is per page.
finish_reason: length

Because max_tokens already defaults to the 40000 ceiling, a length finish almost always means the context window filled up, not the output cap. Raising max_tokens will not fix it - send fewer pages per request.


request_id   : "value"
usage        : CompletionUsage(completion_tokens="value", prompt_tokens="value", total_tokens="value")
==============================================================================
pdf1_page1: ```json
{"SELLER_DETAILS":{"COMPANY_NAMES" : ["Acme Corp"],"ADDRESS": ["123 Business Rd, Tech Park, New Delhi-110001, India", "Acme...
```

pdf1_page2: ```json
{"SELLER_DETAILS":{"COMPANY_NAMES" : ["Acme Corp"],"ADDRESS": ["123 Business Rd, Tech Park, New Delhi-110001, India", "Acme...
```

pdf1_page3: ```json
{"SELLER_DETAILS":{"COMPANY_NAMES" : ["Acme Corp"],"ADDRESS": ["123 Business Rd, Tech Park, New Delhi-110001, India", "Acme...
```

...