Skip to content

base url have bug #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alanjchuang opened this issue Nov 1, 2024 · 4 comments
Closed

base url have bug #105

alanjchuang opened this issue Nov 1, 2024 · 4 comments
Assignees

Comments

@alanjchuang
Copy link

alanjchuang commented Nov 1, 2024

client := openai.NewChatCompletionService(
option.WithAPIKey("xxx"), // defaults to os.LookupEnv("OPENAI_API_KEY")
option.WithBaseURL("https://aihubmix.com/v1"),
)

the v1 will be missed
panic: POST "https://aihubmix.com/chat/completions": 405 Method Not Allowed

@alanjchuang alanjchuang changed the title base url base url have bug Nov 1, 2024
@jacobzim-stl
Copy link
Collaborator

Thanks for the report, this should be quick fix!

@dreamilk
Copy link

dreamilk commented Nov 13, 2024

You can implement your own middleware to modify the URL for post/get calls
example:

client := openai.NewClient(
	option.WithBaseURL("https://aihubmix.com/v1"),
	option.WithAPIKey("OPENAI_API_KEY"),
	option.WithMiddleware(func(r *http.Request, mn option.MiddlewareNext) (*http.Response, error) {
		r.URL.Path = "/v1" + r.URL.Path
		return mn(r)
	}),
)

@jacobzim-stl
Copy link
Collaborator

jacobzim-stl commented Nov 18, 2024

If you add a slash to the end, so it's https://aihubmix.com/v1/, then it should work. We'll consider a fix to make this work automatically.

@daulet
Copy link

daulet commented Mar 14, 2025

Suggested fix: #272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants