Nara Lens/Docs

Python SDK

Official Python SDK for Nara Lens.

Installation

Bash
pip install naralens

Quick Start

Python
from naralens import Vision

# Initialize the client
client = Vision(api_key="your-api-key")

# Analyze an image
result = client.analyze(
    image="https://example.com/image.jpg",
    perception="detect:person,vehicle"
)

# Access results
for obj in result.objects:
    print(f"{obj.label}: {obj.confidence:.2%}")
    print(f"  Bounding box: {obj.bbox}")

Async Usage

Python
import asyncio
from naralens import AsyncVision

async def main():
    client = AsyncVision(api_key="your-api-key")

    result = await client.analyze(
        image="https://example.com/image.jpg",
        perception="detect:person"
    )

    print(result.objects)

asyncio.run(main())

Error Handling

Python
from naralens import Vision, NaraLensError

client = Vision(api_key="your-api-key")

try:
    result = client.analyze(image="...", perception="...")
except NaraLensError as e:
    print(f"Error: {e.message}")
    print(f"Status code: {e.status_code}")