Gathering detailed insights and metrics for @catgirls/openrouter
Gathering detailed insights and metrics for @catgirls/openrouter
npm install @catgirls/openrouter
Typescript
Module System
Node Version
NPM Version
70.4
Supply Chain
97.6
Quality
87.6
Maintenance
100
Vulnerability
100
License
TypeScript (98.47%)
JavaScript (1.53%)
Love this project? Help keep it running โ sponsor us today! ๐
Total Downloads
601
Last Day
2
Last Week
5
Last Month
47
Last Year
601
1 Stars
18 Commits
1 Forks
1 Watchers
2 Branches
1 Contributors
Updated on Jan 26, 2025
Latest Version
1.0.0-beta.6
Package Id
@catgirls/openrouter@1.0.0-beta.6
Unpacked Size
103.91 kB
Size
17.91 kB
File Count
9
NPM Version
10.9.2
Node Version
22.13.0
Published on
Jan 17, 2025
Cumulative downloads
Total Downloads
Last Day
100%
2
Compared to previous day
Last Week
0%
5
Compared to previous week
Last Month
-91.5%
47
Compared to previous month
Last Year
0%
601
Compared to previous year
1
1
7
Nyaa~! A TypeScript client for OpenRouter that's both kawaii and powerful! (๏พโใฎโ)๏พ*:๏ฝฅ๏พโง
A fully typed, streaming-capable OpenRouter API client that makes working with AI models as comfy as curling up in a warm sunbeam! You get:
1pnpm add @catgirls/openrouter axios 2# or yarn/npm if you're not as cool as us :3
wiggles ears excitedly
Basic chat completion:
1import { OpenRouterClient } from "@catgirls/openrouter"; 2 3const client = new OpenRouterClient("your-api-key", { 4 siteName: "My Kawaii App", // Optional 5 siteUrl: "https://nyaa.example.com", // Optional 6 model: "anthropic/claude-3-opus", // Default model or choose later! 7}); 8 9// Simple completion 10const response = await client.chatCompletion({ 11 messages: [{ role: "user", content: "Explain quantum physics!" }], 12}); 13 14// Streaming with full event support! *purrs* 15const stream = await client.chatCompletion({ 16 messages: [{ role: "user", content: "Write me a story!" }], 17 stream: true, 18}); 19 20// Basic token streaming 21stream.on("token", (token) => console.log("Nyaa~", token)); 22 23// Advanced events for clingy control freaks! 24stream.on("content", (content) => console.log("Content:", content)); 25stream.on("role", (role) => console.log("Role change:", role)); 26stream.on("tool_calls", (tools) => console.log("Tool called:", tools)); 27stream.on("finish", (reason) => console.log("Finished because:", reason)); 28stream.on("usage", (stats) => console.log("Token usage:", stats)); 29stream.on("done", () => console.log("All done! *stretches*"));
Control which AI providers to use:
1const response = await client.chatCompletion({ 2 messages: [...], 3 provider: { 4 // Only use providers that don't store data 5 data_collection: 'deny', 6 // Allow fallback to other providers 7 allow_fallbacks: true, 8 // Require all parameters to be supported 9 require_parameters: true, 10 // Preferred provider order 11 order: ['Anthropic', 'OpenAI', 'Google'], 12 // Skip these providers 13 ignore: ['DeepInfra'], 14 // Only use specific quantizations 15 quantizations: ['fp16', 'bf16'] 16 } 17});
Support for both text and image inputs:
1const response = await client.chatCompletion({ 2 messages: [ 3 { 4 role: 'user', 5 content: [ 6 { 7 type: 'text', 8 text: 'What's in this image?' 9 }, 10 { 11 type: 'image_url', 12 image_url: { 13 url: 'data:image/jpeg;base64,...', 14 detail: 'auto' // Optional detail level 15 } 16 } 17 ] 18 } 19 ] 20});
Use function calling just like with OpenAI:
1const response = await client.chatCompletion({ 2 messages: [...], 3 tools: [{ 4 type: 'function', 5 function: { 6 name: 'scratchPost', 7 description: 'Post something on the scratching post', 8 parameters: { 9 type: 'object', 10 properties: { 11 message: { type: 'string' } 12 } 13 } 14 } 15 }], 16 tool_choice: 'auto' // or 'none', or { type: 'function', function: { name: 'specific_function' } } 17});
1class OpenRouterClient { 2 constructor( 3 apiKey: string, 4 config?: { 5 siteUrl?: string; // Your site URL 6 siteName?: string; // Your site name 7 model?: RouterModel; // Default model ID 8 }, 9 httpClient?: IHttpClient, // Optional custom HTTP client 10 streamHandler?: IStreamHandler, // Optional custom stream handler 11 ); 12 13 // Core methods 14 async chatCompletion<T extends boolean = false>( 15 options: Request & { stream?: T }, 16 ): Promise<ChatCompletionResult<T>>; 17 18 async getGenerationStats(generationId: string): Promise<GenerationStats>; 19 20 async getModels(): Promise<QueryResponseModel[]>; 21}
Key configuration options:
1interface Request { 2 messages?: Message[]; // Chat messages 3 prompt?: string; // Or use raw prompt 4 model?: RouterModel; // Model ID 5 stream?: boolean; // Enable streaming 6 max_tokens?: number; // Max response length 7 temperature?: number; // Randomness (0-2) 8 tools?: Tool[]; // Function calling 9 tool_choice?: ToolChoice; // Tool selection strategy 10 stop?: string | string[]; // Stop sequences 11 response_format?: { 12 // Force output format 13 type: "json_object"; 14 }; 15 16 // Advanced options 17 transforms?: string[]; // Prompt transformations 18 models?: RouterModel[]; // Fallback models 19 route?: "fallback"; // Routing strategy 20 provider?: ProviderPreferences; // Provider control 21 22 // And many more! Check the types for full details 23}
MIT - As free as a cat in a cardboard box! ๐ฑ
made with <3 by catgirls from vatican city
purrs contentedly at well-typed API calls
No vulnerabilities found.
No security vulnerabilities found.