Analyze images using AI vision capabilities to extract descriptions and insights.
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 |
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'
)
{
"success": true,
"analysis": "Description of the analyzed image...",
"model_used": "gpt-4o-mini"
}