Feat/openrouter#45
Conversation
|
Warning Review limit reached
More reviews will be available in 48 minutes and 50 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR introduces OpenRouter provider support to chat-rs, a new crate wrapping the OpenAI-compatible OpenRouter API. The implementation includes a type-state builder, two usage examples, workspace integration via feature flags, and documentation updates describing the provider's dual-wire capability and stateless behavior. ChangesOpenRouter Provider Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
ROADMAP.md (1)
46-48:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove the stale
chat-responses“planned” note.This section now contradicts both the implemented table above and the Line 23 OpenRouter description.
chat-responsesis already shipped, so keeping it here as planned makes the roadmap internally inconsistent.Suggested documentation fix
-**A planned `chat-responses` crate** will factor the OpenAI Responses API wire out of `chat-openai` the same way `chat-completions` factors Chat Completions. Providers that support both (Groq) will then be able to toggle between wire specs on the builder. +**`chat-responses`** is the shared OpenAI Responses API wire crate, factored out of `chat-openai` the same way `chat-completions` factors Chat Completions. Providers that support both wires can build on it directly.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ROADMAP.md` around lines 46 - 48, Remove the stale "planned `chat-responses` crate" sentence and update the wording to reflect that `chat-responses` has already shipped and was factored out of `chat-openai` (mirroring how `chat-completions` works); ensure the paragraph mentions that providers can toggle between wire specs (e.g., Groq) and matches the existing table and the `OpenRouter` description so the roadmap is consistent with current implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/openrouter/stream.rs`:
- Around line 33-38: The REPL loop reads stdin into user_input with
std::io::stdin().read_line(&mut user_input) but doesn't check the returned byte
count, so EOF (0 bytes) still pushes an empty message and triggers chat.stream;
modify the loop around read_line to capture the Result<usize, _>, unwrap or ?
into a variable (e.g., bytes_read), break the loop when bytes_read == 0 (EOF),
and also skip pushing blank input by checking user_input.trim().is_empty()
before calling messages.push(content::from_user(...)); update the block
containing user_input, read_line, messages.push and chat.stream accordingly.
In `@providers/openrouter/Cargo.toml`:
- Around line 21-23: The provider crate's stream feature must wire through
chat-core and include optional dependencies; update the [features] section so
the stream feature also enables "chat-core/stream" and references the optional
deps "async-stream" and "futures" (e.g. stream =
["chat-responses/stream","chat-completions/stream","chat-core/stream","async-stream","futures"]),
and add optional dependency entries for async-stream and futures in the
dependencies table (mark them optional = true) so the provider-level stream
contract is satisfied.
- Around line 12-19: Add the standard provider dependency surface to this
crate's Cargo.toml: include dependencies on async-trait, serde (with features =
["derive"]), serde_json, tools-rs, schemars, and the transport-reqwest crate
(per provider contract); also add optional dependencies for streaming support:
futures and async-stream (marked optional with appropriate features if the crate
supports streaming). Ensure these entries are placed alongside the existing
chat-core / chat-completions / chat-responses deps so the provider
(chat-openrouter) matches the other providers' manifest contract and enable any
needed features (e.g., serde derive) consistent with the workspace convention.
In `@README.md`:
- Line 75: Add OpenRouter to the Examples section of the README by inserting
entries that reference the new example files examples/openrouter/completion.rs
and examples/openrouter/stream.rs and show the correct provider name/key/builder
(OpenRouter, `openrouter`, `OPENROUTER_API_KEY`, `OpenRouterBuilder`) — update
the examples table row (the line containing the providers like "OpenRouter |
`openrouter` | `OPENROUTER_API_KEY` | `OpenRouterBuilder`") and add short
example commands or notes pointing to the two example files so users can
discover and run examples for completion and streaming.
---
Outside diff comments:
In `@ROADMAP.md`:
- Around line 46-48: Remove the stale "planned `chat-responses` crate" sentence
and update the wording to reflect that `chat-responses` has already shipped and
was factored out of `chat-openai` (mirroring how `chat-completions` works);
ensure the paragraph mentions that providers can toggle between wire specs
(e.g., Groq) and matches the existing table and the `OpenRouter` description so
the roadmap is consistent with current implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 67014c37-43b6-4057-b511-3b167f53afe1
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (10)
.env.exampleCargo.tomlREADME.mdROADMAP.mdexamples/openrouter/completion.rsexamples/openrouter/stream.rsproviders/openrouter/Cargo.tomlproviders/openrouter/README.mdproviders/openrouter/src/lib.rssrc/lib.rs
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Summary by CodeRabbit
New Features
OPENROUTER_API_KEYenvironment variableDocumentation