feat: add temperature and other common settings to model-level configuration - #388
Merged
Merged
Conversation
|
ah, this is gonna be awesome to have. ty! |
…uration Fixes #387 This change adds support for setting default values for common model parameters at the model creation level: - temperature - topP - topK - frequencyPenalty - presencePenalty - maxTokens These settings can be overridden at call time via generateText/streamText options. Example: ```typescript const model = openrouter('google/gemini-3-flash-preview', { temperature: 0, topP: 0.9, maxTokens: 100, }); ``` Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
robert-j-y
force-pushed
the
devin/1769809800-issue-387-temperature-settings
branch
from
April 15, 2026 21:18
0eb69f3 to
89d7000
Compare
Merged
robert-j-y
added a commit
that referenced
this pull request
Apr 26, 2026
…eaming, and #413 reasoning-delta metadata fix Restores four pieces of behavior that were inadvertently removed when the empty reasoning_details fix was applied: - #419: Defensive usage fallback in stream finish handler that copies openrouterUsage promptTokens/completionTokens into usage.inputTokens.total /outputTokens.total when the standard fields are still undefined after computeTokenUsage(). - #388: Model-level settings fallbacks (?? this.settings.X) for max_tokens, temperature, top_p, frequency_penalty, presence_penalty, top_k. - #443: eager_input_streaming forwarding from tool providerOptions to the function tool request body. - #413: Stop attaching accumulated reasoning_details snapshots to reasoning-start/reasoning-delta events to avoid payload bloat. The always-include behavior remains on reasoning-end and the stream finish event, which is the only place opencode-style consumers read it from. Keeps the legitimate empty reasoning_details fix in place so DeepSeek V4 and similar providers continue to receive the empty array on follow-up turns. Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai>
robert-j-y
added a commit
that referenced
this pull request
Apr 26, 2026
…ons (#487) * fix: preserve empty reasoning_details arrays in multi-turn conversations Always include reasoning_details in finish event metadata and reasoning-end providerMetadata, even when the accumulated array is empty. DeepSeek V4 and similar providers require the field to be sent back in subsequent turns to maintain conversation state. * fix: treat empty reasoning_details array as explicit metadata signal Replace length>0 checks with Array.isArray checks so that an explicit [] from message-level providerOptions is treated as 'metadata present but empty' rather than 'metadata absent'. Preserve [] through dedup/signature-filter path. * test(perry): update assertions for empty reasoning_details preservation * test(perry): update signature-roundtrip assertions for empty reasoning_details * test(perry): update stream usage accounting assertion for reasoning_details * test(perry): update doStream finish event snapshots for reasoning_details * chore(perry): add patch changeset for empty reasoning_details fix * fix: restore #419 usage fallback, settings fallbacks, eager_input_streaming, and #413 reasoning-delta metadata fix Restores four pieces of behavior that were inadvertently removed when the empty reasoning_details fix was applied: - #419: Defensive usage fallback in stream finish handler that copies openrouterUsage promptTokens/completionTokens into usage.inputTokens.total /outputTokens.total when the standard fields are still undefined after computeTokenUsage(). - #388: Model-level settings fallbacks (?? this.settings.X) for max_tokens, temperature, top_p, frequency_penalty, presence_penalty, top_k. - #443: eager_input_streaming forwarding from tool providerOptions to the function tool request body. - #413: Stop attaching accumulated reasoning_details snapshots to reasoning-start/reasoning-delta events to avoid payload bloat. The always-include behavior remains on reasoning-end and the stream finish event, which is the only place opencode-style consumers read it from. Keeps the legitimate empty reasoning_details fix in place so DeepSeek V4 and similar providers continue to receive the empty array on follow-up turns. Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai> * test: restore deleted #419/eager_input_streaming/#413 test coverage Restores the seven tests that were inadvertently deleted along with the empty reasoning_details fix and flips the reasoning-start/reasoning-delta providerMetadata assertions back to toBeUndefined() to lock in the restored #413 behavior. - 3 tests for eager_input_streaming forwarding from tool providerOptions. - 4 tests for the #419 defensive usage fallback in the stream finish handler. - Adjusts the two streaming reasoning_details tests to assert that reasoning-start and reasoning-delta events do NOT carry providerMetadata (the snapshot is exposed only on reasoning-end and the finish event). Co-Authored-By: Robert Yeakel <robert.yeakel@openrouter.ai> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Robert Yeakel <robert.yeakel@openrouter.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #387
Adds support for setting default values for common model parameters at model creation time. Previously, settings like
temperaturecould only be passed at call time viagenerateText/streamText. Now users can set defaults when creating the model:Call-level options still override model-level settings when provided.
New settings added to
OpenRouterSharedSettings:temperature- Controls randomness (0-2)topP- Nucleus sampling (0-1)topK- Top-k samplingfrequencyPenalty- Penalize repeated tokens (-2 to 2)presencePenalty- Penalize tokens based on presence (-2 to 2)maxTokens- Maximum tokens to generateKey areas for review:
??) is used so call-levelundefinedfalls back to model settings, but explicit values always wintemperaturesettings inOpenRouterChatSettings. (Missing) #387Checklist
pnpm stylecheckandpnpm typecheckpnpm testand all tests passChangeset
pnpm changesetto create a changeset fileLink to Devin run: https://app.devin.ai/sessions/ad14476ac9334b8a962f771f56e48975
Requested by: Robert Yeakel (@robert-j-y)