Skip to main content
The Workflow AI SDK provides provider functions that wrap AI SDK providers with durable execution capabilities. Each provider function creates a step function that returns a language model instance, ensuring proper state management in workflow contexts.

Overview

All provider functions follow the same pattern:
The provider wrappers automatically mark the model instantiation as a workflow step, ensuring durability.

Anthropic

Integrate with Claude models from Anthropic.

Import

Usage

Signature

object
Returns: Function that accepts a model ID and returns a Promise resolving to a LanguageModel

Available Models

  • claude-3-5-sonnet-20241022 - Latest Sonnet (most balanced)
  • claude-3-5-haiku-20241022 - Fast and efficient
  • claude-3-opus-20240229 - Most capable (legacy)
  • claude-3-sonnet-20240229 - Balanced (legacy)
  • claude-3-haiku-20240307 - Fast (legacy)
See Anthropic’s model documentation for the latest models.

Example

OpenAI

Integrate with GPT models from OpenAI.

Import

Usage

Signature

object
Returns: Function that accepts a model ID and returns a Promise resolving to a LanguageModel

Available Models

  • gpt-4o - Latest and most capable GPT-4 model
  • gpt-4o-mini - Affordable and intelligent small model
  • gpt-4-turbo - Previous flagship model
  • gpt-3.5-turbo - Fast and cost-effective
  • o1-preview - Advanced reasoning (limited features)
  • o1-mini - Fast reasoning model
See OpenAI’s model documentation for the latest models.

Example

Google AI

Integrate with Gemini models from Google.

Import

Usage

Signature

object
Returns: Function that accepts a model ID and returns a Promise resolving to a LanguageModel

Available Models

  • gemini-2.0-flash-exp - Latest experimental Flash model
  • gemini-1.5-pro - Most capable production model
  • gemini-1.5-flash - Fast and efficient
  • gemini-1.0-pro - Legacy production model
See Google’s model documentation for the latest models.

Example

xAI

Integrate with Grok models from xAI.

Import

Usage

Signature

object
Returns: Function that accepts a model ID and returns a Promise resolving to a LanguageModel

Available Models

  • grok-2-latest - Latest Grok 2 model
  • grok-2-1212 - Grok 2 from December 2024
  • grok-beta - Beta version with latest features
See xAI’s documentation for the latest models.

Example

Using AI Gateway

Instead of provider functions, you can use Vercel AI Gateway with a string model identifier:
This approach:
  • Centralizes API key management
  • Provides built-in caching and rate limiting
  • Enables easy provider switching
  • Requires AI Gateway configuration

Provider Comparison

Best Practices

  1. Use environment variables: Store API keys in environment variables, never hardcode them
  2. Choose the right model: Use smaller/faster models for simple tasks, larger models for complex reasoning
  3. Set appropriate limits: Configure maxOutputTokens based on your use case
  4. Handle rate limits: Workflow steps automatically retry on rate limits
  5. Monitor costs: Track token usage through step results and telemetry
  6. Test locally: Use local development mode to test without consuming API credits

See Also