Back to Home

Image Describer API Documentation - AI Image Description Generation

Overview

The Image Describer API is a powerful image description generation tool that intelligently produces accurate, detailed, and insightful descriptions of images based on the provided image and prompt. This AI-driven image recognition API understands and analyzes image content, generating corresponding textual descriptions according to your prompts. It's widely applicable to various scenarios involving image understanding, image analysis, and image content generation, enabling you to easily implement image question answering and image-to-text conversion.

Application Scenarios

The Image Describer API can assist you in efficiently performing image understanding and content generation in the following areas:

API Keys

To access the Image Describer API, you must first obtain a valid API key. This key is used to authenticate your requests and ensure secure access to the API.

Obtaining an API Key

  1. Access the API Keys Management Page: Log in to the system, then click your user avatar in the top-right corner. In the dropdown menu, click "Apply for API" to open the API Keys Management Page.
API for Image Describer
  1. Create a New Key: Click "Create New Key", enter a name for your key in the pop-up dialog, and then click "Create".
API for Image Describer
  1. Copy and Store Your Key: Note that the key will only be displayed in full once. Click the copy icon to copy the key to your clipboard, and then click "Confirm" to close the dialog.

Important: Do not share it with others or expose it in the browser, client-side code, or any other insecure location. Keep your key safe to prevent unauthorized access.

API Endpoint

POST https://api.imagedescriber.app/api/v1/generate_content

Request parameters

Request Headers

HeaderTypeRequiredDescription
content-typestringYes`application/json`
authorizationstringYes`Bearer ${api_key}`, where `${api_key}` is your API key.

Request Body

{
  "image": "data:image/jpeg;base64,{image_base64_data}",
  "prompt": "What is this object? Describe its possible uses.",
  "lang": "en"
}
ParameterTypeRequiredDescription
imagestringYes

The URL or Base64 encoded data of the image. Supported image formats are listed in Image Format Details.

promptstringNoThe question or description request for the image, for example, "What is this?" or "Describe this image."
langstringNoThe language code for the returned description. Defaults to `en` (English). Supported language codes are listed below.

Supported Languages

CodeLanguage
enEnglish (Default)
zhChinese
frFrench
deGerman
esSpanish
jaJapanese
koKorean

Request Example (cURL)

curl --location 'https://api.imagedescriber.app/api/v1/generate_content' \
--header 'content-type: application/json' \
--header 'authorization: Bearer your_api_key' \
--data '{
    "image":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQE...", 
    "prompt":"What is this object? Describe its possible uses.",
    "lang":"en"
}'

Request Example (Python)

import requests
import base64

def image_to_base64(image_path):
  """Convert image to Base64 encoding"""
  with open(image_path, "rb") as image_file:
    encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
  return encoded_string

def generate_image_description(api_key, image_path, prompt, lang="en"):
  """Generate image description using the Image Describer API"""
  url = "https://api.imagedescriber.app/api/v1/generate_content"
  headers = {
      "content-type": "application/json",
      "authorization": f"Bearer {api_key}"
  }
  
  image_base64_data = image_to_base64(image_path)
  payload = {
      "image": f"data:image/jpeg;base64,{image_base64_data}",
      "prompt": prompt,
      "lang": lang
  }

  response = requests.post(url, headers=headers, json=payload)

  if response.status_code == 200:
      result = response.json()
      print(result["data"]["content"])
  else:
    print(f"Error: {response.status_code}")
    print(response.text)

# Example usage
api_key = "your_api_key"
image_path = "your_image.jpg"
prompt = "What is this object? Describe its possible uses."

generate_image_description(api_key, image_path, prompt)

Request Example (Next.js)

import fs from 'fs';

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

// 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 imageData = `data:${file.type};base64,${base64Image}`;

const body = {
  "image": imageData,
  "prompt": "Describe the image in detail",
  "lang": "en"
};

const response = await fetch('https://api.imagedescriber.app/api/v1/generate_content', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer {your_api_key}'
    },
    body: JSON.stringify(body),
});

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

Response

Response Body (JSON Response)

The API now returns the complete response in a single JSON object. The content field within the data object contains the generated image description in Markdown format.

{
  "code": 0,
  "message": "success",
  "request_id": "unique_request_id_string",
  "data": {
    "content": "Generated content in Markdown format" 
  }
}
FieldTypeDescription
codenumberStatus code, `0` indicates success, non-`0` indicates an error.
messagestringStatus message, describes the status of the request.
request_idstringUnique request ID, used for tracking and troubleshooting.
datastringContains the generated content. markdown format.
contentstringThe generated **image description** text. The format is **Markdown**.

Request Limits

To ensure service stability and fairness, each API key is limited to 5 requests per minute (300 requests per hour). Requests exceeding this limit will be rejected with error code 1004.

Credit System

How to Get More Credits?

You can visit the Credit Recharge Page to purchase credit packages to support more API calls. We offer various packages to meet the needs of different users.

Error Handling

The following table lists common error codes, their meanings, and solutions:

Error CodeDescriptionSolution
1002UnauthorizedPlease verify that your `authorization` header is set correctly.
1003Invalid API KeyPlease verify that your API key is correct or obtain a new one.
1004Too Many RequestsPlease reduce your request frequency, maximum 5 requests per minute.
1005Invalid ParametersPlease verify that your request parameters conform to the specifications.
2002Insufficient Credits
2003Content Blocked by FilterPlease modify your image or prompt to ensure the content complies with regulations.
2004Invalid Image Format

Please use a supported image format, refer to Image Format Details.

2005Image Upload FailedPlease verify that your image URL is valid or try uploading again later.
5050Internal Server ErrorPlease contact our technical support team and provide the `request_id`.

Image Format Details

Currently supported image formats include: JPG, JPEG, PNG, WebP. The maximum image size is 4MB.

Contact Us

If you have any questions or suggestions, please feel free to contact us through the following methods:

Start using the Image Describer API now and unlock the limitless possibilities of image understanding!