Skip to content

Support custom headers and pre-request auth hooks for OpenAI-compatible providers #119

Description

@qznc

Some OpenAI-compatible APIs require custom HTTP headers or dynamic token exchange before each request. For example, GitHub Copilot's chat API requires:

  1. An Editor-Version header on every request
  2. Exchanging a long-lived OAuth token for a short-lived session token via a separate endpoint before each chat call

Currently there's no way to achieve either through LLMBuilder or OpenAICompatibleProvider. The OpenAIProviderConfig trait has custom_headers(), but it's only available when implementing a new provider inside the crate — not from user code.

Idea

  1. Add a .header(key, value) method to LLMBuilder that forwards custom headers to the underlying provider's HTTP requests
  2. Add a hook (e.g. .auth_provider(callback)) that lets users supply a function to dynamically resolve/refresh the bearer token before each request

This would allow integrating providers like GitHub Copilot without having to reimplement the entire ChatProvider trait from scratch.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions