Skip to main content

NeuralHive Python SDK for model access and inference

Project description

NeuralHive SDK

Python SDK client for NeuralHive model access.

Installation

pip install neuralhive

Authentication Setup

Option 1: Configure once (recommended)

neuralhive configure --api-key nh_live_your_api_key

Then use SDK without passing key in code.

Option 2: Environment variable

export NEURALHIVE_API_KEY="nh_live_your_api_key"

Option 3: Pass key directly in code

client = Client("nh_live_your_api_key")

Quick Start

from neuralhive import Client

client = Client()
models = client.list_models()
print(models)

Usage

1. List models

from neuralhive import Client

client = Client("nh_live_your_api_key")
models = client.list_models()

2. Get model details

model = client.get_model("your_model_id")
print(model)

3. Run model inference

from neuralhive import Client

client = Client("nh_live_your_api_key")

result = client.detect(
    model_id="your_object_detection_model_id",
    image="<base64_image>",
)

For all other methods, see API Reference below.

API Reference

Client(api_key: str | None = None)

Parameter Type Required Description
api_key str No Your NeuralHive API key

Returns:

  • Client instance

Notes:

  • Authentication is validated automatically on first API call.
  • Production recommendation: avoid hardcoded API keys in source code.

client.list_models()

Parameters:

  • None

Returns:

  • list[dict] containing allowed models for this API key

client.get_model(model_id)

Parameter Type Required Description
model_id str Yes Target model identifier

Returns:

  • dict with model details

client.detect(model_id, image, prompt=None)

Parameter Type Required Description
model_id str Yes Target model identifier
image str Yes Base64 image input
prompt str No Optional prompt (required for SAM-like IDs)

Returns:

  • dict

client.segment(model_id, image, prompt=None)

Parameter Type Required Description
model_id str Yes Target model identifier
image str Yes Base64 image input
prompt str No Optional prompt (required for SAM-like IDs)

Returns:

  • dict

client.recognize(model_id, image)

Parameter Type Required Description
model_id str Yes Target model identifier
image str Yes Base64 image input

Returns:

  • list[float] (face embeddings)

client.reidentify(model_id, image)

Parameter Type Required Description
model_id str Yes Target model identifier
image str Yes Base64 image input

Returns:

  • dict

client.estimate_pose(model_id, image)

Parameter Type Required Description
model_id str Yes Target model identifier
image str Yes Base64 image input

Returns:

  • dict

client.embed(model_id, text=None, image=None)

Parameter Type Required Description
model_id str Yes Target model identifier
text str No Text input
image str No Base64 image input

Notes:

  • Exactly one input is required: text or image

Returns:

  • list[float] or list[list[float]]

client.generate_text(model_id, prompt, image=None, images=None, videos=None)

Parameter Type Required Description
model_id str Yes Target model identifier
prompt str Yes Text prompt
image str No Single base64 image
images str or list[str] No Base64 image(s)
videos str or list[str] No Video URL(s) or base64 video input(s)

Returns:

  • str

client.analyze(model_id, text=None, images=None, videos=None)

Parameter Type Required Description
model_id str Yes Target model identifier
text str No Text input
images str or list[str] No Base64 image(s)
videos str or list[str] No Video URL(s) or base64 video input(s)

Notes:

  • At least one input is required: text or images or videos

Returns:

  • str

client.generate_image(model_id, prompt)

Parameter Type Required Description
model_id str Yes Target model identifier
prompt str Yes Text prompt

Returns:

  • str (generated image URL, empty string if unavailable)

client.generate_3d(model_id, image=None, prompt=None)

Parameter Type Required Description
model_id str Yes Target model identifier
image str No Base64 image input
prompt str No Optional prompt input

Notes:

  • Provide at least one input: image or prompt

Returns:

  • str (3D asset URL, empty string if unavailable)

Input Validation

  • model_id is required for all inference methods.
  • task_type is never required from user.
  • image and images must be base64-encoded strings when provided.
  • Unsupported fields for selected model are rejected before request dispatch.
  • Missing required fields for selected model are rejected before request dispatch.

Contract

Frozen contract file is included in repository.

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

neuralhive-1.0.1.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

neuralhive-1.0.1-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

Details for the file neuralhive-1.0.1.tar.gz.

File metadata

  • Download URL: neuralhive-1.0.1.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for neuralhive-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5bc86c99614c6a21f3fb9e9e70baa5009b53585fbe5ab7905e8da266e88684e4
MD5 5c504550598bb980ddf3103851b2e14c
BLAKE2b-256 6956fb093850a0fa8499e29eed767d6f2584887f6d56cda3ebc5e8bfc7af804f

See more details on using hashes here.

File details

Details for the file neuralhive-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: neuralhive-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 33.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for neuralhive-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5e5e320987751013089723cf1f204b386cb98c983dcf381d875d86369b45e67
MD5 831e1c9427c7911e0314ff3b9820c18b
BLAKE2b-256 82b4a36a5d924feafa3f7f62328668603ebf68e8ff5bc1fd7691c398f3de5a05

See more details on using hashes here.

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