diff --git a/apple/TablePro/Models/AI/AIProviderPreset.swift b/apple/TablePro/Models/AI/AIProviderPreset.swift index a25b599e33..d51bc24674 100644 --- a/apple/TablePro/Models/AI/AIProviderPreset.swift +++ b/apple/TablePro/Models/AI/AIProviderPreset.swift @@ -29,7 +29,16 @@ struct AIProviderPreset: Identifiable, Equatable, Sendable { rejectsBadKeyWithForbidden: true ) - static let all: [AIProviderPreset] = [.requesty] + static let runcrate = AIProviderPreset( + id: "runcrate", + displayName: "Runcrate", + endpoint: "https://api.runcrate.ai/v1", + symbolName: "cloud", + authStyle: .apiKey, + rejectsBadKeyWithForbidden: false + ) + + static let all: [AIProviderPreset] = [.requesty, .runcrate] static func preset(withID id: String?) -> AIProviderPreset? { guard let id else { return nil } diff --git a/apple/TableProTests/Core/AI/AIProviderPresetTests.swift b/apple/TableProTests/Core/AI/AIProviderPresetTests.swift index a13b06ec59..44706cac6a 100644 --- a/apple/TableProTests/Core/AI/AIProviderPresetTests.swift +++ b/apple/TableProTests/Core/AI/AIProviderPresetTests.swift @@ -31,6 +31,28 @@ struct AIProviderPresetTests { ) } + @Test("Runcrate needs a key, and its default Base URL resolves to its chat completions and models routes") + func runcratePreset() throws { + let preset = AIProviderPreset.runcrate + #expect(preset.authStyle == .apiKey) + #expect(!preset.rejectsBadKeyWithForbidden) + + let config = AIProviderConfig(preset: preset) + #expect(config.type == .custom) + #expect(config.presetID == "runcrate") + #expect(config.name == "Runcrate") + let style = config.type.endpointStyle + #expect(style == .chatCompletions) + #expect( + AIEndpoint(config.endpoint, style: style)?.chatURL(model: "deepseek-ai/DeepSeek-V4.1-Flash", style: style)?.absoluteString + == "https://api.runcrate.ai/v1/chat/completions" + ) + #expect( + AIEndpoint(config.endpoint, style: style)?.url(appending: style.modelsResource)?.absoluteString + == "https://api.runcrate.ai/v1/models" + ) + } + @Test("Every preset has a unique id and an https endpoint the transport can resolve") func presetsAreWellFormed() { #expect(Set(AIProviderPreset.all.map(\.id)).count == AIProviderPreset.all.count)