Browse the docsOpenWorld
Image
Send the image as a base64 data URI inside an image_url content part, alongside a text part describing the output you want. The text part is what makes this endpoint OpenWorld - ask for JSON with seller, buyer and line items, and that is what you get back.
Request body
| Field | Type | Description |
|---|---|---|
| model | stringrequired | Must be chitragupta. Anything else returns 404 model_not_found. |
| messages | arrayrequired | Roles user and assistant only. A system message returns 422 system_message_not_allowed - the system prompt is owned server-side so behaviour stays consistent for every caller. |
| messages[].content[] | arrayrequired | Mix of text parts and image_url parts. Each image_url.url is a data URI: data:image/jpeg;base64,…. Up to 10 images per request. |
| max_tokens | integer | Optional. Defaults to 40000, which is also the ceiling. |
import base64, mimetypes
from openai import OpenAI
API_KEY = "Your API Key"
BASE_URL = "https://labs-api.petpooja.com/v1/"
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)import fs from "node:fs";
const API_KEY = "Your API Key";
const BASE_URL = "https://labs-api.petpooja.com/v1/chat/completions";
const image = fs.readFileSync("<IMAGE_PATH>").toString("base64");
const res = await fetch(`${BASE_URL}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_KEY}`,
},
body: JSON.stringify({
model: "chitragupta",
messages: [{
role: "user",
content: [
{ type: "text", text: "Extract the invoice information as JSON." },
{ type: "image_url", image_url: { url: `data:image/jpeg;base64,${image}` } },
],
}],
}),
});
const data = await res.json();
console.log(data.choices[0].message.content);package main
import (
"encoding/base64"
"fmt"
"io"
"net/http"
"os"
"strings"
)
const (
key = "Your API Key"
url = "https://labs-api.petpooja.com/v1/chat/completions"
model = "chitragupta"
path = "<IMAGE_PATH>"
)
func main() {
data, err := os.ReadFile(path)
if err != nil {
panic(err)
}
b64 := base64.StdEncoding.EncodeToString(data)
body := fmt.Sprintf(`{"model":"%s","messages":[{"role":"user","content":[
{"type":"text","text":"Extract the invoice information from this image as JSON."},
{"type":"image_url","image_url":{"url":"data:image/jpeg;base64,%s"}}
]}]}`, model, b64)
req, _ := http.NewRequest("POST", url, strings.NewReader(body))
req.Header.Set("Authorization", "Bearer "+key)
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode)
fmt.Println(string(out))
}KEY="Your API Key"
BASE="https://labs-api.petpooja.com/v1/chat/completions"
IMAGE="<IMAGE_PATH>"
IMAGE_URI="data:image/jpeg;base64,$(base64 -w0 "$IMAGE")"
cat > /tmp/pp_chat_image.json <<EOF
{
"model": "chitragupta",
"max_tokens": 4000,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Extract all visible text and details from this image."
},
{
"type": "image_url",
"image_url": {
"url": "$IMAGE_URI",
"detail": "high"
}
}
]
}
]
}
EOF
curl -s -i "$BASE" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d @/tmp/pp_chat_image.jsonSend the PDF as a base64 data URI inside a file content part. Every page is rendered to an image server-side and sent to the model in a single call, so the model can reason across pages - carry-forward totals, continuation tables, a summary on page 3 that refers to page 1.
Rendered PDF pages and loose images share one budget of 10 per request. A 7-page PDF leaves room for 3 images. Exceed it and the request returns 413 page_limit_exceeded - split it, or use Default, which allows 25.
Request body
| Field | Type | Description |
|---|---|---|
| model | stringrequired | Must be chitragupta. |
| file.file_data | stringrequired | Data URI of the PDF: data:application/pdf;base64,…. |
| file.filename | string | Optional label echoed into logs. Useful when you send more than one document. |
import base64
from openai import OpenAI
API_KEY = "Your API Key"
BASE_URL = "https://labs-api.petpooja.com/v1/"
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)import fs from "node:fs";
const apiKey = "Your API Key";
const baseURL = "https://labs-api.petpooja.com/v1/chat/completions";
const model = "chitragupta";
const pdfPath = "<PDF_PATH>";
async function main() {
const b64 = fs.readFileSync(pdfPath).toString("base64");
const body = {
model,
messages: [{
role: "user",
content: [
{ type: "text", text: "Extract information of last page from this document as JSON." },
{ type: "file", file: { filename: "invoice.pdf", file_data: `data:application/pdf;base64,${b64}` } }
]
}]
};
const res = await fetch(baseURL, {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify(body)
});
console.log("HTTP Status:", res.status);
console.log(await res.text());
}
main();package main
import (
"encoding/base64"
"fmt"
"io"
"net/http"
"os"
"strings"
)
const (
apiKey = "Your API Key"
baseURL = "https://labs-api.petpooja.com/v1/chat/completions"
model = "chitragupta"
pdfPath = "<PDF_PATH>"
)
func main() {
data, err := os.ReadFile(pdfPath)
if err != nil {
panic(err)
}
b64 := base64.StdEncoding.EncodeToString(data)
body := fmt.Sprintf(`{"model":"%s","messages":[{"role":"user","content":[
{"type":"text","text":"Extract information of last page from this document as JSON."},
{"type":"file","file":{"filename":"invoice.pdf","file_data":"data:application/pdf;base64,%s"}}
]}]}`, model, b64)
req, _ := http.NewRequest("POST", baseURL, strings.NewReader(body))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println("HTTP Status:", res.StatusCode)
fmt.Println(string(out))
}KEY="Your API Key"
BASE="https://labs-api.petpooja.com/v1/chat/completions"
PDF="<PDF_PATH>"
PDF_URI="data:application/pdf;base64,$(base64 -w0 "$PDF")"
cat > /tmp/pp_chat_pdf.json <<EOF
{
"model": "chitragupta",
"max_tokens": 8000,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Extract all details from this document and return the extracted information."
},
{
"type": "file",
"file": {
"file_data": "$PDF_URI",
"filename": "document.pdf"
}
}
]
}
]
}
EOF
curl -s -i "$BASE" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d @/tmp/pp_chat_pdf.json