Skip to content

Conversation

@andrewshu2000
Copy link
Contributor

@andrewshu2000 andrewshu2000 commented Jun 30, 2025

Related GitHub Issue

Closes: #1300

Description

This PR adds support for sending default headers with all LiteLLM API requests to track the originating app. PR #1300 previously added these headers for other providers but they were missed for LiteLLM.

Implementation details:

  • Updated RouterProvider to include DEFAULT_HEADERS in the OpenAI client initialization
  • Updated LiteLLM model fetcher to include DEFAULT_HEADERS in axios requests
  • Updated tests to verify that DEFAULT_HEADERS are included in requests

The implementation ensures that both the OpenAI client used by the RouterProvider (which LiteLLMHandler extends) and the direct axios requests in the LiteLLM model fetcher include the default headers.

Test Procedure

  1. Unit Tests: Updated the existing LiteLLM fetcher tests to verify that DEFAULT_HEADERS are included in requests
  2. Running Tests: To verify the changes, run:
    cd src
    pnpm vitest run api/providers/fetchers/__tests__/litellm.spec.ts
  3. Manual Verification: You can also manually verify the headers are sent by:
    • Setting up a local LiteLLM server
    • Using browser dev tools or a tool like Postman to inspect network requests
    • Confirming that the HTTP-Referer and X-Title headers are present in requests

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - This change affects backend API requests only, with no visual changes.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The DEFAULT_HEADERS object contains:

{
  "HTTP-Referer": "https://github.com/RooVetGit/Roo-Cline",
  "X-Title": "Roo Code"
}

These headers help with tracking and attribution of API requests.

Get in Touch

Discord: 183852721751719936, 189214917033852928


Important

Adds DEFAULT_HEADERS to LiteLLM API requests and updates tests to verify header inclusion.

  • Behavior:
    • Adds DEFAULT_HEADERS to LiteLLM API requests in litellm.ts and router-provider.ts.
    • Ensures headers are included in both OpenAI client and axios requests.
  • Testing:
    • Updates tests in litellm.spec.ts to verify inclusion of DEFAULT_HEADERS in requests.
    • Tests handle various scenarios including missing API keys and unexpected response formats.

This description was created by Ellipsis for 3ab37c7. You can customize this summary. It will automatically update as commits are pushed.

@andrewshu2000 andrewshu2000 requested review from cte, jr and mrubens as code owners June 30, 2025 00:55
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 30, 2025
@andrewshu2000 andrewshu2000 changed the title feature: adding x-title header and testing for litellm fetcher feat: adding x-title header and testing for litellm fetcher Jun 30, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 30, 2025
@andrewshu2000 andrewshu2000 changed the title feat: adding x-title header and testing for litellm fetcher feat: adding default headers and testing for litellm fetcher Jun 30, 2025
@dosubot dosubot bot added the enhancement New feature or request label Jun 30, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 30, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jun 30, 2025
…atting

- Reorder header spread in router-provider.ts so user-provided openAiHeaders can override DEFAULT_HEADERS
- Remove unnecessary blank lines after imports for consistency
- This matches the pattern used in openai.ts where DEFAULT_HEADERS come first
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

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

Thank you @andrewshu2000 for your contribution!

Looks good

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 30, 2025
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Needs Review] in Roo Code Roadmap Jun 30, 2025
@mrubens mrubens merged commit 569b276 into RooCodeInc:main Jul 1, 2025
17 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jul 1, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 1, 2025
hannesrudolph pushed a commit that referenced this pull request Jul 3, 2025
* chore: adding x-title header and testing for litellm

* chore: indentation fi and headers order fix

* chore: spacing fix

* chore: removed white space

* fix: allow user headers to override default headers and clean up formatting

- Reorder header spread in router-provider.ts so user-provided openAiHeaders can override DEFAULT_HEADERS
- Remove unnecessary blank lines after imports for consistency
- This matches the pattern used in openai.ts where DEFAULT_HEADERS come first

---------

Co-authored-by: Brendan-Z <[email protected]>
Co-authored-by: Daniel Riccio <[email protected]>
utarn pushed a commit to modelharbor/ModelHarbor-Agent that referenced this pull request Jul 4, 2025
…Inc#5242)

* chore: adding x-title header and testing for litellm

* chore: indentation fi and headers order fix

* chore: spacing fix

* chore: removed white space

* fix: allow user headers to override default headers and clean up formatting

- Reorder header spread in router-provider.ts so user-provided openAiHeaders can override DEFAULT_HEADERS
- Remove unnecessary blank lines after imports for consistency
- This matches the pattern used in openai.ts where DEFAULT_HEADERS come first

---------

Co-authored-by: Brendan-Z <[email protected]>
Co-authored-by: Daniel Riccio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer PR - Needs Review size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants