Vision API

Analyze images using AI vision capabilities to extract descriptions and insights.

Endpoint

POST https://filebrain.pro/api/image/analyzer/v1/

File Requirements

File Types

  • JPEG
  • PNG
  • WEBP
  • GIF (non-animated)

Limitations

  • Maximum file size: 20MB
  • One image per request

Request Parameters

Parameter Type Required Description
prompt string Yes Instructions for image analysis
api_key string Yes Your FileBrain API key
llm_api_key string Yes Your LLM API key (OpenAI supported)
model string No Model to use (e.g., 'gpt-4o-mini'). Defaults to system choice if not specified

Code Example

Python Example
import requests

def analyze_image(image_path, prompt, api_key, llm_api_key):
    # Prepare the files and data
    files = {
        'file': open(image_path, 'rb')
    }
    
    data = {
        'prompt': prompt,
        'api_key': api_key,
        'llm_api_key': llm_api_key,
        'model': 'gpt-4o-mini'  # Optional
    }

    # Make the request
    response = requests.post(
        'https://filebrain.pro/api/image/analyzer/v1/',
        files=files,
        data=data
    )
    
    # Check response
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Error: {response.status_code}, {response.text}")

# Example usage
result = analyze_image(
    'path/to/image.jpg',
    'Analyze this image and describe what you see in brief',
    'YOUR_FBP_ACCOUNT_API_KEY'
)

Response Format

Success Response (200 OK)
{
    "success": true,
    "analysis": "Description of the analyzed image...",
    "model_used": "gpt-4o-mini"
}

Error Handling

Common Error Codes

  • 400 - Invalid request (missing parameters, invalid file type)
  • 401 - Invalid API key
  • 413 - File too large (>20MB)
  • 429 - Rate limit exceeded
  • 500 - Server error