unionst/swift-chat-ai-starter

A complete iPhone chat app that streams Claude, built on Swift Chat's assistant style

Swift

0

1 commits

updated Oct 5, 2026

See the code

See what people are saying

README

Swift Chat AI Starter

A complete iPhone chat app that streams answers from Claude, built on Swift Chat’s assistant style. Your question rises to the top of the screen and the answer streams in under it as Markdown, the way Siri and ChatGPT answer.

See it running

Run it

  1. Open SwiftChatAIStarter.xcodeproj in Xcode 26 and run it on an iPhone or the simulator.
  2. Paste an Anthropic API key into the sheet that appears.
  3. Ask anything. Attach a photo from the plus button and Claude will look at it.

What’s in it

FileWhat it does
AssistantView.swiftThe whole UI: one Chat with .chatStyle(.assistant) and a few modifiers
Conversation.swiftHolds the thread, appends one reply per answer and rewrites its text as tokens arrive
ClaudeRequest.swiftBuilds the Messages API request from the thread, including photos
ClaudeClient.swiftStreams the reply over server-sent events with URLSession
KeychainStore.swiftKeeps the API key in the Keychain

The UI is these few lines:

Chat(conversation.entries, typingUsers: conversation.isWaiting ? [Conversation.assistant] : []) { entry in
    Message(entry.text, role: entry.role, timestamp: entry.sentAt)
        .messageMedia(entry.media)
}
.chatStyle(.assistant)
.chatTypingStatus(conversation.status)
.chatInputCapabilities([.camera, .photoLibrary])
.onChatSend { text, media in
    await conversation.send(text, media: media)
}

Before you ship

The app sends your key straight to api.anthropic.com, which is fine on your own phone and wrong in an app other people install. Put a small server in front of the API, call it from ClaudeClient, and keep the key there.

Requests use claude-opus-5-5 at low effort, which suits chat. They opt into server-side fallbacks (fallbacks: "default"), so a request a safety classifier declines is retried on another model instead of failing. Change any of this in ClaudeRequest.swift.

License

MIT. Swift Chat itself is free to use in any app; see its license.

ai-chat
anthropic
chatgpt
claude
ios
llm
swift-chat
swiftui

unionst/swift-chat-ai-starter

A complete iPhone chat app that streams Claude, built on Swift Chat's assistant style

Swift

0

1 commits

updated Oct 5, 2026

See the code

See what people are saying

README

Swift Chat AI Starter

A complete iPhone chat app that streams answers from Claude, built on Swift Chat’s assistant style. Your question rises to the top of the screen and the answer streams in under it as Markdown, the way Siri and ChatGPT answer.

See it running

Run it

  1. Open SwiftChatAIStarter.xcodeproj in Xcode 26 and run it on an iPhone or the simulator.
  2. Paste an Anthropic API key into the sheet that appears.
  3. Ask anything. Attach a photo from the plus button and Claude will look at it.

What’s in it

FileWhat it does
AssistantView.swiftThe whole UI: one Chat with .chatStyle(.assistant) and a few modifiers
Conversation.swiftHolds the thread, appends one reply per answer and rewrites its text as tokens arrive
ClaudeRequest.swiftBuilds the Messages API request from the thread, including photos
ClaudeClient.swiftStreams the reply over server-sent events with URLSession
KeychainStore.swiftKeeps the API key in the Keychain

The UI is these few lines:

Chat(conversation.entries, typingUsers: conversation.isWaiting ? [Conversation.assistant] : []) { entry in
    Message(entry.text, role: entry.role, timestamp: entry.sentAt)
        .messageMedia(entry.media)
}
.chatStyle(.assistant)
.chatTypingStatus(conversation.status)
.chatInputCapabilities([.camera, .photoLibrary])
.onChatSend { text, media in
    await conversation.send(text, media: media)
}

Before you ship

The app sends your key straight to api.anthropic.com, which is fine on your own phone and wrong in an app other people install. Put a small server in front of the API, call it from ClaudeClient, and keep the key there.

Requests use claude-opus-5-5 at low effort, which suits chat. They opt into server-side fallbacks (fallbacks: "default"), so a request a safety classifier declines is retried on another model instead of failing. Change any of this in ClaudeRequest.swift.

License

MIT. Swift Chat itself is free to use in any app; see its license.

ai-chat
anthropic
chatgpt
claude
ios
llm
swift-chat
swiftui