sashabaranov / go-openai

OpenAI ChatGPT, GPT-3, GPT-4, DALL·E, Whisper API wrapper for Go
Apache License 2.0
9.07k stars 1.39k forks source link

Add possability to create NewClient with custom endpoint (localhost) #502

Open JackBekket opened 1 year ago

JackBekket commented 1 year ago

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)

3rd commented 1 year ago

image

It would be enough if AuthToken was a public field.

mofung1 commented 10 months ago

I agree. Hope the author changes

demaggus83 commented 3 months ago

Did you tried this?

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

client := openai.NewClientWithConfig(c)