Back to Home

Image Describer API Documentation

2025-02-22

Posted by

Image Describer API Documentation

Introduction & Use Cases

Image Describer API allows you to integrate AI-powered image description capabilities into your applications. Our API uses advanced AI models to analyze images and generate detailed descriptions.

Common Use Cases

  • Generate detailed descriptions for images
  • Extract text and information from images
  • Analyze image content and context
  • Create character descriptions for creative writing
  • Generate image captions for content management

API Keys

To use our API, you'll need to obtain API credentials (API Key and Secret). You can manage your API keys in the dashboard.

Manage API Keys →

API Endpoint

POST https://imagedescriber.online/api/openapi/describe-image

Integration Guide

Request Headers

Header NameRequiredDescription
content-typeYesMust be multipart/form-data
appidYesYour API key obtained from the dashboard
timestampYesCurrent timestamp in milliseconds
nonceYesRandom UUID string for request uniqueness, must be unique and between 6 and 32 characters. e.g., 4dc6gvrjg1
signatureYesHMAC-SHA256 signature for authentication (See code examples)

Request Parameters

ParameterTypeRequiredDescription
imageBase64DatastringYesBase64 encoded image data with MIME type prefix (e.g., data:image/jpeg;base64,/9j/4AAQSkZJRgABAQE...)
promptstringNoCustom prompt for image analysis
langstringNoResponse language (en/zh/de/es/fr/ja/ko)

Response Format

FieldTypeDescription
codenumberResponse status code. 200 for success
dataobjectResponse data object, present when code is 200
data.contentstringThe generated description for the image
msgstringResponse message, provides additional information
succeedbooleanIndicates whether the request was successful

Example Response

{
    "code": 200,
    "data": {
        "content": "Detailed description of the image in markdown format..."
    },
    "succeed": true,
    "msg": "Success"
}

Error Codes

CodeMessageDescription
200OKRequest successful
500SERVER_ERRORInternal server error
10003INSUFFICIENT_CREDITSInsufficient credits
10004INVALID_PARAMInvalid parameters
10005HARMFUL_CONTENTHarmful content detected
30001INVALID_API_KEYInvalid API key
30002INVALID_SIGNATUREInvalid request signature

Code Examples

Next.js Example

import fs from 'fs';

// Get image base64 data: Server-side implementation
const buffer = await fs.readFileSync("/temp/test.jpg");
const base64Image = buffer.toString('base64');
const imageBase64Data = `data:image/jpeg;base64,${base64Image}`;

// Get image base64 data: Client-side implementation
const file:File = /* file from input or drop event */;
const arrayBuffer = await file.arrayBuffer();
const bytes = new Uint8Array(arrayBuffer);
const base64Image = btoa(String.fromCharCode.apply(null, bytes as any));
const imageBase64Data = `data:${file.type};base64,${base64Image}`;

// Request Body
const formData = new FormData();
formData.append('imageBase64Data', imageBase64Data);
formData.append('lang', 'en');
formData.append('prompt', 'Summarize the content of the picture in one sentence, then describe in detail what is in the picture, including objects, people, animals, and the atmosphere and mood of the picture');

// Signature
const appid = "app_1234567";
const secret = "sk_a8f3dbb3...";
const timestamp = Date.now().toString();
const nonce = crypto.randomBytes(4).toString('hex');

const signStr = buildSignString(appid, timestamp, nonce); // See subsequent code for function implementation
const sign = await sign(signStr, secret); // See subsequent code for function implementation

// Do Request
const response = await fetch('https://imagedescriber.online/api/openapi/describe-image', {
  method: 'POST',
  headers: {
      'appid': appid,
      'timestamp': timestamp,
      'nonce': nonce,
      'signature': sign
    },
    body: formData
});

const result = await response.json();
console.log(result);

function buildSignString(appId: string, timestamp: string, nonce: string): string {
  return [appId, timestamp, nonce].join('-');
}

async function sign(message: string, secret: string): Promise<string> {
  const encoder = new TextEncoder();
  const keyData = encoder.encode(secret);
  const messageData = encoder.encode(message);

  const key = await crypto.subtle.importKey(
    'raw',
    keyData,
    { name: 'HMAC', hash: 'SHA-256' },
    false,
    ['sign']
  );

  const signatureData = await crypto.subtle.sign(
    'HMAC',
    key,
    messageData
  );

  return btoa(String.fromCharCode.apply(null, Array.from(new Uint8Array(signatureData))));
}

Pricing

API calls consume credits from your account. You can purchase credits on our pricing page.

View Pricing →

Help & Support

If you have any questions or need assistance, please don't hesitate to contact our support team.

Email: [email protected]