Skip to content

Latest commit

Β 

History

History
226 lines (185 loc) Β· 6.61 KB

File metadata and controls

226 lines (185 loc) Β· 6.61 KB

πŸ“Έ Postman Examples for Image Processing Endpoints

πŸŒ… Your iStock Image Example

Based on the image you provided: Family Sunset Photo

Extracted Content:

  • Title: "Family Enjoying a Sunny Day in a Field"
  • Description: "The image depicts a woman and two children in a sunlit field. The woman, wearing a pink sweater, is kneeling and facing the children, who are standing. The child on the left, a young girl, is wearing a pink top and has her hair in a ponytail. The child on the right, a young boy, is wearing a blue shirt. The sun is setting or rising in the background, casting a warm glow over the scene. The field is filled with tall, golden grass, and there are trees in the distance."
  • Text Found: "iStock Credit: kieferpix 1468298683"

πŸš€ Postman Setup for /transcribe-image-url

Method & URL

POST http://localhost:8000/transcribe-image-url

Headers

Content-Type: application/json
Accept: application/json

Body (JSON)

Example: Your iStock Image (Simplified)

{
  "url": "https://media.istockphoto.com/id/1468298683/pt/foto/mother-and-her-two-children-boy-and-girl-relaxing-in-nature-grass-field-watching-the-sunset.jpg?s=2048x2048&w=is&k=20&c=7wMm1zEerJCW3xDdm2gwovcdTBeU7DeayHEaYDNsJBI="
}

πŸ“ Expected Response

{
  "file_id": "e5de9397-0431-4e8c-85e6-2ff1250210fe",
  "file_info": {
    "name": "family_sunset.jpg",
    "extension": ".jpg",
    "size_mb": 0.34,
    "mime_type": "image/jpeg",
    "duration": null,
    "chunks_processed": null,
    "url": "https://media.istockphoto.com/id/1468298683/pt/foto/mother-and-her-two-children-boy-and-girl-relaxing-in-nature-grass-field-watching-the-sunset.jpg?s=2048x2048&w=is&k=20&c=7wMm1zEerJCW3xDdm2gwovcdTBeU7DeayHEaYDNsJBI="
  },
  "success": true,
  "error": null,
  "title": "Family Enjoying a Sunny Day in a Field",
  "description": "The image depicts a woman and two children in a sunlit field. The woman, wearing a pink sweater, is kneeling and facing the children, who are standing. The child on the left, a young girl, is wearing a pink top and has her hair in a ponytail. The child on the right, a young boy, is wearing a blue shirt. The sun is setting or rising in the background, casting a warm glow over the scene. The field is filled with tall, golden grass, and there are trees in the distance.",
  "extracted_text": "iStock\nCredit: kieferpix\n1468298683",
  "processor_used": "OpenAI Vision",
  "processing_time": 4.228828,
  "timestamp": "2025-09-23T14:17:51.668013"
}

πŸ”„ Alternative: File Upload Endpoint

If you want to upload the image file directly instead of using a URL:

Method & URL

POST http://localhost:8000/transcribe-image

Headers

Accept: application/json

Body (form-data)

Key: file
Type: File
Value: [Select your downloaded image file]

πŸ“‹ More Postman Examples

Example 2: Other Image URLs

{
  "url": "https://picsum.photos/800/600"
}

Example 3: GitHub Image

{
  "url": "https://raw.githubusercontent.com/user/repo/main/image.png"
}

Example 4: Direct Image URL

{
  "url": "https://i.imgur.com/example.jpg"
}

πŸ› οΈ Postman Collection Setup

1. Create New Collection

  • Name: "AI Content Processing API"
  • Description: "Image processing and text extraction"

2. Add Environment Variables

api_base_url: http://localhost:8000

3. Add Request

  • Name: "Transcribe Image URL"
  • Method: POST
  • URL: {{api_base_url}}/transcribe-image-url

4. Pre-request Script (Optional)

// Log the request
console.log("Processing image URL:", pm.request.body.raw);

5. Tests Script

// Test successful response
pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

pm.test("Response has success field", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property('success');
});

pm.test("Processing was successful", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.success).to.eql(true);
});

pm.test("Response has extracted content", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData).to.have.property('title');
    pm.expect(jsonData).to.have.property('description');
    pm.expect(jsonData).to.have.property('extracted_text');
});

// Log results
var response = pm.response.json();
if (response.success) {
    console.log("Title:", response.title);
    console.log("Description:", response.description);
    console.log("Extracted Text:", response.extracted_text);
    console.log("Processing Time:", response.processing_time + "s");
}

πŸ” Postman Tips

1. Environment Setup

Create an environment with:

  • api_url: http://localhost:8000
  • image_url: https://media.istockphoto.com/id/1468298683/pt/foto/mother-and-her-two-children-boy-and-girl-relaxing-in-nature-grass-field-watching-the-sunset.jpg?s=2048x2048&w=is&k=20&c=7wMm1zEerJCW3xDdm2gwovcdTBeU7DeayHEaYDNsJBI=

2. Dynamic Variables

Use in your request body:

{
  "url": "{{image_url}}",
  "filename": "{{$randomFileName}}.jpg"
}

3. Save Response

Add to Tests script:

// Save response to environment
var response = pm.response.json();
pm.environment.set("last_extracted_text", response.extracted_text);
pm.environment.set("last_processing_time", response.processing_time);

🚨 Common Issues & Solutions

1. CORS Issues

Add to Headers:

Origin: http://localhost:3000

2. Long URLs

For very long URLs, encode them:

// Pre-request script
var encodedUrl = encodeURIComponent(pm.environment.get("image_url"));
pm.environment.set("encoded_image_url", encodedUrl);

3. Timeout for Large Images

Increase timeout in Settings > General > Request timeout

4. Authentication (if needed)

Add to Headers:

Authorization: Bearer your_api_token

πŸ“± Mobile Testing

For mobile app development, test with:

{
  "url": "https://media.istockphoto.com/id/1468298683/pt/foto/mother-and-her-two-children-boy-and-girl-relaxing-in-nature-grass-field-watching-the-sunset.jpg?s=2048x2048&w=is&k=20&c=7wMm1zEerJCW3xDdm2gwovcdTBeU7DeayHEaYDNsJBI=",
  "filename": "mobile_upload.jpg"
}

🌐 Bulk Testing

Create multiple requests with different image URLs:

  1. Stock photos
  2. Screenshots
  3. Documents with text
  4. Handwritten notes
  5. Social media images

Each will return different extracted content based on what's visible in the image!