@seedkit-ai/ai-sdk-provider
v0.1.7
Published
Seed adapter for AI SDK
Downloads
166
Maintainers
Readme
AI SDK Seed Adapter
Seed (Doubao) provider for the AI SDK.
Installation
npm install @seedkit-ai/ai-sdk-providerSetup
Set your Seed API key as an environment variable:
export ARK_API_KEY=your-api-keyOr pass it directly when creating the provider:
import { createSeed } from '@seedkit-ai/ai-sdk-provider';
const seed = createSeed({
apiKey: 'your-api-key',
});Usage
Basic Text Generation
import { generateText } from 'ai';
import { seed } from '@seedkit-ai/ai-sdk-provider';
const { text } = await generateText({
model: seed('doubao-seed-1-8-251228'),
prompt: 'What is the meaning of life?',
});
console.log(text);Streaming
import { streamText } from 'ai';
import { seed } from '@seedkit-ai/ai-sdk-provider';
const result = streamText({
model: seed('doubao-seed-1-8-251228'),
prompt: 'Write a short story about a robot.',
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}Extended Thinking Mode
Enable extended thinking to get reasoning content from the model:
import { streamText } from 'ai';
import { seed } from '@seedkit-ai/ai-sdk-provider';
const result = streamText({
model: seed('doubao-seed-1-8-251228'),
prompt: 'Solve this step by step: What is 23 * 47?',
providerOptions: {
seed: {
thinking: true,
},
},
});
for await (const part of result.fullStream) {
if (part.type === 'reasoning-delta') {
process.stdout.write(`[Thinking] ${part.text}`);
} else if (part.type === 'text-delta') {
process.stdout.write(part.text);
}
}PDF File Support
You can include PDF files in your messages:
import { generateText } from 'ai';
import { seed } from '@seedkit-ai/ai-sdk-provider';
import fs from 'fs';
const pdfBuffer = fs.readFileSync('document.pdf');
const { text } = await generateText({
model: seed('doubao-seed-1-6-vision-250815'),
messages: [
{
role: 'user',
content: [
{
type: 'file',
data: pdfBuffer,
mimeType: 'application/pdf',
},
{
type: 'text',
text: 'Summarize this PDF document.',
},
],
},
],
});Image Generation
Generate images using Seed's image models:
import { generateImage } from 'ai';
import { seed } from '@seedkit-ai/ai-sdk-provider';
const { images } = await generateImage({
model: seed.image('doubao-seedream-4-5-251128'),
prompt: 'A beautiful sunset over mountains',
size: '1024x1024',
});
// images[0] contains the base64 encoded imageTool Calling
import { generateText } from 'ai';
import { seed } from '@seedkit-ai/ai-sdk-provider';
import { z } from 'zod';
const { text, toolCalls } = await generateText({
model: seed('doubao-seed-1-8-251228'),
prompt: 'What is the weather in San Francisco?',
tools: {
getWeather: {
description: 'Get the weather for a location',
parameters: z.object({
location: z.string().describe('The city name'),
}),
execute: async ({ location }) => {
return { temperature: 72, condition: 'sunny' };
},
},
},
});Web Search Tool
Use the built-in web search tool:
import { generateText } from 'ai';
import { seed, seedTools } from '@seedkit-ai/ai-sdk-provider';
const { text } = await generateText({
model: seed('doubao-seed-1-8-251228'),
prompt: 'What are the latest news about AI?',
tools: {
webSearch: seedTools.webSearch(),
},
});Supported Models
Chat Models
doubao-seed-1-8-251228- Latest Doubao Seed modeldoubao-seed-code-preview-251028- Code-optimized modeldoubao-seed-1-6-lite-251015- Lightweight modeldoubao-seed-1-6-flash-250828- Fast inference modeldoubao-seed-1-6-vision-250815- Vision-capable model (supports images and PDFs)
Image Models
doubao-seedream-4-5-251128- Latest Seedream image generation modeldoubao-seedream-4-0-250828- Seedream 4.0 model
You can also use any model ID string for custom endpoints.
Provider Options
import { createSeed } from '@seedkit-ai/ai-sdk-provider';
const seed = createSeed({
// Custom base URL (default: https://ark.cn-beijing.volces.com/api/v3)
baseURL: 'https://your-custom-endpoint.com/api/v3',
// API key (default: ARK_API_KEY env variable)
apiKey: 'your-api-key',
// Custom headers
headers: {
'X-Custom-Header': 'value',
},
// Custom fetch implementation
fetch: customFetch,
});Model Options
import { generateText } from 'ai';
import { seed } from '@seedkit-ai/ai-sdk-provider';
const { text } = await generateText({
model: seed('doubao-seed-1-8-251228'),
prompt: 'Hello!',
providerOptions: {
seed: {
// Enable extended thinking mode
thinking: true,
// Enable structured outputs
structuredOutputs: true,
// Enable strict JSON schema validation
strictJsonSchema: false,
// Enable parallel tool calls
parallelToolCalls: true,
},
},
});License
MIT
