Skip to content

docs(ocr): fix Python snippets for client.post - #169

Merged
swapnilroy-cell merged 1 commit into
masterfrom
fix/ocr-python-snippets
Nov 6, 2026
Merged

swapnilroy-cell merged 1 commit into
masterfrom
fix/ocr-python-snippets

Conversation

@swapnilroy-cell

Copy link
Copy Markdown

Fixes both Python tabs (Default and Self-Hosted) under /ocr.

  • client.post(url, **kwargs) sends every kwarg except files, headers and stream as the JSON body, so body={...} was sent as {"body": {...}}. Fields are now passed as keyword arguments.
  • The response is a pydantic GenericResponse and is not subscriptable, so response["pages"] raised TypeError. Now uses response.pages.

The /rerank Python samples already use keyword arguments. Companion docs-core fix is on branch fix/ocr-python-snippets in Portkey-AI/docs-core.

- Pass fields as keyword arguments instead of body={...}, which the SDK
  wraps again and sends as {"body": {...}}
- Use response.pages; GenericResponse is not subscriptable

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the OCR Python example corrections.

No open issues 🎉

What changed in this PR

Corrects the Default and Self-Hosted Python examples for /ocr to match the client’s request and response handling.

Changes:

  • Passes request fields directly as keyword arguments instead of nesting them under body.
  • Uses response.pages to access pages on the response object.
File Description
openapi.yaml Fixes request construction and response access in both OCR Python examples.

Review effort: Balanced

@swapnilroy-cell
swapnilroy-cell merged commit 54aeff6 into master Nov 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants