Skip to content

Overview

This page adapts the original AI SDK documentation: AI SDK Core → Overview.

Large Language Models (LLMs) are advanced programs that can understand, create, and engage with human language on a large scale. They are trained on vast amounts of written material to recognize patterns in language and predict what might come next in a given piece of text.

AI SDK Core simplifies working with LLMs by offering a standardized way of integrating them into your app — so you can focus on product logic rather than integration plumbing.

For example, basic text generation in Swift:

import SwiftAISDK
import OpenAIProvider
let result = try await generateText(
model: openai("gpt-4o"),
prompt: "Write a 1‑sentence product tagline for a time‑tracking app."
)
print(result.text)

AI SDK Core includes functions for text generation, structured data generation, and tool usage. They use a standardized approach to prompts and settings, making it easier to work with different models.

  • generateText — non‑streamed text generation and tool calling. Great for automation (draft emails, summarization) and agent workflows.
  • streamText — streamed text and tool calls. Ideal for interactive UIs (chat, progressive responses). See also Streaming.
  • generateObject — generate a typed object matching a schema. In Swift you usually pass schema: MyCodableType.self; fall back to FlexibleSchema(jsonSchema(...)) only for edge cases.
  • streamObject — stream a structured object that matches a schema (useful for incremental UI rendering on your side).

See the AI SDK Core API Reference for details on each function.