OpenAI icon indicating copy to clipboard operation
OpenAI copied to clipboard

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

Open daisukes opened this issue 1 year ago • 0 comments

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

  • This works http://localhost:8000/chat/completion
  • This does not work http://localhost:8000/v1/chat/completion

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

  • https://github.com/openai/openai-python/blob/195c05a64d39c87b2dfdf1eca2d339597f1fce03/src/openai/_client.py#L121
        if base_url is None:
            base_url = f"https://api.openai.com/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

daisukes avatar Aug 01 '24 03:08 daisukes