Browse the docsReference
Parameters
Every tuning parameter is optional. Send one and your value is used after validation; omit it, or send null, and the deployment default applies. Omission never means “send nothing” - it means “use the default”.
| Parameter | Default | Accepted range | Forwarded | Notes |
|---|---|---|---|---|
| max_tokensinteger | 40000 | 1 - 40000 | yes | The cap equals the default, so 40000 is both the fallback and the maximum. Asking for more is a 422, not a silent clamp. |
| temperaturenumber | 0 | 0 - 2 | yes | Leave it at 0 for extraction. Higher values make the model paraphrase fields instead of copying them. |
| top_pnumber | - | - | ignored | Accepted so OpenAI SDKs do not break. Has no effect. |
| reasoning_effortstring | - | - | ignored | An OpenAI reasoning-tier concept that does not apply to this model. |
| streamboolean | false | - | ignored | Responses are always returned whole. true is treated as false. |
Any field we do not recognise is dropped at the edge rather than rejected, so a newer OpenAI SDK will not break against this API - and arbitrary client input never reaches the model.
import os
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)
r = client.chat.completions.create(
model=MODEL,
messages=[{"role": "user", "content": "Extract this invoice as JSON."}],
temperature=0, # 0..2 (omit -> default 0)
max_tokens=200, # 1..40000 (omit -> default 40000)
)Limits
Rate limits apply per API key. Everything else is a per-request structural limit, enforced at the edge before any inference is billed.
| Limit | OpenWorld | Default |
|---|---|---|
| Pages + images per request | 10 | 25 |
| Model calls per request | 1all pages together | 1 per pagerun concurrently |
| Your text instructions | passed text | ignored |
| Output structure | Based on your prompt | Fixed schema, tagged per page |
| Max tokens | 40,000 | 40,000 |
| Requests per second | 10 | 10 |
| Requests running at the same timehow many of your calls we process in parallel | 20 | 20 |
Compress scans to JPEG before encoding - it is the single cheapest latency win available to you.
Error codes
Every failure returns the same envelope: a stable machine-readable code, a human-safe message, and the request_id to quote in a support ticket. Branch on code, never on the message text.
| HTTP | Code | What went wrong | How to fix it |
|---|---|---|---|
| 401 | invalid_api_key | Missing, malformed, or revoked key, or an inactive account. | Fix or replace the key. |
| 402 | insufficient_credits | The account is out of credits. | Top up, then resend. |
| 403 | permission_denied | This key is not allowed to perform the action. | Check the key's scope and workspace. |
| 404 | model_not_found | Unknown model name in the request. | Use chitragupta. |
| 405 | method_not_allowed | Wrong HTTP method for this route. | All completion routes are POST. |
| 409 | idempotency_conflict | An Idempotency-Key was reused with a different body. | Use a new key, or resend the exact original body. |
| 413 | file_too_large | The uploaded file exceeds the size limit. | Compress the file before encoding. |
| 413 | page_limit_exceeded | Too many pages and images combined. | Split into smaller requests. |
| 422 | invalid_request | Malformed body, or max_tokens above the cap. | Fix the payload. |
| 422 | system_message_not_allowed | A system message was sent; the model uses a fixed prompt. | Move the instruction into the user message. |
| 422 | images_not_allowed | An image was sent to a text-only model. | Use a vision-capable model. |
| 429 | rate_limit_exceeded | Too many requests per second, or too many in flight on this key. | Honor the Retry-After header. |
| 429 | quota_exceeded | The key or account hit its usage quota. | Wait for the reset or raise the quota. |
| 500 | internal_error | Unexpected server-side failure. | Retry with exponential backoff. |
| 502 | inference_failed | The model returned an invalid response. | Retry once; if it persists, log the request_id. |
| 503 | provider_unavailable | Inference capacity is temporarily unavailable. | Retry with exponential backoff. |
| 504 | inference_timeout | The model took too long. | Retry with backoff, or send fewer pages. |
# See the request_id even on an error:
try:
r = client.chat.completions.create(model=MODEL, messages=[{"role": "user", "content": "hi"}])
print(r.id.replace("chatcmpl-", ""))
except Exception as e:
print(type(e).__name__, getattr(e, "status_code", "?"), getattr(e, "body", None))