feat(litellm): add team name and user name support to LiteLLM credential#6487
Open
raghava3107 wants to merge 3 commits into
Open
feat(litellm): add team name and user name support to LiteLLM credential#6487raghava3107 wants to merge 3 commits into
raghava3107 wants to merge 3 commits into
Conversation
LiteLLM proxy supports team-based routing for billing and access control. This adds optional Team Name and User Name fields to the LiteLLM credential, and passes them as x-litellm-team and x-litellm-user headers in API requests. This enables organizations using LiteLLM proxy with team-scoped API keys to explicitly identify the team and user making requests, which is useful for: - Team-based cost tracking and billing - Per-team rate limiting - Audit logging Both fields are optional and backward-compatible — existing LiteLLM configurations continue to work without changes.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces optional 'Team Name' and 'User Name' fields to the LiteLLM API credentials. These fields are then extracted and passed as custom headers ('x-litellm-team' and 'x-litellm-user') in the configuration of the ChatLiteLLM model. No review comments were provided, and there is no feedback to address.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Replace team/user-specific fields with a generic Custom Headers field that supports any LiteLLM proxy header (x-litellm-tags, x-litellm-customer-id, x-litellm-end-user-id, x-litellm-spend-logs-metadata, etc.). Headers are passed as a JSON string in the credential and sent as defaultHeaders in the OpenAI-compatible client configuration. Malformed JSON is handled gracefully. Add comprehensive test suite covering: - Basic initialization with API key and model - Custom headers passed correctly to the client - Malformed JSON headers handled gracefully - Backward compatibility without headers - Optional parameters (maxTokens, topP, timeout)
Ensure JSON.parse result is a non-array object before using as headers. Rejects arrays, strings, and numbers that would parse but are invalid headers.
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.
Summary
Adds a Custom Headers field to the LiteLLM credential, enabling users to pass any LiteLLM proxy headers in API requests. Also adds a comprehensive test suite for the ChatLiteLLM node.
Why is this needed?
LiteLLM is an AI gateway/proxy that routes requests to 100+ LLM providers (OpenAI, Anthropic, Bedrock, etc.) through a unified API. Organizations use LiteLLM for:
LiteLLM supports several request headers for these features (docs):
x-litellm-tagsx-litellm-customer-idx-litellm-end-user-idx-litellm-spend-logs-metadataCurrently, Flowise's LiteLLM integration only supports an API key — there's no way to pass these headers to the proxy.
Solution
Credential (
LitellmApi.credential.ts):Custom Headersfield (JSON string){"x-litellm-tags": "team:activation,env:prod"}Chat model (
ChatLitellm.ts):defaultHeadersin the OpenAI-compatible client configurationTests (
ChatLitellm.test.ts) — 6 tests:Backward Compatibility
The Custom Headers field is optional. Existing LiteLLM configurations continue to work without any changes.
Files Changed
packages/components/credentials/LitellmApi.credential.tslitellmCustomHeadersfieldpackages/components/nodes/chatmodels/ChatLitellm/ChatLitellm.tspackages/components/nodes/chatmodels/ChatLitellm/ChatLitellm.test.tsTest Results