diff --git a/chat.go b/chat.go index 2b13f8dd..8958ebba 100644 --- a/chat.go +++ b/chat.go @@ -393,12 +393,12 @@ func (c *Client) CreateChatCompletion( if err = validateRequestForO1Models(request); err != nil { return } - req, err := c.newRequest( ctx, http.MethodPost, c.fullURL(urlSuffix, withModel(request.Model)), withBody(request), + withCustomHeaders(request.Metadata), ) if err != nil { return diff --git a/client.go b/client.go index ed8595e0..85927b19 100644 --- a/client.go +++ b/client.go @@ -90,6 +90,14 @@ func withContentType(contentType string) requestOption { } } +func withCustomHeaders(headers map[string]string) requestOption { + return func(args *requestOptions) { + for key, value := range headers { + args.header.Set(key, value) + } + } +} + func withBetaAssistantVersion(version string) requestOption { return func(args *requestOptions) { args.header.Set("OpenAI-Beta", fmt.Sprintf("assistants=%s", version))