{"_id":"@aid-on/unillm-vercel-ai-sdk","name":"@aid-on/unillm-vercel-ai-sdk","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.2":{"name":"@aid-on/unillm-vercel-ai-sdk","version":"0.1.2","description":"Vercel AI SDK wrapper for @aid-on/unillm - provides LanguageModelV1 compatibility for existing AI SDK code","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"build":"tsc","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest"},"dependencies":{"@aid-on/unillm":"^0.5.5","ai":"^4.3.16"},"devDependencies":{"@types/node":"^22.10.2","typescript":"^5.7.2","vitest":"^2.1.8"},"peerDependencies":{"@cloudflare/workers-types":"^4.0.0"},"peerDependenciesMeta":{"@cloudflare/workers-types":{"optional":true}},"_id":"@aid-on/unillm-vercel-ai-sdk@0.1.2","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-3GwfrNI3uS4mD/8KlruX8pX6003HsTPUzPPbImG3+Ze4ri4YqM0xgT8NPiowp9pfdwejiUL2kq54TdfrBN3DoA==","shasum":"65f168f91464c01342d9c0ea0adbf042d4502204","tarball":"https://registry.npmjs.org/@aid-on/unillm-vercel-ai-sdk/-/unillm-vercel-ai-sdk-0.1.2.tgz","fileCount":11,"unpackedSize":26200,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCiXVGkydklXFXN9CUdk7SKHu9DeLizXnhLndop5Ak+yAIgN5X9IqF5frin06W6Q4t/d+6LUl0grdJd8/QIXuzeDsw="}]},"_npmUser":{"name":"aid-on","email":"hiromi.motodera@aid-on.org"},"directories":{},"maintainers":[{"name":"aid-on","email":"hiromi.motodera@aid-on.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unillm-vercel-ai-sdk_0.1.2_1771435098089_0.31822356994928946"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-18T17:18:17.992Z","0.1.2":"2026-02-18T17:18:18.243Z","modified":"2026-02-18T17:18:18.472Z"},"maintainers":[{"name":"aid-on","email":"hiromi.motodera@aid-on.org"}],"description":"Vercel AI SDK wrapper for @aid-on/unillm - provides LanguageModelV1 compatibility for existing AI SDK code","readme":"# @aid-on/unillm-vercel-ai-sdk\n\n<div align=\"center\">\n\n[![npm version](https://img.shields.io/npm/v/@aid-on/unillm-vercel-ai-sdk.svg?style=flat-square&color=00DC82)](https://www.npmjs.com/package/@aid-on/unillm-vercel-ai-sdk)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.7-3178C6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n\n<br />\n\n<h3><b>unillm-vercel-ai-sdk</b> - AI SDK Compatibility for Edge-Native LLM</h3>\n<p align=\"center\"><b>Bridge the gap between edge-native and ecosystem.</b><br/>Vercel AI SDK wrapper for @aid-on/unillm with LanguageModelV1 compatibility.</p>\n\n<br/>\n\n[**日本語**](./README.ja.md) | **English**\n\n<br/>\n\n</div>\n\n## Purpose\n\nThis package wraps the edge-native `@aid-on/unillm` library to provide Vercel AI SDK compatibility. Use this when:\n\n- **Migrating existing AI SDK code** to edge-native architecture\n- **Need LanguageModelV1 interface** for compatibility with AI SDK ecosystem\n- **Want edge optimization** without rewriting all your AI SDK calls\n\nFor new projects, consider using `@aid-on/unillm` directly for better edge performance.\n\n## Installation\n\n```bash\nnpm install @aid-on/unillm-vercel-ai-sdk\n```\n\n## Usage\n\nDrop-in replacement for AI SDK providers:\n\n```typescript\n// Before (using AI SDK providers directly)\nimport { createGroq } from \"@ai-sdk/groq\";\nimport { generateText } from \"ai\";\n\nconst groq = createGroq({ apiKey: process.env.GROQ_API_KEY });\nconst model = groq(\"llama-3.1-8b-instant\");\n\n// After (using unillm wrapper)\nimport { getModel } from \"@aid-on/unillm-vercel-ai-sdk\";\nimport { generateText } from \"ai\";\n\nconst model = getModel(\"groq:llama-3.1-8b-instant\", {\n  groqApiKey: process.env.GROQ_API_KEY,\n});\n\n// Same AI SDK calls work unchanged\nconst result = await generateText({\n  model,\n  prompt: \"Hello!\",\n});\n```\n\n## Multi-Provider Support\n\n```typescript\nimport { getModel, createFallbackChain } from \"@aid-on/unillm-vercel-ai-sdk\";\nimport { generateText } from \"ai\";\n\n// Unified interface for all providers\nconst groqModel = getModel(\"groq:llama-3.1-8b-instant\", credentials);\nconst geminiModel = getModel(\"gemini:gemini-2.0-flash\", credentials);\nconst cloudflareModel = getModel(\"cloudflare:@cf/meta/llama-3.3-70b-instruct-fp8-fast\", credentials);\n\n// Fallback chain\nconst chain = createFallbackChain({\n  models: [\n    \"groq:llama-3.1-8b-instant\",\n    \"gemini:gemini-2.0-flash\",\n  ],\n  credentials,\n});\n\nconst result = await chain.generate(async (model) => {\n  return generateText({ model, prompt: \"Hello\" });\n});\n```\n\n## Supported Models\n\nAll models from `@aid-on/unillm`:\n\n### Groq\n- `groq:llama-3.1-8b-instant`\n- `groq:llama-3.3-70b-versatile`\n- `groq:openai/gpt-oss-120b`\n- `groq:openai/gpt-oss-20b`\n\n### Gemini\n- `gemini:gemini-2.0-flash`\n- `gemini:gemini-2.0-flash-exp`\n\n### Cloudflare Workers AI\n- `cloudflare:@cf/meta/llama-3.3-70b-instruct-fp8-fast`\n- `cloudflare:@cf/meta/llama-3.1-8b-instruct`\n- `cloudflare:@cf/openai/gpt-oss-120b`\n- `cloudflare:@cf/openai/gpt-oss-20b`\n\n## Migration Guide\n\n### From Individual AI SDK Providers\n\n```typescript\n// Before\nimport { createGroq } from \"@ai-sdk/groq\";\nimport { createGoogleGenerativeAI } from \"@ai-sdk/google\";\n\nconst groq = createGroq({ apiKey: \"...\" });\nconst google = createGoogleGenerativeAI({ apiKey: \"...\" });\n\n// After\nimport { getModel } from \"@aid-on/unillm-vercel-ai-sdk\";\n\nconst groqModel = getModel(\"groq:llama-3.1-8b-instant\", { groqApiKey: \"...\" });\nconst geminiModel = getModel(\"gemini:gemini-2.0-flash\", { geminiApiKey: \"...\" });\n```\n\n### Benefits of Migration\n\n- **Unified interface** across all providers\n- **Edge-optimized** WebStreams support\n- **Memory efficient** for edge environments\n- **Built-in retry logic** with exponential backoff\n- **Structured output** with Zod validation\n- **Consistent error handling** across providers\n\n## Advanced Features\n\nAll advanced features from `@aid-on/unillm` are available:\n\n```typescript\nimport {\n  generateObject,\n  withRetry,\n} from \"@aid-on/unillm-vercel-ai-sdk\";\n\n// Structured output\nconst result = await generateObject({\n  model: \"groq:llama-3.1-8b-instant\",\n  credentials,\n  schema: z.object({ name: z.string() }),\n  prompt: \"Generate a person\",\n});\n\n// Retry logic\nconst retryResult = await withRetry(\n  () => generateText({ model, prompt }),\n  { maxAttempts: 3 }\n);\n```\n\n## API Reference\n\n### Wrapper Functions\n\n| Export | Description |\n|--------|------------|\n| `getModel(spec, credentials)` | Create a LanguageModelV1 instance from a model spec |\n| `createFallbackChain(options)` | Create a fallback chain across multiple providers |\n\n### Re-exported from @aid-on/unillm\n\n| Export | Description |\n|--------|------------|\n| `parseModelSpec` | Parse a model spec string into provider and model |\n| `createModelSpec` | Create a model spec from provider and model |\n| `hasCredentials` | Check if credentials are available for a provider |\n| `getCredentialsFromEnv` | Get credentials from environment variables |\n| `getModelInfo` | Get metadata for a model |\n| `getModelsByProvider` | List models for a provider |\n| `getAllSpecs` | Get all available model specs |\n| `getRecommendedModels` | Get recommended models |\n| `isValidSpec` | Validate a model spec string |\n| `generateObject` | Generate structured output with schema validation |\n| `extractJSON` | Extract JSON from LLM response text |\n| `withRetry` | Retry wrapper with exponential backoff |\n| `withRetryResult` | Retry wrapper returning detailed result |\n| `createRetryWrapper` | Create a reusable retry wrapper |\n| `LLMProviderError` | Error class for LLM provider errors |\n| `wrapError` | Wrap an error as LLMProviderError |\n| `isLLMError` | Type guard for LLMProviderError |\n| `isRetryable` | Check if an error is retryable |\n| `isRetryableCode` | Check if an error code is retryable |\n\n## Performance Comparison\n\n| Feature | @aid-on/unillm | @aid-on/unillm-vercel-ai-sdk |\n|---------|----------------|------------------------------|\n| Bundle size | ~50KB | ~200KB+ (includes AI SDK) |\n| Cold start | ~10ms | ~50ms+ |\n| Memory usage | Minimal | Higher (AI SDK overhead) |\n| Edge optimization | Native | Compatible |\n| AI SDK compatibility | No | Full |\n\n## Related Packages\n\n- **[@aid-on/unillm](../unillm)** - Edge-native core library (no AI SDK dependency)\n- **[@aid-on/unillm-vercel-ai-sdk](.)** - AI SDK compatibility wrapper (this package)\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-37bbd98837c77146d2308a58f8a86efc"}