Back to OSS
Swift Package LLM / AI
swift-llm-cloud
Anthropic / OpenAI / Gemini を束ねるマルチプロバイダー LLM クラウドクライアント
Swift
llmanthropicopenaigemini
English | 日本語
LLMCloud
A multi-provider LLM cloud client Swift package
Features
- Multi-Provider — Anthropic Claude, OpenAI GPT, Google Gemini, and more via a unified API
- Unified Interface — Common protocol-based design across all providers
- Streaming — Real-time output via
AsyncThrowingStreamfor all providers - Function Calling — Tool invocation support across all providers
- Structured Output — Type-safe responses using
@Structuredmacro (JSON Schema auto-generated)
Installation
// Package.swift
dependencies: [
.package(url: "https://github.com/no-problem-dev/swift-llm-cloud.git", from: "3.37.0")
]
Module Structure
Import only the modules you need:
| Module | Purpose |
|---|---|
LLMCloud |
Umbrella (re-exports Anthropic, OpenAI, Gemini) |
LLMCloudClient |
Shared infrastructure (retry, rate limiting, schema conversion) |
LLMCloudAnthropic |
Anthropic Claude provider |
LLMCloudOpenAI |
OpenAI GPT provider (with Responses API support) |
LLMCloudGemini |
Google Gemini provider (with context cache support) |
LLMCloudDeepSeek |
DeepSeek provider (V4 Flash/Pro) |
LLMCloudXAI |
xAI Grok provider |
LLMCloudGroq |
Groq-hosted models (Llama, Qwen, etc.) |
LLMCloudMistral |
Mistral AI provider |
LLMCloudOpenRouter |
OpenRouter (single interface to multiple providers) |
LLMCloudOpenAICompatible |
Shared OpenAI-compatible engine layer |
LLMCloudBranding |
Provider brand logos (SwiftUI) |
Quick Start
Anthropic Claude
import LLMCloudAnthropic
let client = AnthropicClient(apiKey: "sk-ant-...")
@Structured("Product info")
struct Product {
@StructuredField("Product name")
var name: String
@StructuredField("Price in USD", .minimum(0))
var price: Double
}
let result: Product = try await client.generate(
input: "The iPhone 16 Pro costs $999 and is a smartphone.",
model: .sonnet
)
print(result.name) // "iPhone 16 Pro"
print(result.price) // 999.0
OpenAI GPT
import LLMCloudOpenAI
let client = OpenAIClient(apiKey: "sk-...")
let result: Product = try await client.generate(
input: "The MacBook Pro costs $1999 and is a laptop.",
model: .gpt4o
)
Google Gemini
import LLMCloudGemini
let client = GeminiClient(apiKey: "AIza...")
let result: Product = try await client.generate(
input: "The AirPods Pro cost $249 and are wireless earbuds.",
model: .flash25
)
Documentation
| Guide | Description |
|---|---|
| API Reference | Full public API |
Requirements
- iOS 17.0+ / macOS 14.0+
- Swift 6.2+
- Xcode 16.0+
Dependencies
- swift-llm-client (>= 3.9.0) — LLM client abstraction
- swift-structured-data (>= 1.1.0) — Structured data conversion
- swift-api-contract (>= 2.1.2) — API contract definition
- swift-api-client (>= 2.3.1) — HTTP client
License
MIT License — See LICENSE for details
Links
同じカテゴリの OSS — LLM / AI
swift-llm-local
Swift PackageiOS / macOS のデバイス上でローカル LLM 推論を動かす Swift パッケージ
Swift
· LLM / AIllmon-deviceinference
swift-llm-mcp
Swift Packageswift-llm-client 向けの MCP + ツール解決層。MCP サーバーと組み込みツールキットのアダプタ
Swift
· LLM / AIllmmcptools
swift-structured-data
Swift Package外部由来の JSON / YAML / XML を Swift の型システムへ安全に変換するレイヤー
Swift
· LLM / AIjsonyamltype-safe
swift-research-agent
Swift PackageWeb 検索・取得ツールと引用ゲートを備えたリサーチャー・エージェント
Swift
· LLM / AIagentresearchweb-search
swift-media-agent
Swift Package画像・チャート・動画生成ツールとセッション単位のメディアストアを持つビジュアライザー・エージェント
Swift
· LLM / AIagentmediageneration