Browse the docsImage
Image
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.
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)import fs from "node:fs";
const API_KEY = "Your API Key";
const BASE_URL = "https://labs-api.petpooja.com/v1/extract/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/extract/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/extract/chat/completions"
IMAGE="<IMAGE_PATH>"
IMAGE_URI="data:image/jpeg;base64,$(base64 -w0 "$IMAGE")"
cat > /tmp/pp_extract_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_extract_image.json