{"_id":"@0xglitch/llm-sdk","name":"@0xglitch/llm-sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@0xglitch/llm-sdk","version":"0.1.0","description":"Unified LLM Gateway Library with Google Gemini primary support","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"scripts":{"build":"tsc","dev":"tsc --watch","test":"echo 'Tests require manual execution with GOOGLE_API_KEY environment variable'","test:unit":"echo 'Unit tests: Run with your preferred test framework'","test:integration":"echo 'Integration tests: Set GOOGLE_API_KEY and run manually'","lint":"tsc --noEmit","format":"prettier --write \"src/**/*.ts\"","prepublishOnly":"npm run build"},"keywords":["llm","gemini","openai","anthropic","ai","language-model"],"author":{"name":"Workflow Automation"},"license":"MIT","dependencies":{"@google/generative-ai":"^0.21.0","openai":"^4.73.0","@anthropic-ai/sdk":"^0.32.1"},"devDependencies":{"@types/node":"^22.10.2","typescript":"^5.6.3","prettier":"^3.4.2","tiktoken":"^1.0.18"},"engines":{"node":">=18.0.0"},"publishConfig":{"access":"public"},"_id":"@0xglitch/llm-sdk@0.1.0","gitHead":"8b759b74eb6539301e5f03e12f77e5ec9383cfb7","_nodeVersion":"24.9.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-vcDBjGP6nnp3qKww+Z+/mOpV2KnouKI5IxRfRfP6ZNAhNBOi56zqwlbKyY3HhJlqnFZ2ChLjXONhnFXmfzMUqQ==","shasum":"c537bb3ea9aba84565a43df1f3f01c8de2317a82","tarball":"https://registry.npmjs.org/@0xglitch/llm-sdk/-/llm-sdk-0.1.0.tgz","fileCount":38,"unpackedSize":108114,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCO819cKlvHZsgsMGG4P9BuA5IycXgFL4qi50iAt+kytQIgeB1UXQ4xUJ3XJN2lSIODC599YihDXP8P8lc5LeoOFac="}]},"_npmUser":{"name":"_0xglitch","email":"deepakkrsoni16@gmail.com"},"directories":{},"maintainers":[{"name":"_0xglitch","email":"deepakkrsoni16@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/llm-sdk_0.1.0_1760529774065_0.05271025862999745"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-15T12:02:53.682Z","0.1.0":"2025-10-15T12:02:54.253Z","modified":"2025-10-15T12:02:54.593Z"},"maintainers":[{"name":"_0xglitch","email":"deepakkrsoni16@gmail.com"}],"description":"Unified LLM Gateway Library with Google Gemini primary support","keywords":["llm","gemini","openai","anthropic","ai","language-model"],"author":{"name":"Workflow Automation"},"license":"MIT","readme":"# @0xglitch/llm-sdk\n\nUnified LLM Gateway Library with Google Gemini primary support.\n\n## Features\n\n- **Google Gemini Support (PRIMARY)**: gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash, gemini-2.0-pro, gemini-1.5-pro, gemini-1.5-flash\n- **OpenAI Support (OPTIONAL)**: gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4o, gpt-4o-mini, gpt-4-turbo, o3-mini\n- **Anthropic Support (OPTIONAL)**: claude-sonnet-4.5, claude-opus-4.1, claude-sonnet-4, claude-3.5-sonnet, claude-3.5-haiku\n- **Intelligent Model Routing**: Complexity-based model selection\n- **Retry Logic**: Exponential backoff (3 retries, 2s/4s/8s delays)\n- **Token Counting**: Accurate token usage tracking for all providers\n- **Streaming Support**: Real-time response streaming\n- **Fallback Mechanism**: Automatic provider switching on failure\n\n## Installation\n\n```bash\nnpm install @workflow/llm-sdk\n```\n\n## Quick Start\n\n```typescript\nimport { LLMClient } from '@workflow/llm-sdk';\n\n// Initialize with Gemini only (default)\nconst client = new LLMClient({\n  geminiApiKey: process.env.GOOGLE_API_KEY\n});\n\n// Simple completion\nconst response = await client.complete({\n  prompt: 'Explain quantum computing in simple terms',\n  complexity: 'simple' // Uses gemini-2.5-flash-lite (2025 default)\n});\n\nconsole.log(response.content);\nconsole.log(`Tokens used: ${response.tokenUsage.total}`);\n```\n\n## Configuration\n\n```typescript\nimport { LLMClient } from '@workflow/llm-sdk';\n\nconst client = new LLMClient({\n  // Primary provider (required)\n  geminiApiKey: process.env.GOOGLE_API_KEY,\n\n  // Optional fallback providers\n  openaiApiKey: process.env.OPENAI_API_KEY,\n  anthropicApiKey: process.env.ANTHROPIC_API_KEY,\n\n  // Default provider preference\n  defaultProvider: 'gemini', // 'gemini' | 'openai' | 'anthropic'\n\n  // Retry configuration\n  retries: 3,\n  retryDelays: [2000, 4000, 8000]\n});\n```\n\n## Model Selection\n\nThe library automatically selects the best model based on task complexity:\n\n- **Simple tasks** → `gemini-2.5-flash-lite` (2025 default: fast, low-cost, high-performance)\n- **Complex tasks** → `gemini-2.5-pro` (2025 default: most powerful with adaptive thinking)\n- **Fallback** → OpenAI (gpt-4.1-nano/gpt-4.1) or Anthropic (claude-sonnet-4/claude-sonnet-4.5) if configured\n\n```typescript\n// Simple task (uses gemini-2.5-flash-lite - 2025 default)\nconst simpleResponse = await client.complete({\n  prompt: 'What is 2+2?',\n  complexity: 'simple'\n});\n\n// Complex task (uses gemini-2.5-pro - 2025 default)\nconst complexResponse = await client.complete({\n  prompt: 'Write a comprehensive analysis of quantum computing applications',\n  complexity: 'complex'\n});\n```\n\n## Streaming\n\n```typescript\nconst stream = await client.streamComplete({\n  prompt: 'Tell me a story',\n  complexity: 'simple'\n});\n\nfor await (const chunk of stream) {\n  process.stdout.write(chunk.content);\n}\n```\n\n## Token Counting\n\n```typescript\n// Count tokens before making a request\nconst tokens = await client.countTokens('Your prompt here');\nconsole.log(`Estimated tokens: ${tokens}`);\n\n// Check token usage after completion\nconst response = await client.complete({\n  prompt: 'Your prompt'\n});\nconsole.log(`Input tokens: ${response.tokenUsage.input}`);\nconsole.log(`Output tokens: ${response.tokenUsage.output}`);\nconsole.log(`Total tokens: ${response.tokenUsage.total}`);\n```\n\n## Error Handling\n\n```typescript\ntry {\n  const response = await client.complete({\n    prompt: 'Your prompt'\n  });\n} catch (error) {\n  if (error.code === 'RATE_LIMIT_EXCEEDED') {\n    console.error('Rate limit exceeded, try again later');\n  } else if (error.code === 'PROVIDER_UNAVAILABLE') {\n    console.error('All providers unavailable');\n  } else {\n    console.error('Unexpected error:', error.message);\n  }\n}\n```\n\n## Environment Variables\n\n```bash\n# Required\nGOOGLE_API_KEY=your_gemini_api_key\n\n# Optional (for fallback)\nOPENAI_API_KEY=your_openai_api_key\nANTHROPIC_API_KEY=your_anthropic_api_key\n```\n\n## API Reference\n\nSee [API.md](./docs/API.md) for complete API documentation.\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-726b5381d0937545a4e3eb694aec71e5"}