Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/%22$%7Bad.imageUrl%7D//%22https:/unpkg.com/react-dom@18/umd/react-dom.development.js/%22?q=image&page=1&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=image

Returns an array of strings in format "username" or "username/projectName"

Found 12756 results for "image"(1825ms)

Gemini-2-5-Pro-O-02main.tsx61 matches

@aibotcommanderβ€’Updated 57 mins ago
2import { OpenAI } from "npm:openai";
3
4const IMAGE_COST = 400;
5const TEXT_COST = 400;
6const FILE_ANALYSIS_COST = 400;
44
45const POE_MODELS = {
46 imageGeneration: [
47 "Flux-schnell",
48 "Flux-schnell-DI",
49 "ImageCreatorSD",
50 "Free-GPT-Image-1"
51 ],
52 textGeneration: [
65 "Llama-3.1-8b-DI"
66 ],
67 imageAnalysis: [
68 "Qwen3-235B-A22B",
69 "Gemini-1.5-Flash",
118
119function selectOptimalTokens(contentLength: number, taskType: string): number {
120 if (taskType === "Image Generation") return 1024;
121 if (contentLength < 100) return 1024; // Short queries
122 if (contentLength < 500) return 1500; // Medium queries
130 taskType: string,
131 timeout: number = 15000,
132 isImageGeneration: boolean = false
133): Promise<string | null> {
134 try {
153 const content = message?.content;
154
155 if (isImageGeneration && message?.attachments && message.attachments.length > 0) {
156 const imageAttachment = message.attachments.find(att =>
157 att.content_type && att.content_type.startsWith('image/')
158 );
159 if (imageAttachment && imageAttachment.url) {
160 return imageAttachment.url;
161 }
162 }
175 taskType: string,
176 timeout: number = 15000,
177 isImageGeneration: boolean = false
178): Promise<string | null> {
179 // Try first 2 models in parallel for speed
187 for (const model of parallelModels) {
188 promises.push(
189 callSinglePoeModel(model, prompt, keyIndex, taskType, timeout, isImageGeneration)
190 .then(result => ({ result, model, keyIndex }))
191 );
203 console.log(`Success with ${successful.value.model} (API key ${successful.value.keyIndex + 1})`);
204
205 if (isImageGeneration) {
206 const urlMatch = successful.value.result.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
207 if (urlMatch) {
208 send("replace_response", {
209 text: `🎨 **${taskType} completed**\n\n![Generated Image](${urlMatch[0]})`
210 });
211 return urlMatch[0];
232 for (const model of remainingModels) {
233 for (let keyIndex = 0; keyIndex < POE_API_KEYS.length; keyIndex++) {
234 const result = await callSinglePoeModel(model, prompt, keyIndex, taskType, timeout, isImageGeneration);
235 if (result) {
236 if (isImageGeneration) {
237 const urlMatch = result.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
238 if (urlMatch) {
239 send("replace_response", {
240 text: `🎨 **${taskType} completed**\n\n![Generated Image](${urlMatch[0]})`
241 });
242 return urlMatch[0];
260}
261
262async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
263 try {
264 const response = await fetch(imageUrl, { timeout: 8000 });
265 if (!response.ok) {
266 throw new Error(`Failed to fetch image: ${response.status}`);
267 }
268 const arrayBuffer = await response.arrayBuffer();
269 const buffer = Buffer.from(arrayBuffer);
270 const mimeType = response.headers.get('content-type') || 'image/jpeg';
271 return { data: buffer.toString('base64'), mimeType: mimeType };
272 } catch (error) {
273 console.error('Error converting image to base64:', error);
274 throw error;
275 }
281 send: SendEventFn,
282 taskType: string,
283 imageUrl?: string
284): Promise<string | null> {
285 try {
287
288 let parts: any[] = [{ text: prompt }];
289 if (imageUrl) {
290 const { data: imageBase64, mimeType } = await imageToBase64(imageUrl);
291 parts.push({
292 inline_data: {
293 mime_type: mimeType,
294 data: imageBase64
295 }
296 });
338}
339
340async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
341 let cleanPrompt = prompt;
342 if (cleanPrompt.endsWith('--image')) {
343 cleanPrompt = cleanPrompt.substring(0, cleanPrompt.length - 7).trim();
344 }
345
346 const imagePrompt = `Detailed ${cleanPrompt}`;
347 send("text", { text: `🎨 Generating image...` });
348
349 const result = await callPoeModelParallel(
350 POE_MODELS.imageGeneration,
351 imagePrompt,
352 send,
353 "Image Generation",
354 15000,
355 true
358 if (!result) {
359 send("error", {
360 text: `❌ Image generation failed: All models exhausted.`,
361 allow_retry: true
362 });
436}
437
438async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
439 let analysisPrompt: string;
440 if (!userPrompt || userPrompt.trim().length === 0) {
441 analysisPrompt = `Analyze this image in detail. Provide a comprehensive analysis including what you see, colors, objects, people, text, context, and any other relevant details.`;
442 } else {
443 analysisPrompt = `${userPrompt}`;
444 }
445
446 send("text", { text: `πŸ” Analyzing image...` });
447
448 // Try Gemini Pro with vision first
449 const geminiResult = await callGeminiApi(GEMINI_VISION_CONFIG, analysisPrompt, send, "Image Analysis", imageUrl);
450 if (geminiResult) return;
451
452 // Fallback to Poe models with URL reference
453 const fallbackPrompt = `Analyze image: ${imageUrl}\n\nUser's request: ${userPrompt || "Provide detailed analysis"}`;
454 const poeResult = await callPoeModelParallel(
455 POE_MODELS.imageAnalysis,
456 fallbackPrompt,
457 send,
458 "Image Analysis",
459 15000
460 );
462 if (!poeResult) {
463 send("error", {
464 text: `❌ Image analysis failed: All models exhausted.`,
465 allow_retry: true
466 });
509 }
510
511 if (cleanContent.endsWith('--image')) {
512 return { intent: 'image_generation', useClaudeModels };
513 }
514
518
519 if (hasAttachments) {
520 if (lowerContent.includes('image') || lowerContent.includes('picture') ||
521 lowerContent.includes('photo') || lowerContent.includes('analyze') ||
522 lowerContent.includes('what') || lowerContent.includes('describe')) {
523 return { intent: 'image_analysis', useClaudeModels };
524 }
525 return { intent: 'file_analysis', useClaudeModels };
526 }
527
528 if (lowerContent.includes('generate image') || lowerContent.includes('create image') ||
529 lowerContent.includes('draw') || lowerContent.includes('picture of') ||
530 lowerContent.includes('image of')) {
531 return { intent: 'image_generation', useClaudeModels };
532 }
533
563 try {
564 switch (intent) {
565 case 'image_generation':
566 await generateImage(userContent, send);
567 break;
568
590 break;
591
592 case 'image_analysis':
593 if (attachments.length > 0) {
594 const imageAttachment = attachments.find(att =>
595 att.content_type && att.content_type.startsWith('image/')
596 );
597 if (imageAttachment && imageAttachment.url) {
598 await analyzeImage(imageAttachment.url, userContent, send);
599 } else {
600 send("error", {
605 } else {
606 send("error", {
607 text: "Please attach an image for analysis.",
608 allow_retry: false,
609 });
652 const rateCard = "| Task Type | Price |\n" +
653 "|-----------|-------|\n" +
654 `| Input (image) | ${IMAGE_COST} points/message |\n` +
655 `| Input (file) | ${FILE_ANALYSIS_COST} points/message |\n` +
656 `| Input (text) | ${TEXT_COST} points/message |\n` +
657 `| Output (search) | ${SEARCH_COST} points/message |\n` +
658 `| Output (image) | ${IMAGE_COST} points/message |\n`;
659
660 return {
Gemini-2-5-Pro-O-01

Gemini-2-5-Pro-O-01main.tsx60 matches

@aibotcommanderβ€’Updated 1 hour ago
2import { OpenAI } from "npm:openai";
3
4const IMAGE_COST = 400;
5const TEXT_COST = 400;
6const FILE_ANALYSIS_COST = 400;
42
43const POE_MODELS = {
44 imageGeneration: [
45 "ImageCreatorSD",
46 "Free-GPT-Image-1",
47 "Flux-schnell-DI",
48 "Flux-schnell"
64 "Gemini-1.5-Flash"
65 ],
66 imageAnalysis: [
67 "Llama-3.1-8b-DI",
68 "Qwen3-235B-A22B",
97 taskType: string,
98 timeout: number = 30000,
99 isImageGeneration: boolean = false
100): Promise<string | null> {
101 for (let keyIndex = 0; keyIndex < POE_API_KEYS.length; keyIndex++) {
123 const content = message?.content;
124
125 if (isImageGeneration && message?.attachments && message.attachments.length > 0) {
126 const imageAttachment = message.attachments.find(att =>
127 att.content_type && att.content_type.startsWith('image/')
128 );
129
130 if (imageAttachment && imageAttachment.url) {
131 send("replace_response", {
132 text: `🎨 **${taskType} completed**\n\n![Generated Image](${imageAttachment.url})`
133 });
134 return imageAttachment.url;
135 }
136 }
137
138 if (content && content.trim().length > 0) {
139 if (isImageGeneration) {
140 const urlMatch = content.match(/https?:\/\/[^\s]+\.(jpg|jpeg|png|gif|webp)/i);
141 if (urlMatch) {
142 send("replace_response", {
143 text: `🎨 **${taskType} completed**\n\n![Generated Image](${urlMatch[0]})`
144 });
145 return urlMatch[0];
164}
165
166async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
167 try {
168 const response = await fetch(imageUrl, { timeout: 10000 });
169 if (!response.ok) {
170 throw new Error(`Failed to fetch image: ${response.status}`);
171 }
172
173 const arrayBuffer = await response.arrayBuffer();
174 const buffer = Buffer.from(arrayBuffer);
175 const mimeType = response.headers.get('content-type') || 'image/jpeg';
176
177 return {
180 };
181 } catch (error) {
182 console.error('Error converting image to base64:', error);
183 throw error;
184 }
189 send: SendEventFn,
190 taskType: string,
191 imageUrl?: string
192): Promise<string | null> {
193 try {
197 let parts: any[] = [{ text: prompt }];
198
199 if (imageUrl) {
200 const { data: imageBase64, mimeType } = await imageToBase64(imageUrl);
201 parts.push({
202 inline_data: {
203 mime_type: mimeType,
204 data: imageBase64
205 }
206 });
252async function callGeminiVision(
253 prompt: string,
254 imageUrl: string,
255 send: SendEventFn,
256 taskType: string
258 try {
259 console.log(`Trying ${taskType} with Gemini Vision`);
260 send("text", { text: `πŸ” Processing image with Gemini Vision...` });
261
262 const { data: imageBase64, mimeType } = await imageToBase64(imageUrl);
263
264 const payload = {
270 inline_data: {
271 mime_type: mimeType,
272 data: imageBase64
273 }
274 }
418}
419
420async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
421 let cleanPrompt = prompt;
422 if (cleanPrompt.endsWith('--image')) {
423 cleanPrompt = cleanPrompt.substring(0, cleanPrompt.length - 7).trim();
424 }
425
426 const imagePrompt = `Detailed ${cleanPrompt}`;
427 send("text", { text: `🎨 Generating image...` });
428
429 const result = await callPoeModel(
430 POE_MODELS.imageGeneration,
431 imagePrompt,
432 send,
433 "Image Generation",
434 20000,
435 true
437
438 if (!result) {
439 await fallbackToGemini(imagePrompt, send, "Image Generation");
440 }
441}
508}
509
510async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
511 let analysisPrompt: string;
512 if (!userPrompt || userPrompt.trim().length === 0) {
513 analysisPrompt = `Analyze this image in detail. Provide a comprehensive analysis including what you see, colors, objects, people, text, context, and any other relevant details.`;
514 } else {
515 analysisPrompt = `${userPrompt}`;
516 }
517
518 const geminiProResult = await callGeminiPro(analysisPrompt, send, "Image Analysis", imageUrl);
519 if (!geminiProResult) {
520 const geminiResult = await callGeminiVision(analysisPrompt, imageUrl, send, "Image Analysis");
521 if (!geminiResult) {
522 const fallbackPrompt = `Analyze image: ${imageUrl}\n\nUser's request: ${userPrompt || "Provide detailed analysis"}\n\n`;
523 const poeResult = await callPoeModel(
524 POE_MODELS.imageAnalysis,
525 fallbackPrompt,
526 send,
527 "Image Analysis",
528 25000
529 );
530
531 if (!poeResult) {
532 await fallbackToGemini(fallbackPrompt, send, "Image Analysis");
533 }
534 }
575 }
576
577 if (cleanContent.endsWith('--image')) {
578 return { intent: 'image_generation', useClaudeModels };
579 }
580
584
585 if (hasAttachments) {
586 if (lowerContent.includes('image') || lowerContent.includes('picture') ||
587 lowerContent.includes('photo') || lowerContent.includes('analyze') ||
588 lowerContent.includes('what') || lowerContent.includes('describe')) {
589 return { intent: 'image_analysis', useClaudeModels };
590 }
591 return { intent: 'file_analysis', useClaudeModels };
592 }
593
594 if (lowerContent.includes('generate image') || lowerContent.includes('create image') ||
595 lowerContent.includes('draw') || lowerContent.includes('picture of') ||
596 lowerContent.includes('image of')) {
597 return { intent: 'image_generation', useClaudeModels };
598 }
599
630 try {
631 switch (intent) {
632 case 'image_generation':
633 await generateImage(userContent, send);
634 break;
635
660 break;
661
662 case 'image_analysis':
663 if (attachments.length > 0) {
664 const imageAttachment = attachments.find(att =>
665 att.content_type && att.content_type.startsWith('image/')
666 );
667
668 if (imageAttachment && imageAttachment.url) {
669 await analyzeImage(imageAttachment.url, userContent, send);
670 } else {
671 send("error", {
676 } else {
677 send("error", {
678 text: "Please attach an image for analysis.",
679 allow_retry: false,
680 });
723 const rateCard = "| Task Type | Price |\n" +
724 "|-----------|-------|\n" +
725 `| Input (image) | ${IMAGE_COST} points |\n` +
726 `| Input (file) | ${FILE_ANALYSIS_COST} points |\n` +
727 `| Input (text) | ${TEXT_COST} points |\n` +
728 `| Output (search) | ${SEARCH_COST} points |\n`+
729 `| Output (image) | ${IMAGE_COST} points |\n`;
730
731 return {

nabanhotelmain.ts1 match

@francisnkotanyiβ€’Updated 2 hours ago
11<style>body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; }</n/style>
12<style>
13.hero-bg { background-image: linear-gradient(90deg, rgba(2,6,23,0.55), rgba(2,6,23,0.35)), url('https://images.unsplash.com/photo-1501117716987-c8e2f7a1b1a7?auto=format&fit=crop&w=1600&q=60'); background-size: cover; background-position: center; }
14.gallery-img { background-size: cover; background-position: center; }
15</style>

campanhapsdalcoframain.ts4 matches

@nmsilvaβ€’Updated 3 hours ago
93 profissao: "Profissional de Seguros",
94 localidade: "Oliveira de Frades",
95 foto: "https://i.postimg.cc/L6ckF9GG/cropped-circle-image-2.png",
96 },
97 {
99 profissao: "Programador InformΓ‘tico",
100 localidade: "Agros-Alcofra",
101 foto: "https://i.postimg.cc/vTVHLzP2/cropped-circle-image-1.png",
102 },
103 {
105 profissao: "Auxiliar Educativa",
106 localidade: "Ribeira-Alcofra",
107 foto: "https://i.postimg.cc/NMVjHVxr/cropped-circle-image.png",
108 },
109 ];
697 <meta name="viewport" content="width=device-width, initial-scale=1.0">
698 <script src="https://cdn.tailwindcss.com"></script>
699 <link rel="icon" href="https://upload.wikimedia.org/wikipedia/commons/thumb/8/82/Flag_of_the_Social_Democratic_Party_%28Portugal%29.svg/1200px-Flag_of_the_Social_Democratic_Party_%28Portugal%29.svg.png" type="image/png" />
700 <style>
701 </style>

h6-val-summary.ts3 matches

@werewolf006β€’Updated 7 hours ago
16 SUM(cache_write_tokens) as total_cache_write_tokens,
17 SUM(price) as total_price,
18 SUM(num_images) as total_images
19 FROM ${USAGE_TABLE}
20 WHERE val_id = ? AND our_api_token = 1
54 total_cache_write_tokens: 0,
55 total_price: 0,
56 total_images: 0
57 };
58
85 // Always include inference price for comparison
86 inference_price: inferenceSummary.inference_price || 0,
87 total_images: usageSummary.total_images,
88 // Add flag to indicate inference data usage
89 used_inference_data: !!inferenceSummary.inference_price,

h6-val-detail.ts6 matches

@werewolf006β€’Updated 7 hours ago
17 price?: number;
18 finish_reason?: string;
19 num_images?: number;
20 our_api_token: boolean;
21}
31 inference_price: number;
32 original_price?: number;
33 total_images: number;
34 used_inference_data?: boolean;
35 inference_price_primary?: boolean;
66 <th>Cache Write</th>
67 <th>Total Price</th>
68 <th>Images</th>
69 </tr>
70 </thead>
76 <td>${formatNumber(summary.total_cache_write_tokens)}</td>
77 <td class="price">${formatPrice(summary.total_price)}</td>
78 <td>${formatNumber(summary.total_images)}</td>
79 </tr>
80 </tbody>
97 <th>Price</th>
98 <th>Finish</th>
99 <th>Images</th>
100 </tr>
101 </thead>
114 <td class="price">${formatPrice(row.price)}</td>
115 <td>${row.finish_reason || '-'}</td>
116 <td>${formatNumber(row.num_images)}</td>
117 </tr>
118 `).join("")}

h6-user-summary.ts2 matches

@werewolf006β€’Updated 7 hours ago
18 SUM(cache_write_tokens) as total_cache_write_tokens,
19 SUM(price) as total_price,
20 SUM(num_images) as total_images
21 FROM ${USAGE_TABLE}
22 WHERE our_api_token = 1
151 total_price: userData.price,
152 inference_price: inferencePriceByUser.get(userId) || 0,
153 total_images: 0,
154 used_inference_data: true
155 });

h6-user-detail.ts7 matches

@werewolf006β€’Updated 7 hours ago
13 total_price: number;
14 inference_price: number;
15 total_images: number;
16 used_inference_data?: boolean;
17}
32 price?: number;
33 finish_reason?: string;
34 num_images?: number;
35 our_api_token: boolean;
36}
48 total_price: 0,
49 inference_price: 0,
50 total_images: 0
51 };
52
77 <th>Total Price</th>
78 <th>Inference Price</th>
79 <th>Images</th>
80 </tr>
81 </thead>
88 <td class="price">${formatPrice(userData.total_price)} ${userData.used_inference_data ? '<span class="badge badge-info" title="Using inference data">I</span>' : ''}</td>
89 <td class="price">${formatPrice(userData.inference_price || 0)}</td>
90 <td>${formatNumber(userData.total_images)}</td>
91 </tr>
92 </tbody>
135 <th>Price</th>
136 <th>Finish</th>
137 <th>Images</th>
138 </tr>
139 </thead>
152 <td class="price">${formatPrice(row.price)}</td>
153 <td>${row.finish_reason || '-'}</td>
154 <td>${formatNumber(row.num_images)}</td>
155 </tr>
156 `).join("")}

h6-useChatLogic.ts4 matches

@werewolf006β€’Updated 7 hours ago
7 branchId: string | undefined;
8 selectedFiles: string[];
9 images: (string | null)[];
10 soundEnabled: boolean;
11}
20 // bearerToken,
21 selectedFiles,
22 images,
23 soundEnabled,
24}: UseChatLogicProps) {
44 branchId,
45 selectedFiles,
46 images: images
47 .filter((img): img is string => {
48 const isValid = typeof img === "string" && img.startsWith("data:");
49 if (!isValid && img !== null) {
50 console.warn(
51 "Invalid image format:",
52 img?.substring(0, 50) + "..."
53 );

h6-usage-detail.ts2 matches

@werewolf006β€’Updated 7 hours ago
17 price?: number;
18 finish_reason?: string;
19 num_images?: number;
20 our_api_token: boolean;
21}
126 </div>
127 <div class="card-item">
128 <strong>Images:</strong> ${formatNumber(usage.num_images)}
129 </div>
130 <div class="card-item">
Gemini-2-5-Pro-O-01

Gemini-2-5-Pro-O-011 file match

@aibotcommanderβ€’Updated 1 hour ago
Multimodal Image Generator: https://poe.com/Gemini-2.5-Pro-Omni

ImageThing

@refactorizedβ€’Updated 2 days ago
Chrimage
Atiq
"Focal Lens with Atig Wazir" "Welcome to my photography journey! I'm Atiq Wazir, a passionate photographer capturing life's beauty one frame at a time. Explore my gallery for stunning images, behind-the-scenes stories, and tips & tricks to enhance your own