Cosmo Realtime SDK
ReleasesMigration guidesSwift

Upgrade Swift to 0.7

Every breaking change in `CosmoAI` 0.7.0, with the replacement for each.

Breaking changes when moving CosmoAI from v0.6.0 to v0.7.0. The changelog has the full release notes; more than one version behind, chain the pages.

  • ModelOptions.grok now carries silenceDurationMs and prefixPaddingMs, both defaulted to nil. Spell the untuned case .grok() — a bare .grok no longer typechecks as a value.

  • Sessions now start through an agent, matching the Python and TypeScript SDKs. RealtimeSession.start(_:config:micMuted:rpcHandlers:) and client.start(config:) are removed, as is direct RealtimeAgent(...) construction — build the agent with client.agent(...) or client.catalogAgent(_:inputs:) and open the run with agent.start(...).

    Before:

    let config = SessionConfig(instructions: "You are a helpful assistant.")
    let session = try await client.start(config: config)

    After:

    let agent = try client.agent(instructions: "You are a helpful assistant.")
    let session = try await agent.start()

    The full signatures, every parameter defaulted: client.agent(instructions:model:modelOptions:voice:audio:tools:interruptionSensitivity:greeting:skills:mcp:hooks:), client.catalogAgent(_:inputs:voice:tools:mcp:hooks:), and agent.start(resumeSessionId:maxSessionSeconds:storeRecording:storeAudio:storeTranscript:storeVideo:micMuted:rpcHandlers:).

  • SessionConfig is removed, its fields split by scope:

    • Agent-scoped (instructions, model, modelOptions, voice, audio, tools, interruptionSensitivity, greeting, hooks) → parameters of client.agent(...).
    • A catalog run's agentName / agentInputs → client.catalogAgent(name, inputs:).
    • Per-run (resumeSessionId, maxSessionSeconds, storeRecording, storeAudio, storeTranscript, storeVideo, plus micMuted and rpcHandlers) → parameters of agent.start(...).
  • SessionConfig's nested types are now top level; cases and fields are unchanged — only the spelling of the type names moves:

    • SessionConfig.Tool → AgentTool (and SessionConfig.sdkToolNamePrefix → AgentTool.sdkToolNamePrefix)
    • SessionConfig.Voice → VoiceConfig
    • SessionConfig.Audio → AudioConfig
    • SessionConfig.Ambience → AmbienceConfig
    • SessionConfig.ModelOptions → ModelOptions, with the turn-detection enums nested there (ModelOptions.GeminiTurnDetection, ModelOptions.OpenAITurnDetection)
    • The enum aliases InterruptionSensitivity, ThinkingLevel, EndOfSpeechSensitivity, SemanticEagerness, and TurnDetectionMode are top level under the same names.
  • RealtimeSession.Options → RealtimeClient.Options, unchanged in shape: the credential is client-level configuration, not per-session.

  • RealtimeSession.installConnectTracing() → RealtimeClient.installConnectTracing(). RealtimeSession.setRecordingAlwaysPrepared(_:) is no longer public — MicPrewarmCoordinator.set(_:) / .settle() remain the supported mic-prewarm entry points.

  • RealtimeAgent's fields and RealtimeClient.Options' fields are now let: an agent and a client's options are configured entirely at creation. Code that mutated a field after construction passes the value to client.agent(...) / catalogAgent(...) or the Options initializer instead.

  • The pre-cutover event and error types are removed: Ready, Transcript, ToolCall, ToolResult, ToolInvocation, Role, ServerError, VoiceClientError, and ConnectionCloseReason. Sessions surface events as the RealtimeSession.Event enum via session.events — Ready → .ready(RealtimeSession.Ready), Transcript → .transcript(RealtimeSession.TranscriptDelta) (fields isFinal, role, text), ToolCall → .toolCall(RealtimeSession.ToolCall), ToolResult → .toolResult(RealtimeSession.ToolResult), ToolInvocation → .toolInvocation(RealtimeSession.ToolInvocation) — and failures throw RealtimeSessionError; code still holding the other removed payload shapes should declare its own copies.