Skip to content

[Feature Request] Support passing dynamic custom headers to LiteLLM via RunConfig #4297

@Faraaz1994

Description

@Faraaz1994

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

🔴 Required Information

Please ensure all items in this section are completed to allow for efficient
triaging. Requests without complete information may be rejected / deprioritized.
If an item is not applicable to you - please mark it as N/A

Is your feature request related to a specific problem?

When using ADK with LiteLLM, there's no way to pass dynamic per-request HTTP configuration like custom headers, timeouts, or retry options via RunConfig.

Currently, http_options can only be set statically on the Agent's generate_content_config which means:

  • Request correlation/tracing headers (e.g., X-Correlation-Id, X-Request-Id, user-id) cannot be set dynamically
  • Per-request timeout adjustments are not possible
  • Different retry strategies for critical vs non-critical requests cannot be configured

Describe the Solution You'd Like

Add an http_options field to RunConfig that propagates through the request pipeline to the model layer. This allows runtime configuration of:

  • headers: Custom HTTP headers (auth tokens, tracing IDs, correlation headers)
  • timeout: Per-request timeout overrides
  • retry_options: Per-request retry configuration
  • extra_body: Additional request body parameters

The merge behavior should be:

  • Agent-level generate_content_config.http_options provides defaults
  • RunConfig.http_options overrides agent defaults at runtime
  • For headers specifically, RunConfig headers should be merged with (and override) agent headers

Impact on your work

This is critical for production deployments where:

  • Per-request authentication tokens need to be passed (e.g., user-specific API keys)
  • Distributed tracing requires correlation headers on every request
  • Different requests have different latency requirements
  • Integration with observability platforms requires custom headers

Willingness to contribute

Are you interested in implementing this feature yourself or submitting a PR?
Yes


🟡 Recommended Information

Describe Alternatives You've Considered

  • Setting headers at Agent initialization - Doesn't work for dynamic per-request values
  • Creating a new Agent per request - Extremely inefficient

Proposed API / Implementation


run_config = RunConfig(
    http_options=types.HttpOptions(
        timeout=60000,
        headers={
            "X-User-ID": user_id,
            "X-Correlation-Id": correlation_id,
        }
    )
)

async for event in runner.run_async(..., run_config=run_config):

Additional Context

Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    models[Component] Issues related to model support

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions