Swift PackageProduction-ready

Build AI agents
in Swift.

Multi-provider SDK with tools, hooks, MCP, skills, and budget control. Drop it into any Swift project โ€” macOS, iOS, server-side โ€” and start shipping agents.

main.swift
import OpenAgentSDK

let agent = createAgent(options: AgentOptions(
    apiKey: "sk-...",
    model: "claude-sonnet-4-6"
))

let result = await agent.prompt("Hello")
print(result.text)

Features

Everything you need to ship an agent.

Multi-Provider

One interface across Anthropic, OpenAI, Ollama, and GLM. Swap providers without touching agent code.

Streaming

Stream partial text, tool calls, and final results as async events. First token in milliseconds.

Custom Tools

Define tools with a single declarative call. Type-safe inputs, structured outputs, automatic schema.

MCP Integration

Connect to any Model Context Protocol server over stdio or SSE. Tools and resources auto-discovered.

Hook System

preToolUse and postToolUse hooks for audit logs, guards, telemetry, and side effects.

Budget Control

Per-run permission policies and token / cost budgets. Stop agents before they over-spend.

Install

Add it to your project.

Use Swift Package Manager from the command line, or add it through Xcode's package dependencies panel. Requires Swift 5.9+.

Full install guide
.package(url: "https://github.com/terryso/open-agent-sdk-swift", from: "0.1.0")

Stop wiring providers.
Start shipping agents.