go-openai icon indicating copy to clipboard operation
go-openai copied to clipboard

Add possability to create NewClient with custom endpoint (localhost)

Open JackBekket opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. As of now, the openai chatGPT API in the sashabaranov/go-openai project only supports a hardcoded end-point. This limitation restricts the flexibility and customizability that users might require in certain scenarios.

Basically I have gpt4all working locally, and it has openai API compatible supported. Which means, if I could change endpoint of API to localhost -- I would able to use go-openai locally

Describe the solution you'd like I want to be able to use go-openai which can call custom end-point and not only openai.com

Let's say that go-openai.NewClient(api_key) can be called like go-openai.NewClient(api_key,api_endpoint)

JackBekket avatar Sep 28 '23 18:09 JackBekket

image

It would be enough if AuthToken was a public field.

3rd avatar Sep 28 '23 22:09 3rd

I agree. Hope the author changes

mofung1 avatar Nov 16 '23 07:11 mofung1

Did you tried this?

c := openai.DefaultConfig("withYourAuthToken") 
c.BaseUrl = "http://localhost/gpt4all"

client := openai.NewClientWithConfig(c)

demaggus83 avatar Jul 04 '24 05:07 demaggus83