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 yes (emulated via forced tool-use)

Structured output is emulated via forced tool-use: the SDK synthesizes a tool whose input schema is your response schema, forces the model to call it, extracts the tool input JSON, and validates it in process. Same generate(from:schema:) API as OpenAI and Gemini. If the model returns prose instead of calling the tool, generate() fails loud rather than fabricating a result. 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.