
# 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: 'generateObject()',
      description: 'Generate structured data from a language model.',
      href: '/docs/reference/ai-sdk-core/generate-object',
    },
    {
      title: 'streamObject()',
      description: 'Stream structured data from a language model.',
      href: '/docs/reference/ai-sdk-core/stream-object',
    },
    {
      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: 'experimental_generateImage()',
      description:
        'Generate images based on a given prompt using an image model.',
      href: '/docs/reference/ai-sdk-core/generate-image',
    },
    {
      title: 'experimental_transcribe()',
      description: 'Generate a transcript from an audio file.',
      href: '/docs/reference/ai-sdk-core/transcribe',
    },
    {
      title: 'experimental_generateSpeech()',
      description: 'Generate speech audio from text.',
      href: '/docs/reference/ai-sdk-core/generate-speech',
    },
  ]}
/>

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_createMCPClient()',
      description: 'Creates a client for connecting to MCP servers.',
      href: '/docs/reference/ai-sdk-core/create-mcp-client',
    },
    {
      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: '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: '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 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](/v5/docs/reference/ai-sdk-core)
  - [generateText](/v5/docs/reference/ai-sdk-core/generate-text)
  - [streamText](/v5/docs/reference/ai-sdk-core/stream-text)
  - [generateObject](/v5/docs/reference/ai-sdk-core/generate-object)
  - [streamObject](/v5/docs/reference/ai-sdk-core/stream-object)
  - [embed](/v5/docs/reference/ai-sdk-core/embed)
  - [embedMany](/v5/docs/reference/ai-sdk-core/embed-many)
  - [generateImage](/v5/docs/reference/ai-sdk-core/generate-image)
  - [transcribe](/v5/docs/reference/ai-sdk-core/transcribe)
  - [generateSpeech](/v5/docs/reference/ai-sdk-core/generate-speech)
  - [tool](/v5/docs/reference/ai-sdk-core/tool)
  - [dynamicTool](/v5/docs/reference/ai-sdk-core/dynamic-tool)
  - [experimental_createMCPClient](/v5/docs/reference/ai-sdk-core/create-mcp-client)
  - [Experimental_StdioMCPTransport](/v5/docs/reference/ai-sdk-core/mcp-stdio-transport)
  - [jsonSchema](/v5/docs/reference/ai-sdk-core/json-schema)
  - [zodSchema](/v5/docs/reference/ai-sdk-core/zod-schema)
  - [valibotSchema](/v5/docs/reference/ai-sdk-core/valibot-schema)
  - [ModelMessage](/v5/docs/reference/ai-sdk-core/model-message)
  - [UIMessage](/v5/docs/reference/ai-sdk-core/ui-message)
  - [validateUIMessages](/v5/docs/reference/ai-sdk-core/validate-ui-messages)
  - [safeValidateUIMessages](/v5/docs/reference/ai-sdk-core/safe-validate-ui-messages)
  - [createProviderRegistry](/v5/docs/reference/ai-sdk-core/provider-registry)
  - [customProvider](/v5/docs/reference/ai-sdk-core/custom-provider)
  - [cosineSimilarity](/v5/docs/reference/ai-sdk-core/cosine-similarity)
  - [wrapLanguageModel](/v5/docs/reference/ai-sdk-core/wrap-language-model)
  - [LanguageModelV2Middleware](/v5/docs/reference/ai-sdk-core/language-model-v2-middleware)
  - [extractReasoningMiddleware](/v5/docs/reference/ai-sdk-core/extract-reasoning-middleware)
  - [simulateStreamingMiddleware](/v5/docs/reference/ai-sdk-core/simulate-streaming-middleware)
  - [defaultSettingsMiddleware](/v5/docs/reference/ai-sdk-core/default-settings-middleware)
  - [stepCountIs](/v5/docs/reference/ai-sdk-core/step-count-is)
  - [hasToolCall](/v5/docs/reference/ai-sdk-core/has-tool-call)
  - [simulateReadableStream](/v5/docs/reference/ai-sdk-core/simulate-readable-stream)
  - [smoothStream](/v5/docs/reference/ai-sdk-core/smooth-stream)
  - [generateId](/v5/docs/reference/ai-sdk-core/generate-id)
  - [createIdGenerator](/v5/docs/reference/ai-sdk-core/create-id-generator)
- [AI SDK UI](/v5/docs/reference/ai-sdk-ui)
  - [useChat](/v5/docs/reference/ai-sdk-ui/use-chat)
  - [useCompletion](/v5/docs/reference/ai-sdk-ui/use-completion)
  - [useObject](/v5/docs/reference/ai-sdk-ui/use-object)
  - [convertToModelMessages](/v5/docs/reference/ai-sdk-ui/convert-to-model-messages)
  - [pruneMessages](/v5/docs/reference/ai-sdk-ui/prune-messages)
  - [createUIMessageStream](/v5/docs/reference/ai-sdk-ui/create-ui-message-stream)
  - [createUIMessageStreamResponse](/v5/docs/reference/ai-sdk-ui/create-ui-message-stream-response)
  - [pipeUIMessageStreamToResponse](/v5/docs/reference/ai-sdk-ui/pipe-ui-message-stream-to-response)
  - [readUIMessageStream](/v5/docs/reference/ai-sdk-ui/read-ui-message-stream)
  - [InferUITools](/v5/docs/reference/ai-sdk-ui/infer-ui-tools)
  - [InferUITool](/v5/docs/reference/ai-sdk-ui/infer-ui-tool)
- [AI SDK RSC](/v5/docs/reference/ai-sdk-rsc)
  - [streamUI](/v5/docs/reference/ai-sdk-rsc/stream-ui)
  - [createAI](/v5/docs/reference/ai-sdk-rsc/create-ai)
  - [createStreamableUI](/v5/docs/reference/ai-sdk-rsc/create-streamable-ui)
  - [createStreamableValue](/v5/docs/reference/ai-sdk-rsc/create-streamable-value)
  - [readStreamableValue](/v5/docs/reference/ai-sdk-rsc/read-streamable-value)
  - [getAIState](/v5/docs/reference/ai-sdk-rsc/get-ai-state)
  - [getMutableAIState](/v5/docs/reference/ai-sdk-rsc/get-mutable-ai-state)
  - [useAIState](/v5/docs/reference/ai-sdk-rsc/use-ai-state)
  - [useActions](/v5/docs/reference/ai-sdk-rsc/use-actions)
  - [useUIState](/v5/docs/reference/ai-sdk-rsc/use-ui-state)
  - [useStreamableValue](/v5/docs/reference/ai-sdk-rsc/use-streamable-value)
  - [render (Removed)](/v5/docs/reference/ai-sdk-rsc/render)
- [Stream Helpers](/v5/docs/reference/stream-helpers)
  - [AIStream](/v5/docs/reference/stream-helpers/ai-stream)
  - [StreamingTextResponse](/v5/docs/reference/stream-helpers/streaming-text-response)
  - [streamToResponse](/v5/docs/reference/stream-helpers/stream-to-response)
  - [OpenAIStream](/v5/docs/reference/stream-helpers/openai-stream)
  - [AnthropicStream](/v5/docs/reference/stream-helpers/anthropic-stream)
  - [AWSBedrockStream](/v5/docs/reference/stream-helpers/aws-bedrock-stream)
  - [AWSBedrockAnthropicStream](/v5/docs/reference/stream-helpers/aws-bedrock-anthropic-stream)
  - [AWSBedrockAnthropicMessagesStream](/v5/docs/reference/stream-helpers/aws-bedrock-messages-stream)
  - [AWSBedrockCohereStream](/v5/docs/reference/stream-helpers/aws-bedrock-cohere-stream)
  - [AWSBedrockLlama2Stream](/v5/docs/reference/stream-helpers/aws-bedrock-llama-2-stream)
  - [CohereStream](/v5/docs/reference/stream-helpers/cohere-stream)
  - [GoogleGenerativeAIStream](/v5/docs/reference/stream-helpers/google-generative-ai-stream)
  - [HuggingFaceStream](/v5/docs/reference/stream-helpers/hugging-face-stream)
  - [@ai-sdk/langchain Adapter](/v5/docs/reference/stream-helpers/langchain-adapter)
  - [@ai-sdk/llamaindex Adapter](/v5/docs/reference/stream-helpers/llamaindex-adapter)
  - [MistralStream](/v5/docs/reference/stream-helpers/mistral-stream)
  - [ReplicateStream](/v5/docs/reference/stream-helpers/replicate-stream)
  - [InkeepStream](/v5/docs/reference/stream-helpers/inkeep-stream)
- [AI SDK Errors](/v5/docs/reference/ai-sdk-errors)
  - [AI_APICallError](/v5/docs/reference/ai-sdk-errors/ai-api-call-error)
  - [AI_DownloadError](/v5/docs/reference/ai-sdk-errors/ai-download-error)
  - [AI_EmptyResponseBodyError](/v5/docs/reference/ai-sdk-errors/ai-empty-response-body-error)
  - [AI_InvalidArgumentError](/v5/docs/reference/ai-sdk-errors/ai-invalid-argument-error)
  - [AI_InvalidDataContentError](/v5/docs/reference/ai-sdk-errors/ai-invalid-data-content-error)
  - [AI_InvalidDataContent](/v5/docs/reference/ai-sdk-errors/ai-invalid-data-content)
  - [AI_InvalidMessageRoleError](/v5/docs/reference/ai-sdk-errors/ai-invalid-message-role-error)
  - [AI_InvalidPromptError](/v5/docs/reference/ai-sdk-errors/ai-invalid-prompt-error)
  - [AI_InvalidResponseDataError](/v5/docs/reference/ai-sdk-errors/ai-invalid-response-data-error)
  - [AI_InvalidToolInputError](/v5/docs/reference/ai-sdk-errors/ai-invalid-tool-input-error)
  - [AI_JSONParseError](/v5/docs/reference/ai-sdk-errors/ai-json-parse-error)
  - [AI_LoadAPIKeyError](/v5/docs/reference/ai-sdk-errors/ai-load-api-key-error)
  - [AI_LoadSettingError](/v5/docs/reference/ai-sdk-errors/ai-load-setting-error)
  - [AI_MessageConversionError](/v5/docs/reference/ai-sdk-errors/ai-message-conversion-error)
  - [AI_NoContentGeneratedError](/v5/docs/reference/ai-sdk-errors/ai-no-content-generated-error)
  - [AI_NoImageGeneratedError](/v5/docs/reference/ai-sdk-errors/ai-no-image-generated-error)
  - [AI_NoObjectGeneratedError](/v5/docs/reference/ai-sdk-errors/ai-no-object-generated-error)
  - [AI_NoOutputSpecifiedError](/v5/docs/reference/ai-sdk-errors/ai-no-output-specified-error)
  - [AI_NoSpeechGeneratedError](/v5/docs/reference/ai-sdk-errors/ai-no-speech-generated-error)
  - [AI_NoSuchModelError](/v5/docs/reference/ai-sdk-errors/ai-no-such-model-error)
  - [AI_NoSuchProviderError](/v5/docs/reference/ai-sdk-errors/ai-no-such-provider-error)
  - [AI_NoSuchToolError](/v5/docs/reference/ai-sdk-errors/ai-no-such-tool-error)
  - [AI_NoTranscriptGeneratedError](/v5/docs/reference/ai-sdk-errors/ai-no-transcript-generated-error)
  - [AI_RetryError](/v5/docs/reference/ai-sdk-errors/ai-retry-error)
  - [AI_TooManyEmbeddingValuesForCallError](/v5/docs/reference/ai-sdk-errors/ai-too-many-embedding-values-for-call-error)
  - [ToolCallRepairError](/v5/docs/reference/ai-sdk-errors/ai-tool-call-repair-error)
  - [AI_TypeValidationError](/v5/docs/reference/ai-sdk-errors/ai-type-validation-error)
  - [AI_UnsupportedFunctionalityError](/v5/docs/reference/ai-sdk-errors/ai-unsupported-functionality-error)


[Full Sitemap](/sitemap.md)
