Jump Into Our API Testing Adventure – $250 Prize + Swag for first 15 submissions


AI-Generated Caption from Random Image

I created an AI-Generated Caption experience using random images fetched from the Picsum Photos API.


:link: API Used:

https://picsum.photos/v2/list?page={{randomPage}}&limit=1

This returns random image metadata based on the page number.


:gear: Pre-request Script:

const randomPage = Math.floor(Math.random() * 100) + 1;
pm.variables.set("randomPage", randomPage);

Generates a new random image on every request.


:package: External Package Used:

lodash – to easily pick random words from arrays to build creative, natural-sounding captions.
compromise - used to generate and transform the caption (not just analyze it)


:scroll: Post-response Script:

const _ = require('lodash');
const compromise = pm.require('npm:[email protected]');

// Get image data from response
const image = pm.response.json()[0];
const imageUrl = `https://picsum.photos/id/${image.id}/400/300`;
const author = image.author;

// Word banks
const adjectives = ['serene', 'vivid', 'mystical', 'dramatic', 'picturesque', 'timeless'];
const scenes = [
    'a glimpse into nature',
    'urban beauty',
    'a peaceful escape',
    'an architectural wonder',
    'a dreamlike sky',
    'a glowing horizon'
];

// Step 1: Seed raw caption
const seedCaption = `The scene is ${_.sample(adjectives)} and shows ${_.sample(scenes)}.`;

// Step 2: Use compromise to smartly transform the caption
let doc = compromise(seedCaption);

// Use NLP to enhance sentence style
doc.verbs().toPresentTense();
doc.replace('The scene is', `Captured by ${author}, this moment feels`);
doc.replace('shows', 'offers');

// Final AI-generated caption
const caption = doc.text();

// NLP analysis just for fun
const nouns = doc.nouns().out('array');
const adjs = doc.adjectives().out('array');

// Set up the visualizer
pm.visualizer.set(`
  <div style="text-align:center; font-family: sans-serif; padding: 20px;">
    <img src="{{img}}" style="max-width:100%; border-radius:10px; box-shadow: 0 4px 10px rgba(0,0,0,0.1);" />
    <h3 style="margin-top: 20px;">📝 AI-Generated Caption</h3>
    <p style="font-size: 18px;">"{{caption}}"</p>
    <p style="color:gray;">📸 Author: {{author}} | 🆔 ID: {{id}}</p>
    <hr style="margin: 20px 0;" />
    <p><strong>🔤 NLP Analysis (from compromise):</strong></p>
    <p><strong>Nouns:</strong> {{nouns}}</p>
    <p><strong>Adjectives:</strong> {{adjs}}</p>
  </div>
`, {
    img: imageUrl,
    caption,
    author,
    id: image.id,
    nouns: nouns.join(', ') || 'None',
    adjs: adjs.join(', ') || 'None'
});


:magnifying_glass_tilted_left: Visualization:

Used pm.visualizer.set() to create a clean UI showing:

  • The randomly selected image
  • An AI-generated caption
  • Image author and ID

:link: View Collection:

:backhand_index_pointing_right: Open in Postman


While APIs and captioning are widely used in AI and web apps, they’re rarely visualized inside Postman. Postman is often used for testing and debugging APIs — not for creative or dynamic frontend-style visualizations.

This collection shows that Postman can be fun, interactive, and artistic — pushing the boundaries of what’s traditionally expected from API tools. It’s not common because most developers don’t think of Postman as a canvas for storytelling, but this proves it can be.


1 Like