-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgoogle.ts
More file actions
36 lines (29 loc) · 980 Bytes
/
google.ts
File metadata and controls
36 lines (29 loc) · 980 Bytes
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
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.GOOGLE_API_KEY) {
console.error('❌ GOOGLE_API_KEY is not set in environment variables');
console.log('Please add your Google 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 futuristic cityscape with flying cars and neon lights, cyberpunk style, highly detailed, 8k resolution",
model: "google:gemini-2.5-flash-image-preview",
apiKey: process.env.GOOGLE_API_KEY!
});
console.log('✅ Image generated successfully!');
console.log('Generated images:', result);
} catch (error) {
console.error('❌ Error generating image:', error);
}
}
main();