Skip to main content

Python API client for MiViA (Microstructure Analysis)

Project description

MiViA Python Client

Python API client for MiViA (Microstructure Analysis).

Installation

pip install mivia

Configuration

Set your API key as environment variable:

For linux:

export MIVIA_API_KEY="your-api-key"
export MIVIA_BASE_URL="https://app.mivia.ai/api"  # optional, default
export MIVIA_PROXY="http://proxy:8080"  # optional, proxy URL

For Windows (Powershell):

$env:MIVIA_API_KEY = 'your-api-key'
$env:MIVIA_BASE_URL = 'https://app.mivia.ai/api'  # optional, default
$env:MIVIA_PROXY = 'http://proxy:8080'  # optional, proxy URL

Usage

Async Client

import asyncio
from mivia import MiviaClient

async def main():
    async with MiviaClient() as client:
        # List models
        models = await client.list_models()
        print(f"Models: {[m.display_name for m in models]}")

        # High-level: analyze images
        jobs = await client.analyze(
            file_paths=["image1.png", "image2.png"],
            model_id=models[0].id,
            wait=True,
        )

        for job in jobs:
            print(f"Job {job.id}: {job.status}")

        # Download report
        await client.download_pdf(
            job_ids=[j.id for j in jobs],
            output_path="report.pdf",
        )

asyncio.run(main())

Sync Client

from mivia import SyncMiviaClient

client = SyncMiviaClient()

# List models
models = client.list_models()

# Get customizations for a model
customizations = client.get_model_customizations(models[0].id)

# Upload and analyze with customization
jobs = client.analyze(
    file_paths=["image.png"],
    model_id=models[0].id,
    customization_id=customizations[0].id if customizations else None,
)

# Download report
client.download_csv(
    job_ids=[j.id for j in jobs],
    output_path="report.zip",
)

CLI

# List models
mivia models

# List customizations for a model
mivia customizations MODEL_UUID

# Upload images
mivia upload image1.png image2.png

# Analyze (upload + run + wait) - supports model name or UUID
mivia analyze image.png --model "Decarburization"
mivia analyze image.png --model MODEL_UUID

# Analyze with customization (by name or UUID)
mivia analyze image.png --model "Test" --customization "Template Name"

# List available customizations for analyze
mivia analyze --model MODEL_UUID --list-customizations

# List jobs
mivia jobs list

# Get job details
mivia jobs get JOB_UUID

# Wait for jobs
mivia jobs wait JOB_UUID1 JOB_UUID2

# Download PDF report
mivia report pdf JOB_UUID -o report.pdf

# Download CSV report
mivia report csv JOB_UUID -o report.zip --no-images

# Show config
mivia config

# Use proxy
mivia --proxy http://proxy:8080 models

Proxy Configuration

Proxy can be configured via parameter, CLI option, or environment variable.

Library

from mivia import MiviaClient, SyncMiviaClient

# Via parameter (highest priority)
async with MiviaClient(proxy="http://proxy:8080") as client:
    models = await client.list_models()

# Sync client
client = SyncMiviaClient(proxy="http://proxy:8080")
models = client.list_models()

# Via environment variable (MIVIA_PROXY)
# export MIVIA_PROXY="http://proxy:8080"
async with MiviaClient() as client:
    models = await client.list_models()

CLI

# Via --proxy option
mivia --proxy http://proxy:8080 models
mivia --proxy http://proxy:8080 analyze image.png --model "Decarburization"

# Via environment variable
export MIVIA_PROXY="http://proxy:8080"
mivia models

# Verify proxy configuration
mivia --proxy http://proxy:8080 config

Priority Order

  1. Explicit proxy parameter / CLI --proxy option
  2. MIVIA_PROXY environment variable
  3. Standard proxy env vars (HTTP_PROXY, HTTPS_PROXY) via httpx defaults
  4. No proxy (direct connection)

API Reference

MiviaClient

Method Description
upload_image(path) Upload single image
upload_images(paths) Upload multiple images
list_images() List uploaded images
delete_image(id) Delete image
list_models() List available models
get_model_customizations(id) Get model customizations
create_jobs(image_ids, model_id) Create computation jobs
get_job(id) Get job details with results
list_jobs() List jobs with pagination
wait_for_job(id) Poll until job completes
wait_for_jobs(ids) Wait for multiple jobs
download_pdf(job_ids, path) Download PDF report
download_csv(job_ids, path) Download CSV report
analyze(paths, model_id) High-level: upload + run + wait

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mivia-0.1.3.tar.gz (41.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mivia-0.1.3-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file mivia-0.1.3.tar.gz.

File metadata

  • Download URL: mivia-0.1.3.tar.gz
  • Upload date:
  • Size: 41.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mivia-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4f2f59c84a39bb6159bb4f96579e19ec7f75c988402d30d8de86190dafdf7e98
MD5 5ccdf233bc0283091709f46f1b27f7e0
BLAKE2b-256 42c2c352f7364ae163abebc7fca3129eacdffca18915c8c59134a1204f643353

See more details on using hashes here.

Provenance

The following attestation bundles were made for mivia-0.1.3.tar.gz:

Publisher: release.yml on MiViA-GmbH/MiViA-API-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mivia-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: mivia-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mivia-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0fb6d485b9a079167ae061746c7e0cadcc101e0e9285535cbdaf07ad44650933
MD5 39e9e5aa7762e363466a222be27d964c
BLAKE2b-256 13bf3cb72a47aac97661c2257861c13bae3b0712633f19b15bfc7923af835db1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mivia-0.1.3-py3-none-any.whl:

Publisher: release.yml on MiViA-GmbH/MiViA-API-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page