-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathopenrouter.ts
More file actions
37 lines (30 loc) · 1.09 KB
/
openrouter.ts
File metadata and controls
37 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'dotenv/config';
import {Langbase} from 'langbase';
async function main() {
// Check if API keys are available
if (!process.env.LANGBASE_API_KEY) {
console.error('❌ LANGBASE_API_KEY is not set in environment variables');
return;
}
if (!process.env.OPENROUTER_API_KEY) {
console.error('❌ OPENROUTER_API_KEY is not set in environment variables');
console.log('Please add your OpenRouter API key to the .env file');
return;
}
const langbase = new Langbase({
apiKey: process.env.LANGBASE_API_KEY!,
});
try {
const result = await langbase.images.generate({
prompt: "A majestic dragon soaring through clouds above a fantasy castle, epic fantasy art style, detailed scales and wings",
model: "openrouter:google/gemini-2.5-flash-image-preview",
apiKey: process.env.OPENROUTER_API_KEY
});
console.log('✅ Image generated successfully via OpenRouter!');
console.log('Generated images:', result);
} catch (error) {
console.error('❌ Error generating image:', error);
console.log('Note: Make sure you have a valid OpenRouter API key and credits');
}
}
main();