Skip to content

feat(agent): support capping OpenRouter output tokens - #590

Open
pawel-twardziak wants to merge 1 commit into
langchain-ai:mainfrom
pawel-twardziak:fix/openrouter-max-tokens-override
Open

feat(agent): support capping OpenRouter output tokens#590
pawel-twardziak wants to merge 1 commit into
langchain-ai:mainfrom
pawel-twardziak:fix/openrouter-max-tokens-override

Conversation

@pawel-twardziak

Copy link
Copy Markdown

via OPENWIKI_OPENROUTER_MAX_TOKENS

Without an explicit max_tokens, OpenRouter's credit pre-check budgets for the model's full advertised output ceiling and rejects requests with 402 when the balance cannot cover that worst case. Let users cap per-request output tokens with a validated env var, following the existing OPENWIKI_OPENROUTER_PROVIDER_ONLY pattern.

Fixes #588

…ENROUTER_MAX_TOKENS

Without an explicit max_tokens, OpenRouter's credit pre-check budgets for
the model's full advertised output ceiling and rejects requests with 402
when the balance cannot cover that worst case. Let users cap per-request
output tokens with a validated env var, following the existing
OPENWIKI_OPENROUTER_PROVIDER_ONLY pattern.

Fixes langchain-ai#588

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012eivpomJ5GqQU6HwcYgb3b
@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3662576

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openwiki Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

Support overriding max_tokens for OpenRouter models

1 participant