Skip to content

Conversation

@vpecinka
Copy link

Implements custom HTTP headers functionality as requested in issue #343. Each LLM service instance (bot configuration) can now have independent custom headers that are sent with every API request to the provider.

Backend Changes:

  • Added customHeaders field to ServiceConfig and all provider configs
  • Implemented HTTP client wrapper to inject custom headers into requests
  • Updated config transformation to preserve customHeaders across saves
  • Added comprehensive unit and integration tests
  • Supports all providers: OpenAI, Anthropic, ASage, OpenAI Compatible

Frontend Changes:

  • Added CustomHeadersItem React component for header management
  • Integrated custom headers editor into System Console bot configuration
  • Fixed focus issues with dynamic header key editing
  • Updated TypeScript types to include customHeaders field

Key Features:

  • Per-service instance custom headers (independent between bots)
  • Headers preserved during config save/load operations
  • User-friendly UI for adding/editing/removing headers
  • Comprehensive validation and error handling
  • Full test coverage including multiple instance scenarios

Use Cases:

  • Authentication tokens specific to different API endpoints
  • Request tracking and routing headers
  • Organization-specific headers for multi-tenant setups
  • Custom metadata for monitoring and analytics

Closes #343

Closes #

Description

vpecinka and others added 6 commits June 30, 2025 11:58
Implements custom HTTP headers functionality as requested in issue mattermost#343.
Each LLM service instance (bot configuration) can now have independent
custom headers that are sent with every API request to the provider.

## Backend Changes:
- Added customHeaders field to ServiceConfig and all provider configs
- Implemented HTTP client wrapper to inject custom headers into requests
- Updated config transformation to preserve customHeaders across saves
- Added comprehensive unit and integration tests
- Supports all providers: OpenAI, Anthropic, ASage, OpenAI Compatible

## Frontend Changes:
- Added CustomHeadersItem React component for header management
- Integrated custom headers editor into System Console bot configuration
- Fixed focus issues with dynamic header key editing
- Updated TypeScript types to include customHeaders field

## Key Features:
- Per-service instance custom headers (independent between bots)
- Headers preserved during config save/load operations
- User-friendly UI for adding/editing/removing headers
- Comprehensive validation and error handling
- Full test coverage including multiple instance scenarios

## Use Cases:
- Authentication tokens specific to different API endpoints
- Request tracking and routing headers
- Organization-specific headers for multi-tenant setups
- Custom metadata for monitoring and analytics

Closes mattermost#343
Copy link
Member

@crspeller crspeller left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I think we just need to clean it up a little.

vpecinka and others added 13 commits August 12, 2025 13:46
Move duplicate customHeadersTransport implementations from OpenAI, Anthropic,
and ASage backends to shared httpexternal.WrapHTTPClientWithCustomHeaders function.
Inter-plugin client calls were failing when agents had tools enabled because the inter-plugin API uses ChatCompletionNoStream which internally calls ReadAll, and ReadAll explicitly rejects tool call events with an error. This created an architecture mismatch where regular conversations use streaming to handle tools properly, but inter-plugin requests use non-streaming which cannot handle tools.

The fix adds a WithLLMContextNoTools context option that allows inter-plugin requests to disable tools for that specific session only, without affecting the bot's overall tool configuration. This preserves the bot's ability to use tools in regular interactive conversations while allowing inter-plugin clients to work with simple completion requests.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <[email protected]>
* Update admin_guide.md

added note reg rendering of URL links via the plugin

* Update admin_guide.md

* Update docs/admin_guide.md

---------

Co-authored-by: Carrie Warner (Mattermost) <[email protected]>
* Update Agents to leverage official OpenAI SDK rather than third party one

* Fixes

* Fix embeddings propogation of dimensions

* Update openai/openai.go

Co-authored-by: Copilot <[email protected]>

* Fix linter

* Attempt to fix e2e

* fix more e2e

* Move output of deltas before checking finishing conditions

* lint

* Fix azure

* PR feedback

* Fix function calling for tools with no parameters. Add test to cover case

* One more PR Feedback

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Christopher Speller <[email protected]>
Move duplicate customHeadersTransport implementations from OpenAI, Anthropic,
and ASage backends to shared httpexternal.WrapHTTPClientWithCustomHeaders function.
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.

💡 idea: Custom headers support for models API

6 participants