diff --git a/Sources/OpenAI/OpenAI.swift b/Sources/OpenAI/OpenAI.swift index 199e3eb3..5ff52833 100644 --- a/Sources/OpenAI/OpenAI.swift +++ b/Sources/OpenAI/OpenAI.swift @@ -22,14 +22,17 @@ final public class OpenAI: OpenAIProtocol { /// API host. Set this property if you use some kind of proxy or your own server. Default is api.openai.com public let host: String - + public let port: Int + public let scheme: String /// Default request timeout public let timeoutInterval: TimeInterval - public init(token: String, organizationIdentifier: String? = nil, host: String = "api.openai.com", timeoutInterval: TimeInterval = 60.0) { + public init(token: String, organizationIdentifier: String? = nil, host: String = "api.openai.com", port: Int = 443, scheme: String = "https", timeoutInterval: TimeInterval = 60.0) { self.token = token self.organizationIdentifier = organizationIdentifier self.host = host + self.port = port + self.scheme = scheme self.timeoutInterval = timeoutInterval } } @@ -196,8 +199,9 @@ extension OpenAI { func buildURL(path: String) -> URL { var components = URLComponents() - components.scheme = "https" + components.scheme = configuration.scheme components.host = configuration.host + components.port = configuration.port components.path = path return components.url! }