Skip to content

docs: wrap chat example in chatRequest - #436

Open
slegarraga wants to merge 2 commits into
OpenRouterTeam:mainfrom
slegarraga:slegarraga/fix-readme-chat-request-shape
Open

docs: wrap chat example in chatRequest#436
slegarraga wants to merge 2 commits into
OpenRouterTeam:mainfrom
slegarraga:slegarraga/fix-readme-chat-request-shape

Conversation

@slegarraga

Copy link
Copy Markdown

Summary

Fixes the README chat example so the request body is passed under chatRequest, matching the generated SDK method input shape.

Why

The current README example passes messages, model, provider, and stream directly to openRouter.chat.send(...). Issue #413 notes that the generated SDK expects those fields inside chatRequest, otherwise runtime validation rejects the call.

Validation

  • git diff --check

This is docs-only; I kept the change limited to the affected example.

Fixes #413.

perry-the-pr-reviewer[bot]

This comment was marked as outdated.

@perry-the-pr-reviewer perry-the-pr-reviewer Bot 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.

Perry's Review

Verdict: 💬 Comments / questions
Risk: 🟢 Low

Code change is LGTM, but I can only post a COMMENT here — the maintainer approval app isn't installed on OpenRouterTeam, so a human maintainer should click Approve. (No code changes requested.)

Review details

Correct docs fix. The generated Chat.send method requires a top-level chatRequest: models.ChatRequest
field on its request type, plus optional globals (httpReferer, appTitle, appCategories,
xOpenRouterMetadata). The previous README example passed messages/model/provider/stream
directly to openRouter.chat.send(...), which the Zod outbound schema rejects at runtime (and
TypeScript flags) since those fields belong on chatRequest, not on the request root. Wrapping
them inside chatRequest matches the SDK input shape, and the stream: true overload lines up
with the for await consumption below it. The chatRequest schema itself carries messages
(required array), model (optional string), provider (optional), and stream (boolean,
default false), so every field in the updated example is valid.

Risk assessment:

Dimension Severity Risk Reasoning
Implementation risk 🟩 Low Docs-only; the wrapping now matches the generated method signature exactly.
Premise risk 🟩 Low The premise (direct-pass is invalid) is independently verifiable from the SDK source.
Estimated impact 🟩 Low Worst case is a misleading README example; no runtime/code impact.
Risk Factor Severity Risk Reasoning
Reversibility 🟩 Low One-line markdown revert.
Detectability 🟩 Low A bad example surfaces immediately to any user who copies it.
Blast radius 🟩 Low A single docs file; no code, config, or data path is touched.
Data integrity None No persisted state is touched.
Financial exposure None No billing/accounting outcome affected.
Security and privacy exposure None No secrets, auth, or tenant-isolation surface.
Propagation 🟩 Low Only README readers; nothing downstream reads this output.
Availability None Cannot affect serving.
Recovery cost 🟩 Low Trivial markdown edit.
Time to correct 🟩 Low Noticed and fixed in one pass.

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.

README example uses incorrect input shape

1 participant