Skip to content

Forward user headers#24

Merged
Wauplin merged 3 commits intomainfrom
forward-headers
Aug 6, 2025
Merged

Forward user headers#24
Wauplin merged 3 commits intomainfrom
forward-headers

Conversation

@Wauplin
Copy link
Copy Markdown
Collaborator

@Wauplin Wauplin commented Aug 6, 2025

cc @SBrandeis

Headers from the user are forwarded to the chat completion API.

Only a few ones are not forwarded:

  • accept, accept-encoding => will be added by openai JS SDK
  • authorization => handled separately
  • connection => we always want to be "keep-alive" for streaming => done by openai SDK
  • content-length / content-type => forwarded content is not the same, hence doesn't make sense to forward these
  • host => not the same host

This will be useful in particular to forward X-HF-Bill-To

@Wauplin Wauplin requested a review from SBrandeis August 6, 2025 12:42
Copy link
Copy Markdown
Collaborator

@SBrandeis SBrandeis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

Comment thread src/routes/responses.ts Outdated
Comment on lines +38 to +47
// All headers are forwarded by default, except these ones.
const NOT_FORWARDED_HEADERS = [
"accept",
"accept-encoding",
"authorization",
"connection",
"content-length",
"content-type",
"host",
];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) could be a Set for O(1) include test

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in f8ae968

@Wauplin Wauplin merged commit 9c10ace into main Aug 6, 2025
1 check passed
@Wauplin Wauplin deleted the forward-headers branch August 6, 2025 12:51
Wauplin added a commit that referenced this pull request Aug 6, 2025
Wauplin added a commit that referenced this pull request Aug 6, 2025
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.

2 participants