
# AI SDK Core

[AI SDK Core](/docs/ai-sdk-core) is a set of functions that allow you to interact with language models and other AI models.
These functions are designed to be easy-to-use and flexible, allowing you to generate text, structured data,
and embeddings from language models and other AI models.

AI SDK Core contains the following main functions:

<IndexCards
  cards={[
    {
      title: 'generateText()',
      description: 'Generate text and call tools from a language model.',
      href: '/docs/reference/ai-sdk-core/generate-text',
    },
    {
      title: 'streamText()',
      description: 'Stream text and call tools from a language model.',
      href: '/docs/reference/ai-sdk-core/stream-text',
    },
    {
      title: 'Output',
      description: 'Structured output types for generateText and streamText.',
      href: '/docs/reference/ai-sdk-core/output',
    },
    {
      title: 'embed()',
      description:
        'Generate an embedding for a single value using an embedding model.',
      href: '/docs/reference/ai-sdk-core/embed',
    },
    {
      title: 'embedMany()',
      description:
        'Generate embeddings for several values using an embedding model (batch embedding).',
      href: '/docs/reference/ai-sdk-core/embed-many',
    },
    {
      title: 'generateImage()',
      description:
        'Generate images based on a given prompt using an image model.',
      href: '/docs/reference/ai-sdk-core/generate-image',
    },
    {
      title: 'experimental_generateVideo()',
      description:
        'Generate videos based on a given prompt using a video model.',
      href: '/docs/reference/ai-sdk-core/generate-video',
    },
    {
      title: 'transcribe()',
      description: 'Generate a transcript from an audio file.',
      href: '/docs/reference/ai-sdk-core/transcribe',
    },
    {
      title: 'generateSpeech()',
      description: 'Generate speech audio from text.',
      href: '/docs/reference/ai-sdk-core/generate-speech',
    },
    {
      title: 'uploadFile()',
      description: 'Upload a file to a provider and get a provider reference.',
      href: '/docs/reference/ai-sdk-core/upload-file',
    },
    {
      title: 'uploadSkill()',
      description: 'Upload a skill to a provider and get a provider reference.',
      href: '/docs/reference/ai-sdk-core/upload-skill',
    },
  ]}
/>

It also contains the following helper functions:

<IndexCards
  cards={[
    {
      title: 'tool()',
      description: 'Type inference helper function for tools.',
      href: '/docs/reference/ai-sdk-core/tool',
    },
    {
      title: 'experimental_getRealtimeToolDefinitions()',
      description: 'Convert AI SDK tools into realtime tool definitions.',
      href: '/docs/reference/ai-sdk-core/get-realtime-tool-definitions',
    },
    {
      title: 'Experimental_SandboxSession',
      description:
        'Experimental execution environment interface passed to tool execution.',
      href: '/docs/reference/ai-sdk-core/sandbox',
    },
    {
      title: 'experimental_filterActiveTools()',
      description: 'Filters a tool set to only the currently active tools.',
      href: '/docs/reference/ai-sdk-core/filter-active-tools',
    },
    {
      title: 'createMCPClient()',
      description: 'Creates a client for connecting to MCP servers.',
      href: '/docs/reference/ai-sdk-core/create-mcp-client',
    },
    {
      title: 'MCP Apps',
      description:
        'Helpers for rendering interactive MCP tool UIs and filtering app-visible tools.',
      href: '/docs/reference/ai-sdk-core/mcp-apps',
    },
    {
      title: 'jsonSchema()',
      description: 'Creates AI SDK compatible JSON schema objects.',
      href: '/docs/reference/ai-sdk-core/json-schema',
    },
    {
      title: 'zodSchema()',
      description: 'Creates AI SDK compatible Zod schema objects.',
      href: '/docs/reference/ai-sdk-core/zod-schema',
    },
    {
      title: 'createProviderRegistry()',
      description:
        'Creates a registry for using models from multiple providers.',
      href: '/docs/reference/ai-sdk-core/provider-registry',
    },
    {
      title: 'cosineSimilarity()',
      description:
        'Calculates the cosine similarity between two vectors, e.g. embeddings.',
      href: '/docs/reference/ai-sdk-core/cosine-similarity',
    },
    {
      title: 'simulateReadableStream()',
      description:
        'Creates a ReadableStream that emits values with configurable delays.',
      href: '/docs/reference/ai-sdk-core/simulate-readable-stream',
    },
    {
      title: 'wrapLanguageModel()',
      description: 'Wraps a language model with middleware.',
      href: '/docs/reference/ai-sdk-core/wrap-language-model',
    },
    {
      title: 'wrapImageModel()',
      description: 'Wraps an image model with middleware.',
      href: '/docs/reference/ai-sdk-core/wrap-image-model',
    },
    {
      title: 'extractReasoningMiddleware()',
      description:
        'Extracts reasoning from the generated text and exposes it as a `reasoning` property on the result.',
      href: '/docs/reference/ai-sdk-core/extract-reasoning-middleware',
    },
    {
      title: 'extractJsonMiddleware()',
      description:
        'Extracts JSON from text content by stripping markdown code fences.',
      href: '/docs/reference/ai-sdk-core/extract-json-middleware',
    },
    {
      title: 'isStepCount()',
      description:
        'Creates a stop condition that triggers after a specified number of steps.',
      href: '/docs/reference/ai-sdk-core/is-step-count',
    },
    {
      title: 'hasToolCall()',
      description:
        'Creates a stop condition that triggers when any specified tool is called.',
      href: '/docs/reference/ai-sdk-core/has-tool-call',
    },
    {
      title: 'isLoopFinished()',
      description:
        'Creates a stop condition that lets the agent loop run until it naturally finishes.',
      href: '/docs/reference/ai-sdk-core/loop-finished',
    },
    {
      title: 'simulateStreamingMiddleware()',
      description:
        'Simulates streaming behavior with responses from non-streaming language models.',
      href: '/docs/reference/ai-sdk-core/simulate-streaming-middleware',
    },
    {
      title: 'defaultSettingsMiddleware()',
      description: 'Applies default settings to a language model.',
      href: '/docs/reference/ai-sdk-core/default-settings-middleware',
    },
    {
      title: 'smoothStream()',
      description: 'Smooths text and reasoning streaming output.',
      href: '/docs/reference/ai-sdk-core/smooth-stream',
    },
    {
      title: 'generateId()',
      description: 'Helper function for generating unique IDs',
      href: '/docs/reference/ai-sdk-core/generate-id',
    },
    {
      title: 'createIdGenerator()',
      description: 'Creates an ID generator',
      href: '/docs/reference/ai-sdk-core/create-id-generator',
    },
  ]}
/>


## Navigation

- [AI SDK Core](/v7/docs/reference/ai-sdk-core)
  - [generateText](/v7/docs/reference/ai-sdk-core/generate-text)
  - [streamText](/v7/docs/reference/ai-sdk-core/stream-text)
  - [embed](/v7/docs/reference/ai-sdk-core/embed)
  - [embedMany](/v7/docs/reference/ai-sdk-core/embed-many)
  - [rerank](/v7/docs/reference/ai-sdk-core/rerank)
  - [generateImage](/v7/docs/reference/ai-sdk-core/generate-image)
  - [transcribe](/v7/docs/reference/ai-sdk-core/transcribe)
  - [generateSpeech](/v7/docs/reference/ai-sdk-core/generate-speech)
  - [experimental_generateVideo](/v7/docs/reference/ai-sdk-core/generate-video)
  - [uploadFile](/v7/docs/reference/ai-sdk-core/upload-file)
  - [uploadSkill](/v7/docs/reference/ai-sdk-core/upload-skill)
  - [Agent (Interface)](/v7/docs/reference/ai-sdk-core/agent)
  - [ToolLoopAgent](/v7/docs/reference/ai-sdk-core/tool-loop-agent)
  - [createAgentUIStream](/v7/docs/reference/ai-sdk-core/create-agent-ui-stream)
  - [createAgentUIStreamResponse](/v7/docs/reference/ai-sdk-core/create-agent-ui-stream-response)
  - [pipeAgentUIStreamToResponse](/v7/docs/reference/ai-sdk-core/pipe-agent-ui-stream-to-response)
  - [tool](/v7/docs/reference/ai-sdk-core/tool)
  - [dynamicTool](/v7/docs/reference/ai-sdk-core/dynamic-tool)
  - [createMCPClient](/v7/docs/reference/ai-sdk-core/create-mcp-client)
  - [experimental_getRealtimeToolDefinitions](/v7/docs/reference/ai-sdk-core/get-realtime-tool-definitions)
  - [MCP Apps](/v7/docs/reference/ai-sdk-core/mcp-apps)
  - [Experimental_StdioMCPTransport](/v7/docs/reference/ai-sdk-core/mcp-stdio-transport)
  - [jsonSchema](/v7/docs/reference/ai-sdk-core/json-schema)
  - [zodSchema](/v7/docs/reference/ai-sdk-core/zod-schema)
  - [valibotSchema](/v7/docs/reference/ai-sdk-core/valibot-schema)
  - [Output](/v7/docs/reference/ai-sdk-core/output)
  - [filterActiveTools](/v7/docs/reference/ai-sdk-core/filter-active-tools)
  - [ModelMessage](/v7/docs/reference/ai-sdk-core/model-message)
  - [UIMessage](/v7/docs/reference/ai-sdk-core/ui-message)
  - [validateUIMessages](/v7/docs/reference/ai-sdk-core/validate-ui-messages)
  - [safeValidateUIMessages](/v7/docs/reference/ai-sdk-core/safe-validate-ui-messages)
  - [Experimental_SandboxSession](/v7/docs/reference/ai-sdk-core/sandbox)
  - [createProviderRegistry](/v7/docs/reference/ai-sdk-core/provider-registry)
  - [customProvider](/v7/docs/reference/ai-sdk-core/custom-provider)
  - [cosineSimilarity](/v7/docs/reference/ai-sdk-core/cosine-similarity)
  - [wrapLanguageModel](/v7/docs/reference/ai-sdk-core/wrap-language-model)
  - [wrapImageModel](/v7/docs/reference/ai-sdk-core/wrap-image-model)
  - [LanguageModelV4Middleware](/v7/docs/reference/ai-sdk-core/language-model-v2-middleware)
  - [extractReasoningMiddleware](/v7/docs/reference/ai-sdk-core/extract-reasoning-middleware)
  - [simulateStreamingMiddleware](/v7/docs/reference/ai-sdk-core/simulate-streaming-middleware)
  - [defaultSettingsMiddleware](/v7/docs/reference/ai-sdk-core/default-settings-middleware)
  - [addToolInputExamplesMiddleware](/v7/docs/reference/ai-sdk-core/add-tool-input-examples-middleware)
  - [extractJsonMiddleware](/v7/docs/reference/ai-sdk-core/extract-json-middleware)
  - [isStepCount](/v7/docs/reference/ai-sdk-core/is-step-count)
  - [hasToolCall](/v7/docs/reference/ai-sdk-core/has-tool-call)
  - [isLoopFinished](/v7/docs/reference/ai-sdk-core/loop-finished)
  - [simulateReadableStream](/v7/docs/reference/ai-sdk-core/simulate-readable-stream)
  - [smoothStream](/v7/docs/reference/ai-sdk-core/smooth-stream)
  - [generateId](/v7/docs/reference/ai-sdk-core/generate-id)
  - [createIdGenerator](/v7/docs/reference/ai-sdk-core/create-id-generator)
  - [DefaultGeneratedFile](/v7/docs/reference/ai-sdk-core/default-generated-file)
- [AI SDK UI](/v7/docs/reference/ai-sdk-ui)
  - [useChat](/v7/docs/reference/ai-sdk-ui/use-chat)
  - [useCompletion](/v7/docs/reference/ai-sdk-ui/use-completion)
  - [useObject](/v7/docs/reference/ai-sdk-ui/use-object)
  - [experimental_useRealtime](/v7/docs/reference/ai-sdk-ui/use-realtime)
  - [convertToModelMessages](/v7/docs/reference/ai-sdk-ui/convert-to-model-messages)
  - [pruneMessages](/v7/docs/reference/ai-sdk-ui/prune-messages)
  - [createUIMessageStream](/v7/docs/reference/ai-sdk-ui/create-ui-message-stream)
  - [createUIMessageStreamResponse](/v7/docs/reference/ai-sdk-ui/create-ui-message-stream-response)
  - [pipeUIMessageStreamToResponse](/v7/docs/reference/ai-sdk-ui/pipe-ui-message-stream-to-response)
  - [readUIMessageStream](/v7/docs/reference/ai-sdk-ui/read-ui-message-stream)
  - [InferUITools](/v7/docs/reference/ai-sdk-ui/infer-ui-tools)
  - [InferUITool](/v7/docs/reference/ai-sdk-ui/infer-ui-tool)
  - [experimental_MCPAppRenderer](/v7/docs/reference/ai-sdk-ui/mcp-app-renderer)
  - [DirectChatTransport](/v7/docs/reference/ai-sdk-ui/direct-chat-transport)
- [AI SDK RSC](/v7/docs/reference/ai-sdk-rsc)
  - [streamUI](/v7/docs/reference/ai-sdk-rsc/stream-ui)
  - [createAI](/v7/docs/reference/ai-sdk-rsc/create-ai)
  - [createStreamableUI](/v7/docs/reference/ai-sdk-rsc/create-streamable-ui)
  - [createStreamableValue](/v7/docs/reference/ai-sdk-rsc/create-streamable-value)
  - [readStreamableValue](/v7/docs/reference/ai-sdk-rsc/read-streamable-value)
  - [getAIState](/v7/docs/reference/ai-sdk-rsc/get-ai-state)
  - [getMutableAIState](/v7/docs/reference/ai-sdk-rsc/get-mutable-ai-state)
  - [useAIState](/v7/docs/reference/ai-sdk-rsc/use-ai-state)
  - [useActions](/v7/docs/reference/ai-sdk-rsc/use-actions)
  - [useUIState](/v7/docs/reference/ai-sdk-rsc/use-ui-state)
  - [useStreamableValue](/v7/docs/reference/ai-sdk-rsc/use-streamable-value)
  - [render (Removed)](/v7/docs/reference/ai-sdk-rsc/render)
- [AI SDK Workflow](/v7/docs/reference/ai-sdk-workflow)
  - [WorkflowAgent](/v7/docs/reference/ai-sdk-workflow/workflow-agent)
  - [WorkflowChatTransport](/v7/docs/reference/ai-sdk-workflow/workflow-chat-transport)
- [AI SDK Errors](/v7/docs/reference/ai-sdk-errors)
  - [AI_APICallError](/v7/docs/reference/ai-sdk-errors/ai-api-call-error)
  - [AI_DownloadError](/v7/docs/reference/ai-sdk-errors/ai-download-error)
  - [AI_EmptyResponseBodyError](/v7/docs/reference/ai-sdk-errors/ai-empty-response-body-error)
  - [AI_InvalidArgumentError](/v7/docs/reference/ai-sdk-errors/ai-invalid-argument-error)
  - [AI_InvalidDataContentError](/v7/docs/reference/ai-sdk-errors/ai-invalid-data-content-error)
  - [AI_InvalidMessageRoleError](/v7/docs/reference/ai-sdk-errors/ai-invalid-message-role-error)
  - [AI_InvalidPromptError](/v7/docs/reference/ai-sdk-errors/ai-invalid-prompt-error)
  - [AI_InvalidResponseDataError](/v7/docs/reference/ai-sdk-errors/ai-invalid-response-data-error)
  - [AI_InvalidToolApprovalError](/v7/docs/reference/ai-sdk-errors/ai-invalid-tool-approval-error)
  - [AI_InvalidToolApprovalSignatureError](/v7/docs/reference/ai-sdk-errors/ai-invalid-tool-approval-signature-error)
  - [AI_InvalidToolInputError](/v7/docs/reference/ai-sdk-errors/ai-invalid-tool-input-error)
  - [AI_JSONParseError](/v7/docs/reference/ai-sdk-errors/ai-json-parse-error)
  - [AI_LoadAPIKeyError](/v7/docs/reference/ai-sdk-errors/ai-load-api-key-error)
  - [AI_LoadSettingError](/v7/docs/reference/ai-sdk-errors/ai-load-setting-error)
  - [AI_MessageConversionError](/v7/docs/reference/ai-sdk-errors/ai-message-conversion-error)
  - [AI_NoContentGeneratedError](/v7/docs/reference/ai-sdk-errors/ai-no-content-generated-error)
  - [AI_NoImageGeneratedError](/v7/docs/reference/ai-sdk-errors/ai-no-image-generated-error)
  - [AI_NoObjectGeneratedError](/v7/docs/reference/ai-sdk-errors/ai-no-object-generated-error)
  - [AI_NoOutputGeneratedError](/v7/docs/reference/ai-sdk-errors/ai-no-output-generated-error)
  - [AI_NoSpeechGeneratedError](/v7/docs/reference/ai-sdk-errors/ai-no-speech-generated-error)
  - [AI_NoSuchModelError](/v7/docs/reference/ai-sdk-errors/ai-no-such-model-error)
  - [AI_NoSuchProviderError](/v7/docs/reference/ai-sdk-errors/ai-no-such-provider-error)
  - [AI_NoSuchProviderReferenceError](/v7/docs/reference/ai-sdk-errors/ai-no-such-provider-reference-error)
  - [AI_NoSuchToolError](/v7/docs/reference/ai-sdk-errors/ai-no-such-tool-error)
  - [AI_NoTranscriptGeneratedError](/v7/docs/reference/ai-sdk-errors/ai-no-transcript-generated-error)
  - [AI_NoVideoGeneratedError](/v7/docs/reference/ai-sdk-errors/ai-no-video-generated-error)
  - [AI_RetryError](/v7/docs/reference/ai-sdk-errors/ai-retry-error)
  - [AI_TooManyEmbeddingValuesForCallError](/v7/docs/reference/ai-sdk-errors/ai-too-many-embedding-values-for-call-error)
  - [AI_ToolCallNotFoundForApprovalError](/v7/docs/reference/ai-sdk-errors/ai-tool-call-not-found-for-approval-error)
  - [ToolCallRepairError](/v7/docs/reference/ai-sdk-errors/ai-tool-call-repair-error)
  - [AI_TypeValidationError](/v7/docs/reference/ai-sdk-errors/ai-type-validation-error)
  - [AI_UIMessageStreamError](/v7/docs/reference/ai-sdk-errors/ai-ui-message-stream-error)
  - [AI_UnsupportedFunctionalityError](/v7/docs/reference/ai-sdk-errors/ai-unsupported-functionality-error)
- [AI SDK TUI](/v7/docs/reference/ai-sdk-tui)
  - [runAgentTUI](/v7/docs/reference/ai-sdk-tui/run-agent-tui)


[Full Sitemap](/sitemap.md)
