A React Native app for the ultimate thinking partner.
at main 44 lines 1.4 kB view raw
1import { LettaClient } from '@letta-ai/letta-client'; 2 3async function testImage() { 4 const token = process.env.LETTA_API_KEY; 5 if (!token) { 6 console.error('Error: LETTA_API_KEY environment variable not set'); 7 process.exit(1); 8 } 9 10 const client = new LettaClient({ token }); 11 12 const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg"; 13 const imageResponse = await fetch(imageUrl); 14 const imageBuffer = await imageResponse.arrayBuffer(); 15 const imageData = Buffer.from(imageBuffer).toString('base64'); 16 17 const response = await client.agents.messages.create( 18 "agent-bb780791-961a-4fa3-95ba-b681b6d508e6", { 19 messages: [ 20 { 21 role: "user", 22 content: [ 23 { 24 type: "text", 25 text: "Describe this image." 26 }, 27 { 28 type: "image", 29 source: { 30 type: "base64", 31 mediaType: "image/jpeg", 32 data: imageData, 33 }, 34 } 35 ], 36 } 37 ], 38 } 39 ); 40 41 console.log('Response:', response); 42} 43 44testImage().catch(console.error);