Browse the docsImage
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.json