Gemini
Gemini is now accessible from the OpenAI Library. Announcement .
SwiftOpenAI
support all OpenAI endpoints, however Please refer to Gemini documentation to understand which API's are currently compatible'
Gemini is now accessible through the OpenAI Library. See the announcement here.
SwiftOpenAI supports all OpenAI endpoints. However, please refer to the Gemini documentation to understand which APIs are currently compatible."
You can instantiate a OpenAIService
using your Gemini token like this...
let geminiAPIKey = "your_api_key"
let baseURL = "https://generativelanguage.googleapis.com"
let version = "v1beta"
let service = OpenAIServiceFactory.service(
apiKey: apiKey,
overrideBaseURL: baseURL,
overrideVersion: version)
You can now create a chat request using the .custom model parameter and pass the model name as a string.
let parameters = ChatCompletionParameters(
messages: [.init(
role: .user,
content: content)],
model: .custom("gemini-1.5-flash"))
let stream = try await service.startStreamedChat(parameters: parameters)