MacPaw / OpenAI

Swift community driven package for OpenAI public API
MIT License
2.11k stars 357 forks source link

base_url support instead of host, port, and scheme and move '/v1' to base_url #221

Open daisukes opened 3 months ago

daisukes commented 3 months ago

When I want to connect to an OpenAI compatible proxy server (i.e. litellm), it does not accept requests including /v1 in the URL.

The official OpenAI python library has base_url option to create client and the default base_url contains /v1

I can make a client for my proxy like

client = openai.OpenAI(api_key="api-key", base_url="http://localhost:8000")

So, I want base_url support instead of host, port and scheme configuration here.

https://github.com/MacPaw/OpenAI/blob/843e087929aa806adb611dbca93f9a4a7f28be04/Sources/OpenAI/OpenAI.swift#L30

Also, I want APIPath not including /v1 and move it to base_url

https://github.com/MacPaw/OpenAI/blob/843e087929aa806adb611dbca93f9a4a7f28be04/Sources/OpenAI/OpenAI.swift#L211-L231