Add X-Max-Output-Tokens header for output truncation#1234
Open
Ratnaditya-J wants to merge 1 commit intojina-ai:mainfrom
Open
Add X-Max-Output-Tokens header for output truncation#1234Ratnaditya-J wants to merge 1 commit intojina-ai:mainfrom
Ratnaditya-J wants to merge 1 commit intojina-ai:mainfrom
Conversation
Adds a new parameter that truncates the extracted content to fit within a specified token budget. Unlike X-Token-Budget (which rejects requests that exceed the budget), this parameter returns partial content up to the limit, useful for workflows that only need the initial portion of a page.
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.
Closes #1228
This adds a new X-Max-Output-Tokens header (and corresponding maxOutputTokens body parameter) that lets callers limit how many tokens the response content contains. The content gets truncated to fit within the specified limit before being returned.
This is different from X-Token-Budget, which rejects the entire request if the cost exceeds the budget. X-Max-Output-Tokens returns partial content instead, which is what the issue author was asking for -- retrieving just the first N tokens of a page without hitting budget errors or getting the full response.
How it works: