Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Sources/OpenAI/OpenAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ 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

/// Optional base path if you set up OpenAI API proxy on a custom path on your own host. Default is ""
public let basePath: 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", basePath: String? = nil, timeoutInterval: TimeInterval = 60.0) {
self.token = token
self.organizationIdentifier = organizationIdentifier
self.host = host
self.basePath = basePath
self.timeoutInterval = timeoutInterval
}
}
Expand Down Expand Up @@ -171,7 +175,7 @@ extension OpenAI {
var components = URLComponents()
components.scheme = "https"
components.host = configuration.host
components.path = path
components.path = (configuration.basePath ?? "") + path
return components.url!
}
}
Expand Down