Skip to content
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

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

Open
daisukes opened this issue Aug 1, 2024 · 1 comment

Comments

@daisukes
Copy link

daisukes commented Aug 1, 2024

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

        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.

public init(token: String, organizationIdentifier: String? = nil, host: String = "api.openai.com", port: Int = 443, scheme: String = "https", timeoutInterval: TimeInterval = 60.0) {

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

extension APIPath {
static let completions = "/v1/completions"
static let embeddings = "/v1/embeddings"
static let chats = "/v1/chat/completions"
static let edits = "/v1/edits"
static let models = "/v1/models"
static let moderations = "/v1/moderations"
static let audioSpeech = "/v1/audio/speech"
static let audioTranscriptions = "/v1/audio/transcriptions"
static let audioTranslations = "/v1/audio/translations"
static let images = "/v1/images/generations"
static let imageEdits = "/v1/images/edits"
static let imageVariations = "/v1/images/variations"
func withPath(_ path: String) -> String {
self + "/" + path
}
}

@codeAndxv
Copy link

I need this feature. Can a manager review this PR and merge it into the code?

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

2 participants