docs: wrap chat example in chatRequest - #436
Conversation
There was a problem hiding this comment.
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. |
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, andstreamdirectly toopenRouter.chat.send(...). Issue #413 notes that the generated SDK expects those fields insidechatRequest, otherwise runtime validation rejects the call.Validation
git diff --checkThis is docs-only; I kept the change limited to the affected example.
Fixes #413.