LanguageModelCapabilities
A set of capabilities that a language model provides.
Declaration
struct LanguageModelCapabilitiesOverview
Use this to declare what your model can do, like tool calling and guided generation:
struct MyLanguageModel: LanguageModel {
var capabilities: LanguageModelCapabilities {
LanguageModelCapabilities(capabilities: [
.toolCalling,
.guidedGeneration,
.reasoning
])
}
}Apps can inspect capabilities ahead of time to detect what the model supports before performing the request:
// Before prompting the model with a generable type, check whether it
// supports guided generation.
if selectedModel.capabilities.contains(.guidedGeneration) {
let response = try await session.respond(to: "...", generating: MySchema.self)
}When a model doesn’t support a capability, the framework can refuse to dispatch incompatible requests to the executor and throw an LanguageModelError.unsupportedCapability(_:) error instead.