Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 9 additions & 3 deletions Packages/OsaurusCore/Models/RemoteProviderConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,21 @@ public struct RemoteProvider: Codable, Identifiable, Sendable, Equatable {
if authType == .apiKey, let apiKey = getAPIKey(), !apiKey.isEmpty {
switch providerType {
case .anthropic:
headers["x-api-key"] = apiKey
if headers["x-api-key"] == nil {
headers["x-api-key"] = apiKey
}
// Add required Anthropic version header if not already set
if headers["anthropic-version"] == nil {
headers["anthropic-version"] = "2023-06-01"
}
case .gemini:
headers["x-goog-api-key"] = apiKey
if headers["x-goog-api-key"] == nil {
headers["x-goog-api-key"] = apiKey
}
case .openai, .openResponses:
headers["Authorization"] = "Bearer \(apiKey)"
if headers["Authorization"] == nil {
headers["Authorization"] = "Bearer \(apiKey)"
}
}
}

Expand Down
12 changes: 9 additions & 3 deletions Packages/OsaurusCore/Services/RemoteProviderManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,21 @@ public final class RemoteProviderManager: ObservableObject {
if authType == .apiKey, let apiKey = apiKey, !apiKey.isEmpty {
switch providerType {
case .anthropic:
testHeaders["x-api-key"] = apiKey
if testHeaders["x-api-key"] == nil {
testHeaders["x-api-key"] = apiKey
}
// Add required Anthropic version header if not already set
if testHeaders["anthropic-version"] == nil {
testHeaders["anthropic-version"] = "2023-06-01"
}
case .gemini:
testHeaders["x-goog-api-key"] = apiKey
if testHeaders["x-goog-api-key"] == nil {
testHeaders["x-goog-api-key"] = apiKey
}
case .openai, .openResponses:
testHeaders["Authorization"] = "Bearer \(apiKey)"
if testHeaders["Authorization"] == nil {
testHeaders["Authorization"] = "Bearer \(apiKey)"
}
}
}

Expand Down
Loading