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)
Finetune
Start finetuning
- Run
neuralhive finetune. - Select a task, model, and dataset.
- Review the final cost and start training.
Dataset requirements
- For
slm, provide a file path. - For other finetune tasks, provide a directory path.
- You can save a local dataset for future use.
Track progress
- Run
neuralhive trainings. - View active training names and progress.
- You can leave training running in the background.
Usage
1. Get model details
model = client.get_model("your_model_id")
print(model)
2. Run model inference
from neuralhive import Client
client = Client()
result = client.detect(
image_path="/absolute/path/to/image.jpg",
)
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:
Clientinstance
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:
dictwith model details
client.detect(image_path, model_id=None, prompt=None, export_to=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
model_id |
str |
No | Target model identifier |
prompt |
str |
No | Optional prompt (required for SAM-like IDs) |
export_to |
str |
No | Export directory path for box-rendered image |
Notes:
- If
model_idis not provided, SDK uses defaultobject_detectionmodel from your allowed models.
Returns:
dict
client.segment(image_path, model_id=None, prompt=None, export_to=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
model_id |
str |
No | Target model identifier |
prompt |
str |
No | Optional prompt (required for SAM-like IDs) |
export_to |
str |
No | Export directory path for mask-rendered image |
Returns:
dict
Notes:
- If
model_idis not provided, SDK uses defaultinstance_segmentationmodel from your allowed models.
client.detect_and_segment(image_path, prompt, export_to=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
prompt |
str |
Yes | Segmentation prompt |
export_to |
str |
No | Export directory path for mask+box-rendered image |
Notes:
- Uses SAM3 / prompt-based segmentation models.
Returns:
dict
client.recognize(image_path)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
Returns:
list[list[float]](face embeddings per detected face)
client.reidentify(image_path, model_id=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
model_id |
str |
No | Target model identifier |
Returns:
dict
client.estimate_pose(image_path, export_to=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
export_to |
str |
No | Export directory path for pose-rendered image |
Returns:
dictwith:keypoints:list[object]scores:list[object]saved_path:str | None
client.embed(text=None, image_path=None, model_id=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
str |
No | Text input |
image_path |
str |
No | Local image file path |
model_id |
str |
No | Target model identifier |
Notes:
- Exactly one input is required:
textorimage_path - If
model_idis not provided, SDK uses the defaultclipmodel from your allowed models.
Returns:
list[float]orlist[list[float]]
client.generate_text(prompt, model_id=None, image_paths=None, video_paths=None, system_prompt=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
str |
Yes | Text prompt |
model_id |
str |
No | Target model identifier |
image_paths |
str or list[str] |
No | Local image file path(s) |
video_paths |
str or list[str] |
No | Local video path(s) or public URL(s) |
system_prompt |
str |
No | Optional system prompt for SLM models |
Notes:
- If
model_idis not provided, SDK uses defaultvlmmodel from your allowed models. system_promptis only sent when the selected model is anslmmodel.
Returns:
str
client.analyze(text=None, image_paths=None, video_paths=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
str |
No | Text input |
image_paths |
str or list[str] |
No | Local image file path(s) |
video_paths |
str or list[str] |
No | Local video path(s) or public URL(s) |
Notes:
- At least one input is required:
textorimage_pathsorvideo_paths
Returns:
str
client.generate_image(prompt, export_to=None, height=None, width=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
prompt |
str |
Yes | Text prompt (1–3000 characters) |
export_to |
str |
No | Export directory path (filename comes from response URL) |
height |
int |
No | 512–2048, multiple of 32. Server default is 1024 |
width |
int |
No | 512–2048, multiple of 32. Server default is 1024 |
This is a queued job. The SDK waits for the result (usually 1–2 minutes).
If the job fails or does not finish, the method raises an error.
If the model is cold (not running), the first call can take a few minutes: the SDK retries a 503 up to 2 times.
Returns:
dictwith:download_url:strsaved_path:str | None
client.edit_image(image_path, prompt, export_to=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
prompt |
str |
Yes | Text instruction for the edit |
export_to |
str |
No | Export directory path (filename comes from response URL) |
Returns:
dictwith:download_url:strsaved_path:str | None
client.transcribe_audio(audio_path)
| Parameter | Type | Required | Description |
|---|---|---|---|
audio_path |
str |
Yes | Local audio file path |
Returns:
str
client.read_text(file_path, export_to=None, task="ocr")
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
str |
Yes | Local image file path (JPEG or PNG). PDF is not supported. |
export_to |
str |
No | Directory to save the text as ocr-result.txt |
task |
str |
No | ocr (default), table, formula, chart, spotting or seal |
Returns:
str- Without
export_to: the text read from the image - With
export_to: saved local file path
client.detect_layout(file_path, export_to=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
file_path |
str |
Yes | Local image file path (JPEG or PNG). PDF is not supported. |
export_to |
str |
No | Directory to save the result as layout-detection-result.json |
Returns:
dictcount: number of regions foundpages: one item per page. Each page hasdetections, and each detection hasorder,label,scoreandbox.saved_path: saved.jsonfile path (only whenexport_tois given)
client.generate_3d(image_path, export_to=None)
| Parameter | Type | Required | Description |
|---|---|---|---|
image_path |
str |
Yes | Local image file path |
export_to |
str |
No | Export directory path (filename comes from response URL) |
Returns:
dictwith:download_url:strsaved_path:str | None
Metadata
Release files for neuralhive 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neuralhive-1.2.0.tar.gz | 51.4 kB | Without provenance | Details for neuralhive-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neuralhive-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for neuralhive-1.2.0-py3-none-any.whl |
Total release size: 124.7 kB
Release files / neuralhive-1.2.0.tar.gz
| Download URL | neuralhive-1.2.0.tar.gz |
|---|---|
| Size | 51.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2505f6b44db7f4c52d619d30ddb48b652d4f8fb9aa7f6c2c0616022d990211a8
|
|
BLAKE2b-256 checksum How to use checksums |
4b86bf4ba41b2e7a77adbe1e010aa31ebd4fea05466efb4acc324adc0da35a45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / neuralhive-1.2.0-py3-none-any.whl
| Download URL | neuralhive-1.2.0-py3-none-any.whl |
|---|---|
| Size | 73.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a6273717aa72519bfd1a07cbe16688c700f7966e72598744d9b8635e710f6dd7
|
|
BLAKE2b-256 checksum How to use checksums |
d46302b58fa58977e685ab71228dcbdf4e61fa6250691b27c2e15e6bc4ad8b02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Security for neuralhive 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.