Documentation

Quick Start

Get started with AI Image Description API in just a few minutes. This guide will walk you through the essential steps to integrate AI-powered image description into your application.

Prerequisites

Before you begin, make sure you have:

  • Account: Register at aidescribepicture.com
  • API Key: Create an API key in settings
  • Credits: Purchase image description credits
  • Image URL: A publicly accessible image URL for testing

Step 1: Get Your API Key

  1. Visit aidescribepicture.com
  2. Sign in with your Google account
  3. Navigate to Settings > API Keys
  4. Click "Create New API Key" button
  5. Enter a key name (e.g., "My App")
  6. After creating the key, copy the full key value (keep it secure!)

API Key Format

  • Starts with sk-
  • Contains randomly generated characters
  • Example: sk-abc123def456ghi789...

Step 2: Make Your First API Call

Using cURL

curl -X POST https://aidescribepicture.com/api/api-call/describe-picture \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "imageUrl": "https://example.com/image.jpg",
    "prompt": "Describe this image in detail"
  }'

Using JavaScript

async function describeImage(imageUrl, apiKey, prompt = null) {
  try {
    const response = await fetch('https://aidescribepicture.com/api/api-call/describe-picture', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      body: JSON.stringify({
        imageUrl: imageUrl,
        prompt: prompt
      })
    });
 
    if (!response.ok) {
      const error = await response.text();
      throw new Error(`API Error: ${response.status} - ${error}`);
    }
 
    const result = await response.json();
    
    // Extract description content
    const description = result.choices[0].message.content;
    return description;
  } catch (error) {
    console.error('Error describing image:', error);
    throw error;
  }
}
 
// Usage
const description = await describeImage(
  'https://example.com/image.jpg',
  'your-api-key-here',
  'Describe this image in detail'
);
console.log('Image description:', description);

Step 3: Handle the Response

The API returns a JSON response with the image description:

{
  "choices": [
    {
      "message": {
        "content": "This image shows a red fox in close-up, facing the camera. The fox has fluffy orange and white fur, with erect ears and bright brown eyes. The background is blurred, possibly in a snowy environment or bright setting."
      }
    }
  ]
}

The choices[0].message.content field contains the actual image description text.

Step 4: Display the Result

In HTML

<div id="description">
  <p id="image-description"></p>
</div>

In JavaScript

// Display the description
const descriptionElement = document.getElementById('image-description');
descriptionElement.textContent = description;

Step 5: Error Handling

Always implement proper error handling:

try {
  const description = await describeImage(imageUrl, apiKey, prompt);
  // Handle success
  console.log('Description:', description);
} catch (error) {
  if (error.message.includes('401')) {
    console.error('Invalid API key');
  } else if (error.message.includes('402')) {
    console.error('Insufficient credits');
  } else if (error.message.includes('429')) {
    console.error('Rate limit exceeded');
  } else {
    console.error('API error:', error.message);
  }
}

API Key Management

Managing Keys in Settings

  • View all API keys list
  • View key usage statistics
  • Deactivate or delete unused keys
  • View last used time for keys

Security Best Practices

  • Never hardcode API keys in client-side code
  • Store keys using environment variables
  • Rotate API keys regularly
  • Use different keys for different environments

Environment Variables Example

# .env file
IMAGE_DESCRIPTION_API_KEY=sk-your-api-key-here
// Use in code
const apiKey = process.env.IMAGE_DESCRIPTION_API_KEY;