Anthropic
The direct provider for Claude. The app sends each request straight to Anthropic and streams the reply; tools execute locally.
Construct it
let agent = try runtime.makeAgent(
provider: .anthropic(apiKey: key, model: "claude-sonnet-4-6"),
role: AgentRole(staticPersona: "You are a precise video-editing assistant.")
)
Hold the provider directly when you need it:
let provider = AnthropicProvider(apiKey: key, model: "claude-sonnet-4-6")
model defaults to claude-sonnet-4-6 and is a plain string — any model
Anthropic offers works without a framework update. baseURL: points the
provider at an Anthropic-compatible proxy.
What it supports
| Capability | Value |
|---|---|
| execution | app-driven (the session runs the loop) |
| context window | 200,000 tokens |
| vision | yes |
| tool choice | yes, native |
| structured output | no |
No native structured output: generate() throws
StructuredOutputError.unsupported before any request is sent. Run
structured turns against OpenAI, Gemini, or
the on-device model — see get data, not prose.
The full flag-by-flag table lives in the capability matrix.
Keep the key out of shipped apps
.anthropic(apiKey:) sends the key from the device — fine for prototypes,
extractable from any shipped binary. For production,
name an agent profile instead of a key.