Allow custom headers on OpenAI providers (to be added to more later)
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
type OpenAIClient struct {
|
||||
APIKey string
|
||||
BaseURL string
|
||||
Headers map[string]string
|
||||
}
|
||||
|
||||
type ChatCompletionMessage struct {
|
||||
@@ -198,6 +199,9 @@ func (c *OpenAIClient) sendRequest(ctx context.Context, r ChatCompletionRequest)
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", "Bearer "+c.APIKey)
|
||||
for header, val := range c.Headers {
|
||||
req.Header.Set(header, val)
|
||||
}
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
|
||||
Reference in New Issue
Block a user