-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtogether.ts
More file actions
42 lines (35 loc) · 1.08 KB
/
together.ts
File metadata and controls
42 lines (35 loc) · 1.08 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
38
39
40
41
42
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 serene mountain landscape at sunset with a crystal clear lake reflecting the sky",
model: "together:black-forest-labs/FLUX.1-schnell-Free",
width: 1024,
height: 1024,
n: 1,
apiKey: process.env.TOGETHER_API_KEY!,
});
if (!result?.choices?.[0]?.message?.images?.[0]?.image_url?.url) {
console.error('❌ Image generation did not return an image. Full response:', result);
return;
}
console.log(result);
} catch (error) {
console.error('❌ Error generating image:', error);
}
}
main();