NeuralkAPI¶
- class NeuralkAPI(api_key=None, host=None, timeout_s=900, api_version=None, default_headers=None)¶
Low-level API client for Neuralk inference services.
This client provides direct access to the Neuralk API using a tar-based binary protocol for efficient data transfer. For most users, the higher-level Classifier class is recommended.
- Parameters:
api_key (str, optional) – API key for authentication (e.g., “nk_live_xxxx”). Required for cloud mode. Optional for on-premise deployments.
host (str, default=”https://api.prediction.neuralk-ai.com”) – Base URL of the Neuralk API or on-premise server.
timeout_s (int, default=900) – Request timeout in seconds.
api_version (str, optional) – Optional API version string to send as ‘Nicl-Version’ header.
default_headers (dict, optional) – Optional default headers to include with every request.
Examples
Cloud mode with API key:
>>> from neuralk import NeuralkAPI >>> import numpy as np >>> >>> client = NeuralkAPI(api_key="nk_live_xxxx") >>> result = client.classifications.create( ... X_train=np.array([[1.0, 2.0], [2.0, 3.0], [3.0, 4.0]]), ... y_train=np.array([0, 0, 1]), ... X_test=np.array([[1.5, 2.5]]), ... ) >>> print(result["predictions"]) [0]On-premise mode without API key:
>>> client = NeuralkAPI(host="http://localhost:8000") >>> result = client.classifications.create( ... X_train=X_train, ... y_train=y_train, ... X_test=X_test, ... )