Gathering detailed insights and metrics for @daydreamsai/ai-sdk-provider
Gathering detailed insights and metrics for @daydreamsai/ai-sdk-provider
Gathering detailed insights and metrics for @daydreamsai/ai-sdk-provider
Gathering detailed insights and metrics for @daydreamsai/ai-sdk-provider
The OpenRouter provider for the Vercel AI SDK contains support for hundreds of models through the OpenRouter chat and completion APIs.
npm install @daydreamsai/ai-sdk-provider
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
304 Stars
93 Commits
51 Forks
7 Watchers
6 Branches
12 Contributors
Updated on Jul 11, 2025
Latest Version
0.0.10
Package Id
@daydreamsai/ai-sdk-provider@0.0.10
Unpacked Size
695.62 kB
Size
127.64 kB
File Count
15
NPM Version
10.1.0
Node Version
20.9.0
Published on
Jul 11, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
The Dreams Router provider for the Vercel AI SDK gives access to large language models through the Dreams Router API (forked from OpenRouter).
1npm install @dreams/ai-sdk-provider viem x402
1import { 2 createDreamsRouterAuth, 3 generateX402Payment, 4} from '@dreams/ai-sdk-provider'; 5import { generateText } from 'ai'; 6import { privateKeyToAccount } from 'viem/accounts'; 7 8const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); 9 10const payment = await generateX402Payment(account, { 11 amount: '100000', // $0.10 USDC 12 network: 'base-sepolia', 13}); 14 15const { dreamsRouter, user } = await createDreamsRouterAuth(account, { 16 payment, 17}); 18 19const { text } = await generateText({ 20 model: dreamsRouter('openai/gpt-4o'), 21 prompt: 'Hello, Dreams Router!', 22});
1# For API key authentication 2DREAMSROUTER_API_KEY=your-api-key-here 3 4# For JWT session token authentication 5DREAMSROUTER_SESSION_TOKEN=your-jwt-session-token-here 6 7# For Node.js wallet signing 8PRIVATE_KEY=0x...
Dreams Router supports multiple authentication methods:
1import { createDreamsRouter } from '@dreams/ai-sdk-provider'; 2 3const dreamsrouter = createDreamsRouter({ 4 apiKey: process.env.DREAMSROUTER_API_KEY, 5 baseURL: 'https://dev-router.daydreams.systems/v1', 6});
1import { createDreamsRouter } from '@dreams/ai-sdk-provider'; 2 3const dreamsrouter = createDreamsRouter({ 4 sessionToken: process.env.DREAMSROUTER_SESSION_TOKEN, 5 baseURL: 'https://dev-router.daydreams.systems/v1', 6});
1import { 2 createDreamsRouterAuth, 3 generateX402Payment, 4} from '@dreams/ai-sdk-provider'; 5import { privateKeyToAccount } from 'viem/accounts'; 6 7const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); 8 9// Optional: Generate payment 10const payment = await generateX402Payment(account, { 11 amount: '100000', 12 network: 'base-sepolia', 13}); 14 15const auth = await createDreamsRouterAuth(account, { payment }); 16 17// Returns: { dreamsRouter, sessionToken, user, authManager }
Dreams Router uses viem's native Account interface for both authentication and payments - no custom abstractions!
1import { 2 createDreamsRouterAuth, 3 generateX402Payment, 4} from '@dreams/ai-sdk-provider'; 5import { privateKeyToAccount } from 'viem/accounts'; 6 7const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); 8const payment = await generateX402Payment(account, { amount: '100000' }); 9const auth = await createDreamsRouterAuth(account, { payment });
1import { 2 createDreamsRouterAuthBrowser, 3 createDreamsRouterFromToken, 4 generateX402PaymentBrowser, 5 walletLoginBrowser, 6} from '@dreams/ai-sdk-provider'; 7import { generateText } from 'ai'; 8import { useAccount, useSignMessage, useSignTypedData } from 'wagmi'; 9 10function MyComponent() { 11 const { address } = useAccount(); 12 const { signMessageAsync } = useSignMessage(); 13 const { signTypedDataAsync } = useSignTypedData(); 14 15 const handleLogin = async () => { 16 if (!address || !signMessageAsync) return; 17 18 // Option 1: Step-by-step approach 19 // First, login to get JWT token 20 const { sessionToken, user } = await walletLoginBrowser( 21 address, 22 signMessageAsync, 23 ); 24 25 // Then create the router with the token 26 const dreamsRouter = createDreamsRouterFromToken(sessionToken, { 27 payments: { 28 amount: '100000', // $0.10 USDC 29 network: 'base-sepolia', 30 }, 31 }); 32 33 // Option 2: All-in-one approach 34 const auth = await createDreamsRouterAuthBrowser( 35 address, 36 signMessageAsync, 37 { 38 payments: { 39 amount: '100000', 40 network: 'base-sepolia', 41 }, 42 signTypedDataAsync, // Required for payments 43 }, 44 ); 45 46 // Use the router 47 const { text } = await generateText({ 48 model: auth.dreamsRouter('openai/gpt-4o'), 49 prompt: 'Hello from browser!', 50 }); 51 }; 52}
1import { getApiKeyWithPaymentBrowser } from '@dreams/ai-sdk-provider'; 2import { useAccount, useSignTypedData } from 'wagmi'; 3 4function PaymentComponent() { 5 const { address } = useAccount(); 6 const { signTypedDataAsync } = useSignTypedData(); 7 8 const getApiKey = async () => { 9 if (!address || !signTypedDataAsync) return; 10 11 const { apiKey, user } = await getApiKeyWithPaymentBrowser( 12 address, 13 signTypedDataAsync, 14 { 15 amount: '100000', // $0.10 USDC 16 network: 'base-sepolia', 17 }, 18 ); 19 20 // Use apiKey for subsequent requests 21 const dreamsRouter = createDreamsRouter({ apiKey }); 22 }; 23}
1import { 2 createDreamsRouterAuth, 3 generateX402Payment, 4} from '@dreams/ai-sdk-provider'; 5import { privateKeyToAccount } from 'viem/accounts'; 6 7// Use viem's native account creation 8const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); 9const payment = await generateX402Payment(account, { amount: '100000' }); 10const auth = await createDreamsRouterAuth(account, { payment });
1import { 2 createCustomAccount, 3 createDreamsRouterAuth, 4 generateX402Payment, 5} from '@dreams/ai-sdk-provider'; 6 7const account = createCustomAccount( 8 walletAddress, 9 async (message) => wallet.signMessage(message), 10 async (typedData) => wallet.signTypedData(typedData), // Required for payments 11); 12 13const payment = await generateX402Payment(account, { amount: '100000' }); 14const auth = await createDreamsRouterAuth(account, { payment });
Dreams Router supports automatic crypto payments using X402 protocol:
1import { 2 createDreamsRouterAuth, 3 generateX402Payment, 4} from '@dreams/ai-sdk-provider'; 5import { privateKeyToAccount } from 'viem/accounts'; 6 7const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); 8 9const payment = await generateX402Payment(account, { 10 amount: '100000', // $0.10 USDC 11 network: 'base-sepolia', 12 serviceWallet: '0x...', // Optional 13 validityDuration: 600, // Optional: 10 minutes 14}); 15 16const auth = await createDreamsRouterAuth(account, { payment });
1import { generateX402PaymentBrowser } from '@dreams/ai-sdk-provider'; 2import { useAccount, useSignTypedData } from 'wagmi'; 3 4const { address } = useAccount(); 5const { signTypedDataAsync } = useSignTypedData(); 6 7const payment = await generateX402PaymentBrowser(address!, signTypedDataAsync, { 8 amount: '100000', 9 network: 'base-sepolia', 10}); 11 12const auth = await createDreamsRouterAuth(account, { payment });
1// Authentication only - no payments 2const auth = await createDreamsRouterAuth(account, {});
Dreams Router automatically refreshes expired JWT tokens using your account:
1import { createWalletAuthManager } from '@dreams/ai-sdk-provider'; 2import { privateKeyToAccount } from 'viem/accounts'; 3 4const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); 5 6const authManager = createWalletAuthManager({ 7 baseURL: 'https://dev-router.daydreams.systems', 8 onTokenExpired: async () => { 9 // Automatically refresh token when expired 10 const { sessionToken } = await authManager.walletLogin(account); 11 return sessionToken; 12 }, 13}); 14 15// All API calls will automatically handle token refresh
Access Dreams Router platform features:
1import { DreamsRouterApiClient } from '@dreams/ai-sdk-provider'; 2 3const apiClient = new DreamsRouterApiClient(); 4 5// Get available models 6const models = await apiClient.getDetailedModels(); 7 8// Check wallet balance 9const balance = await apiClient.getWalletBalance(walletAddress); 10 11// Get usage statistics 12const stats = await apiClient.getWalletStats(walletAddress);
This provider is compatible with OpenRouter model IDs and API format. Check available models:
1const models = await apiClient.getDetailedModels(); 2console.log('Available models:', models.data?.models);
Dreams Router handles common errors gracefully:
Full TypeScript support with viem's native types:
1import type { Account } from 'viem'; 2import type { 3 DreamsRouterPaymentConfig, 4 ModelConfig, 5 UsageStats, 6 User, 7} from '@dreams/ai-sdk-provider';
Dreams Router AI SDK provides:
✅ Viem-Native: Uses viem's Account interface - no custom abstractions
✅ Multiple auth methods: API keys, JWT tokens, and wallet authentication
✅ Automatic payments: X402 crypto payment integration
✅ Cross-platform: Works in browser, Node.js, React Native, edge functions
✅ Auto token refresh: Seamless JWT token management
✅ Full API access: Complete Dreams Router platform integration
✅ TypeScript support: Comprehensive type definitions with viem
✅ Vercel AI SDK: Drop-in replacement for other providers
Key Innovation: Uses viem's native Account interface - familiar to all viem users!
No vulnerabilities found.
No security vulnerabilities found.