Vercel
This page adapts the original AI SDK documentation: Vercel.
The Vercel provider gives you access to the v0 API, designed for building modern web applications. The v0 models support text and image inputs and provide fast streaming responses.
You can create your Vercel API key at v0.dev.
Note: The v0 API is currently in beta and requires a Premium or Team plan with usage-based billing enabled. For details, visit the v0.dev pricing page. To request a higher limit, contact Vercel at support@v0.dev.
Features
Section titled “Features”- Framework aware completions: Evaluated on modern stacks like Next.js and Vercel
- Auto-fix: Identifies and corrects common coding issues during generation
- Quick edit: Streams inline edits as they’re available
- Multimodal: Supports both text and image inputs
The Vercel provider is available in the VercelProvider module. Add it to your Swift package:
// Package.swift (excerpt)dependencies: [ .package(url: "https://github.com/teunlao/swift-ai-sdk", from: "0.14.0")],targets: [ .target( name: "YourTarget", dependencies: [ .product(name: "SwiftAISDK", package: "swift-ai-sdk"), .product(name: "VercelProvider", package: "swift-ai-sdk") ] )]Provider Instance
Section titled “Provider Instance”You can import the default provider instance vercel from VercelProvider:
import SwiftAISDKimport VercelProvider
let model = vercel("v0-1.5-md")If you need a customized setup, you can use createVercel and create a provider instance with your settings:
import VercelProvider
let vercel = createVercel(settings: VercelProviderSettings( apiKey: ProcessInfo.processInfo.environment["VERCEL_API_KEY"], baseURL: "https://api.v0.dev/v1", headers: ["X-Custom-Header": "value"]))You can use the following optional settings to customize the Vercel provider instance:
-
baseURL string
Use a different URL prefix for API calls. The default prefix is
https://api.v0.dev/v1. -
apiKey string
API key that is being sent using the
Authorizationheader. It defaults to theVERCEL_API_KEYenvironment variable. -
headers Record<string,string>
Custom headers to include in the requests.
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation (middleware) for testing or request interception.
Language Models
Section titled “Language Models”You can create language models using a provider instance. The first argument is the model ID, for example:
import SwiftAISDKimport VercelProvider
let result = try await generateText( model: vercel("v0-1.5-md"), prompt: "Create a Next.js AI chatbot")
print(result.text)Vercel language models can also be used in streamText (see Generating & Streaming Text).
Models
Section titled “Models”v0-1.5-md
Section titled “v0-1.5-md”The v0-1.5-md model is for everyday tasks and UI generation.
v0-1.5-lg
Section titled “v0-1.5-lg”The v0-1.5-lg model is for advanced thinking or reasoning.
v0-1.0-md (legacy)
Section titled “v0-1.0-md (legacy)”The v0-1.0-md model is the legacy model served by the v0 API.
All v0 models have the following capabilities:
- Supports text and image inputs (multimodal)
- Supports function/tool calls
- Streaming responses with low latency
- Optimized for frontend and full-stack web development
Model Capabilities
Section titled “Model Capabilities”| Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
|---|---|---|---|---|
v0-1.5-md | ✓ | ✓ | ✓ | ✓ |
v0-1.5-lg | ✓ | ✓ | ✓ | ✓ |
v0-1.0-md | ✓ | ✓ | ✓ | ✓ |