Skip to content

eature request: Allow overriding / per-request HTTP headers (e.g. for Langfuse, tracing, custom auth) #731

Description

@krowinski

Many observability / tracing tools (Langfuse, Helicone, OpenLLMetry, Phoenix, etc.) in AI gateways (LiteLLM) rely on sending custom HTTP headers with every OpenAI request (e.g. langfuse-trace-id, trace-id, x-helicone-id, X-Request-ID).

Currently the only way to add custom headers is globally via withHttpHeader() on the factory — which means you have to create a completely new client instance for every request that needs different headers.
This leads to very verbose and repetitive code, especially in applications that trace many LLM calls in one flow.

Describe the solution you'd like
It would be great to have at least one of these options:

  1. Per-request header override (most useful):
$client->chat()->create([
    'model' => 'gpt-4o-mini',
    'messages' => [...],
], extraHeaders: [
    'langfuse-trace-id' => $traceId,
    'langfuse-session-id' => $sessionId,
]);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions