翻篇收录说明
翻篇网页快照

ByteDance | AI SDK

https://ai-sdk.dev/providers/ai-sdk-providers/bytedance

最近抓取:2026-12-06 14:48:01(北京时间)

最近内容变化:2026-12-04 03:45:26(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Learn how to use ByteDance with AI Gateway and the direct provider.

正文摘录

AI SDK ProvidersMenuByteDanceCopy for LLMView MarkdownAsk AI about this pageThe ByteDance provider contains support for the Seedance family of video generation models and the Seedream family of image generation models through the BytePlus ModelArk platform. Seedance provides high-quality text-to-video and image-to-video generation capabilities, including audio-video synchronization, first-and-last frame control, and multi-reference image generation (see the video generation API). Seedream provides text-to-image and image-to-image generation, including multi-image blending and batch image generation (see the image generation API). You can use ByteDance models through AI Gateway (recommended) or connect directly with @ai-sdk/bytedance. GatewayByteDancebytedance/seedream-5.0-proimport { generateImage } from 'ai'; const { image } = await generateImage({ model: "bytedance/seedream-5.0-pro", prompt: 'A sunlit mountain village in watercolor.', }); console.log(image.base64); Using AI Gateway The AI SDK uses AI Gateway by default for model strings. Gateway provides access to models across providers through a single API key, with usage and cost tracking. Install ai: pnpmnpmyarnbun$ pnpm add ai Set an AI Gateway API key in your environment: export AI_GATEWAY_API_KEY=your_api_key_here Vercel deployments can also use OIDC authentication. See the AI Gateway provider documentation for configuration and the model catalog for available models. Gateway feature and provider-option support depends on the model and the provider serving the request. See Gateway provider options. Using @ai-sdk/bytedance For direct access to ByteDance, install ai and @ai-sdk/bytedance: pnpmnpmyarnbun$ pnpm add ai @ai-sdk/bytedance Set your ByteDance API credential in the ARK_API_KEY environment variable: export ARK_API_KEY=your_api_key_here AI Gateway does not expose every API in @ai-sdk/bytedance. Use the direct provider for provider-specific APIs or custom connection settings. The following sections document the direct @ai-sdk/bytedance provider, including its model factories and settings. Gateway model and feature availability can differ. Provider Instance You can import the default provider instance byteDance from @ai-sdk/bytedance: import { byteDance } from '@ai-sdk/bytedance'; If you need a customized setup, you can import createByteDance and create a provider instance with your settings: import { createByteDance } from '@ai-sdk/bytedance'; const byteDance = createByteDance({ apiKey: 'your-api-key', // optional, defaults to ARK_API_KEY environment variable baseURL: 'custom-url', // optional headers: { /* custom headers */ }, // optional }); You can use the following optional settings to customize the ByteDance provider instance: baseURL string Use a different URL prefix for API calls, e.g. to use proxy servers. The default prefix is https://ark.ap-southeast.bytepluses.com/api/v3. apiKey string | PromiseLike<string> | (() => string | PromiseLike<string>) Pass a function to resolve credentials before each request, including when keys rotate. The function can return a string or a promise. Credential caching and refresh are managed by the function. API key that is being sent using the Authorization header. It defaults to the ARK_API_KEY environment variable. You can obtain an API key from the BytePlus console. headers Record<string,string> Custom headers to include in the requests. fetch (input: RequestInfo, init?: RequestInit) => Promise<Response> Custom fetch implementation. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing. Model Capabilities Use byteDanceModelCapabilities(modelId) from @ai-sdk/bytedance to look up a model's declared capabilities and provider options, grouped by endpoint. Image Models You can create ByteDance Seedream image models using the .image() factory method. For more on image generation with the AI SDK see generateImage(). Text-to-Image Generate images from text prompts: import { byteDance, type ByteDanceImageModelOptions } from '@ai-sdk/bytedance'; import { generateImage } from 'ai'; const { image } = await generateImage({ model: byteDance.image('seedream-5-0-260128'), prompt: 'A salamander in a forest pond at dusk surrounded by fireflies', size: '2048x2048', providerOptions: { bytedance: { watermark: false, } satisfies ByteDanceImageModelOptions, }, }); ByteDance identifies Seedream models by their ModelArk model id (e.g. seedream-5-0-260128) or an account-specific endpoint id (e.g. ep-...). The size parameter accepts pixel dimensions ({width}x{height}); resolution levels such as 2K can be passed via providerOptions.bytedance.size. Image Editing Pass input images via prompt.images to transform an existing image (image-to-image): import { readFileSync } from 'node:fs'; import { byteDance, type ByteDanceImageModelOptions } from '@ai-sdk/bytedance'; import { generateImage } from 'ai'; const inputImage = readFileSync('./input-image.png'); const { image } = await generateImage({ model: byteDance.image('seedream-5-0-260128'), prompt: { text: 'Change the salamander to a snow weasel', images: [inputImage], }, providerOptions: { bytedance: { watermark: false, } satisfies ByteDanceImageModelOptions, }, }); You can also pass multiple images to blend styles and elements from several references into a single output (multi-image blending). Images may be provided as binary data, base64 strings, or URLs: import { byteDance, type ByteDanceImageModelOptions } from '@ai-sdk/bytedance'; import { generateImage } from 'ai'; const { image } = await generateImage({ model: byteDance.image('seedream-5-0-260128'), prompt: { text: 'Replace the clothing in image 1 with the outfit from image 2', images: ['https://example.com/model.png', 'https://example.com/outfit.png'], }, providerOptions: { bytedance: { watermark: false, } satisfies ByteDanceImageModelOptions, }, }); Seedream does not support mask-based inpainting. Describe the edit in the prompt, optionally with markers drawn on the input image (interactive editing, supported by dola-seedream-5-0-pro-260628). Image Model Options The following options are available via providerOptions.bytedance. You can type them with ByteDanceImageModelOptions. watermark boolean Whether to add an "AI generated" watermark to the bottom-right corner of the output image. outputFormat 'png' | 'jpeg' Format of the generated image file. Supported by seedream-5-0 and dola-seedream-5-0-pro; seedream-4-5 / seedream-4-0 always return jpeg. size string A resolution level (e.g. 1K, 2K, 3K, 4K) as an alternative to passing pixel dimensions via the top-level size parameter. When set, this overrides the top-level size. Available levels vary by model. sequentialImageGeneration 'auto' | 'disabled' Set to 'auto' to generate a batch of related images (e.g. storyboards or brand visuals). Defaults to 'disabled' (single image). maxImages number Maximum number of images to generate when sequentialImageGeneration is 'auto'. The number of input reference images plus generated images must not exceed the model's limit. optimizePromptMode 'standard' | 'fast' Prompt optimization mode. seedream-4-0 supports both standard and fast; other models support standard only. Additional ModelArk fields can also be passed through providerOptions.bytedance and are validated by ModelArk. Image Model Capabilities ModelNameCapabilitiesImage EditingMask InputMax Images Per Calldola-seedream-5-0-pro-260628Seedream 5.0 ProText-to-image, single/multi image-to-image, interactive editing (markers). Sizes: 1K, 2K. Formats: png, jpeg. Up to 10 references.1seedream-5-0-260128Seedream 5.0 LiteText-to-image, single/multi image-to-image, batch generation. Sizes: 2K, 3K, 4K. Formats: png, jpeg. Up to 14 references.1seedream-5-0-lite-260128Seedream 5.0 LiteText-to-image, single/multi image-to-image, batch generation. Sizes: 2K, 3K, 4K. Formats: png, jpeg. Up to 14 references.1seedream-4-5-251128Seedream 4.5Text-to-image, single/multi image-to-image, batch generation. Sizes: 2K, 4K. Format: jpeg. Up to 14 references.1seedream-4-0-250828Seedream 4.0Text-to-image, single/multi image-to-image, batch generation, fast prompt mode. Sizes: 1K, 2K, 4K. Format: jpeg. Up to 14 references.1 You can also pass any model or endpoint id string if needed, e.g. for future models not yet listed here. Streaming image output is not currently supported through the AI SDK integration. Video Models You can create ByteDance video models using the .video() factory method. For more on video generation with the AI SDK see generateVideo(). Text-to-Video Generate videos from text prompts: import { byteDance, type ByteDanceVideoModelOptions } from '@ai-sdk/bytedance'; import { experimental_generateVideo as generateVideo } from 'ai'; const { video } = await generateVideo({ model: byteDance.video('seedance-1-0-pro-250528'), prompt: 'Photorealistic style: Under a clear blue sky, a vast expanse of white daisy fields stretches out. The camera gradually zooms in and fixates on a close-up of a single daisy.', aspectRatio: '16:9', duration: 5, providerOptions: { bytedance: { watermark: false, } satisfies ByteDanceVideoModelOptions, }, }); console.log(video.url); Image-to-Video Generate videos from a first-frame image with an optional text prompt: import { byteDance, type ByteDanceVideoModelOptions } from '@ai-sdk/bytedance'; import { experimental_generateVideo as generateVideo } from 'ai'; const { video } = await generateVideo({ model: byteDance.video('seedance-1-5-pro-251215'), prompt: { image: 'https://example.com/first-frame.png', text: 'The cat slowly turns its head and blinks', }, duration: 5, providerOptions: { bytedance: { watermark: false, } satisfies ByteDanceVideoModelOptions, }, }); When the output ratio is dictated by an input — first-frame or first-and-last-frame image-to-video, video editing, and video extension — pass aspectRatio: 'adaptive' or omit aspectRatio entirely. Newer Seedance models reject an explicit ratio on those pat