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

Swift Platforms License

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 AsyncThrowingStream for all providers
  • Function Calling — Tool invocation support across all providers
  • Structured Output — Type-safe responses using @Structured macro (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

License

MIT License — See LICENSE for details

Links

同じカテゴリの OSS — LLM / AI

swift-llm-client

Swift Package

プロバイダー非依存の LLM クライアント抽象化。実装を差し替え可能なコア層

Swift
· LLM / AI
llmaiclient

swift-llm-local

Swift Package

iOS / macOS のデバイス上でローカル LLM 推論を動かす Swift パッケージ

Swift
· LLM / AI
llmon-deviceinference

swift-llm-mcp

Swift Package

swift-llm-client 向けの MCP + ツール解決層。MCP サーバーと組み込みツールキットのアダプタ

Swift
· LLM / AI
llmmcptools

swift-structured-data

Swift Package

外部由来の JSON / YAML / XML を Swift の型システムへ安全に変換するレイヤー

Swift
· LLM / AI
jsonyamltype-safe

swift-research-agent

Swift Package

Web 検索・取得ツールと引用ゲートを備えたリサーチャー・エージェント

Swift
· LLM / AI
agentresearchweb-search

swift-media-agent

Swift Package

画像・チャート・動画生成ツールとセッション単位のメディアストアを持つビジュアライザー・エージェント

Swift
· LLM / AI
agentmediageneration

© 2026 Kyoichi Taniguchi. All rights reserved.