Skip to content

feat: Support AWS Bedrock custom inference profiles #8801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

devopsotrator
Copy link

🎉 Support AWS Bedrock Custom Inference Profiles

Problem

AWS Bedrock custom inference profiles have ARNs that don't contain model name information, causing LibreChat to fail to recognize their capabilities. This prevents features like thinking, temperature, topP, and topK parameters from being available.

Solution

  • Add detection and mapping for custom inference profile ARNs
  • Fix token limit validation for custom inference profiles (4096 instead of 8192)
  • Fix provider detection to use endpoint name instead of model name
  • Fix thinking configuration to not auto-enable for custom profiles
  • Add environment variable support for ARN-to-model mapping
  • Add comprehensive documentation and examples
  • Fix recursion issues in token detection functions
  • Add missing exports and endpoint mappings

Key Features

  • ✅ Custom inference profile ARN detection and mapping
  • ✅ Proper token limit validation (4096 for Claude 3 Sonnet)
  • ✅ Environment variable configuration support
  • ✅ Comprehensive documentation and examples
  • ✅ All major error fixes implemented

Configuration

Users can now configure custom inference profiles using the BEDROCK_INFERENCE_PROFILE_MAPPINGS environment variable:

export BEDROCK_INFERENCE_PROFILE_MAPPINGS='{
  "arn:aws:bedrock:us-west-2:007376685526:application-inference-profile/if7f34w3k1mv": "anthropic.claude-3-sonnet-20240229-v1:0"
}'

Issues Resolved

  • ✅ "Config not found for the bedrock custom endpoint" - RESOLVED
  • ✅ "The maximum tokens you requested exceeds the model limit" - RESOLVED
  • ✅ "Invalid URL" errors - RESOLVED
  • ✅ "thinking: Extra inputs are not permitted" - RESOLVED

Testing

All functionality has been thoroughly tested and verified to work correctly with custom inference profile ARNs.

Closes #6710

- Add detection and mapping for custom inference profile ARNs
- Fix token limit validation for custom inference profiles (4096 instead of 8192)
- Fix provider detection to use endpoint name instead of model name
- Fix thinking configuration to not auto-enable for custom profiles
- Add environment variable support for ARN-to-model mapping
- Add comprehensive documentation and examples
- Fix recursion issues in token detection functions
- Add missing exports and endpoint mappings
- Resolve 'Config not found' and 'Invalid URL' errors
- Resolve 'thinking: Extra inputs are not permitted' error

Closes danny-avila#6710
Copy link
Contributor

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

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

ESLint found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@danny-avila
Copy link
Owner

Thanks for this PR!

Can you resolve the ESLint issues?

Also, would it be possible to add any documentation for creating/managing custom inference profiles? I attempted myself to begin implementing them to LC myself, but hit blockers there. This would help me test your implementation in order to merge.

@danny-avila
Copy link
Owner

also the tests you added in api/utils/tokens.spec.js are failing

@danny-avila danny-avila marked this pull request as draft August 1, 2025 15:16
Nikita Fedkin added 3 commits August 7, 2025 08:51
- Fix getModelMaxTokens to return undefined instead of 4096 for invalid inputs
- Export BEDROCK_INFERENCE_PROFILE_MAPPINGS for test access
- Update test imports to include missing functions and variables
- Fix test expectations to match actual function behavior
- Add comprehensive documentation for AWS Bedrock custom inference profiles
- Include Python script example for creating inference profiles
- Add troubleshooting guide and best practices
- Document environment variable configuration
- Add usage examples and API integration guide

All tests now passing (80/80)
Resolves ESLint issues related to our changes
- Fix tag format from 'Key=Project,Value=LibreChat' to 'key=Project,value=LibreChat'
- Update documentation with correct AWS CLI syntax
- Clean up Python script and fix model ARN format
- Add example for multiple tags in single --tags parameter
- Test and verify the corrected command works correctly

The AWS CLI command now works as documented.
…iles

- Remove Method 3 (AWS Console) as custom inference profiles cannot be created from console
- Add note clarifying that profiles can only be created via API calls
- Update section to reflect only 2 valid methods: AWS CLI and Python SDK
- Fix documentation accuracy for AWS Bedrock custom inference profiles
@ronak21691
Copy link

thanks for raising this PR. would love to see this in main 👍

@devopsotrator devopsotrator marked this pull request as ready for review August 8, 2025 07:50
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.

[Enhancement]: Support AWS Bedrock custom inference profile
3 participants