The official Python library for the NetMind's API
Project description
NetMind Python API library
The NetMind Python API Library is the official Python client for NetMind's API platform, providing a convenient way for interacting with the REST APIs and enables easy integrations with Python 3.10+ applications with easy to use synchronous and asynchronous clients.
📚 Table of Contents
Installation
To install NetMind Python Library from PyPI, simply run:
pip install --upgrade netmind
Setting up API Key
You will need to create an account with NetMind.ai to obtain a NetMind API Key.
Once logged in to the NetMind Playground, you can find available API keys in Dashboard.
Setting environment variable
export NETMIND_API_KEY=<your_netmind_api_key>
Using the client
from netmind import NetMind
client = NetMind(api_key="your_netmind_api_key")
This repo contains both a Python Library and a CLI. We'll demonstrate how to use both below.
Usage – Python Client
Chat Completions
from netmind import NetMind
client = NetMind()
# Simple text message
response = client.chat.completions.create(
model="Qwen/Qwen3-8B",
messages=[
{"role": "system", "content": "Act like you are a helpful assistant."},
{"role": "user", "content": "Hi there!"},
],
max_tokens = 512
)
print(response.choices[0].message.content)
# Multi-modal message with text and image
response = client.chat.completions.create(
model="doubao/Doubao-1.5-vision-pro",
messages=[{
"role": "user",
"content": [
{
"type": "text",
"text": "What's in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/yosemite.png"
}
}
]
}]
)
print(response.choices[0].message.content)
The chat completions API supports three types of content:
- Plain text messages using the
contentfield directly - Multi-modal messages with images using
type: "image_url"
When using multi-modal content, the content field becomes an array of content objects, each with its own type and corresponding data.
Streaming
from netmind import NetMind
client = NetMind()
stream = client.chat.completions.create(
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
messages=[
{"role": "system", "content": "Act like you are a helpful assistant."},
{"role": "user", "content": "Hi there!"},
],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
Async usage
import asyncio
from netmind import AsyncNetMind
async_client = AsyncNetMind()
async def async_chat_completion():
response = await async_client.chat.completions.create(
model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
messages=[
{"role": "system", "content": "Act like you are a helpful assistant."},
{"role": "user", "content": "Hi there!"},
]
)
print(response.choices[0].message.content)
asyncio.run(async_chat_completion())
Embeddings
from netmind import NetMind
client = NetMind()
response = client.embeddings.create(
model="nvidia/NV-Embed-v2",
input=["Hello world", "NetMind is awesome!"]
)
print(len(response.data[0].embedding))
Async usage
import asyncio
from netmind import AsyncNetMind
async_client = AsyncNetMind()
async def async_embeddings():
response = await async_client.embeddings.create(
model="nvidia/NV-Embed-v2",
input=["Hello world", "NetMind is awesome!"]
)
print(len(response.data[0].embedding))
asyncio.run(async_embeddings())
Files
from netmind import NetMind
from netmind.types.files import FilePurpose
client = NetMind()
# Upload a file
file_response = client.files.create(
file="path/to/your/file.jsonl",
purpose=FilePurpose.fine_tune
)
print(f"File uploaded with ID: {file_response.id}")
# List files
files = client.files.list()
print("files found:", len(files.data))
file_id = "your_file_id_here"
# Retrieve a file
file = client.files.retrieve(file_id)
print(file)
# Retrieve download url for a file
download_url = client.files.retrieve_url(file_id)
print("Download URL:", download_url.presigned_url)
# Delete a file
client.files.delete(file_id)
Async usage
import asyncio
from netmind import AsyncNetMind
from netmind.types.files import FilePurpose
async_client = AsyncNetMind()
async def async_file_operations():
# Upload a file
file_response = await async_client.files.create(
file="path/to/your/file.jsonl",
purpose=FilePurpose.fine_tune
)
print(f"File uploaded with ID: {file_response.id}")
# List files
files = await async_client.files.list()
print("files found:", len(files.data))
file_id = "your_file_id_here"
# Retrieve a file
file = await async_client.files.retrieve(file_id)
print(file)
# Retrieve download url for a file
download_url = await async_client.files.retrieve_url(file_id)
print("Download URL:", download_url.presigned_url)
# Delete a file
await async_client.files.delete(file_id)
asyncio.run(async_file_operations())
ParsePro
from netmind import NetMind
client = NetMind()
result = client.parse_pro.prase('http://tmpfiles.org/dl/2267856/test.pdf', 'json')
print(result)
result = client.parse_pro.prase('/path/to/test.pdf', 'markdown')
print(result)
Async Task usage
from netmind import NetMind
import time
client = NetMind()
task = client.parse_pro.aparse('http://tmpfiles.org/dl/2267856/test.pdf', 'json')
print(task.task_id, task.status)
time.sleep(10)
result = client.parse_pro.aresult(task.task_id)
print(result.status, result.data)
ParsePro Async usage
from netmind import AsyncNetMind
import asyncio
import time
client = AsyncNetMind()
async def main():
task = await client.parse_pro.aparse('http://tmpfiles.org/dl/2267856/test.pdf', 'markdown')
print(task.task_id, task.status)
time.sleep(10)
result = await client.parse_pro.aresult(task.task_id)
print(result.status, result.data)
asyncio.run(main())
Usage – CLI
coming soon
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netmind-0.1.3.tar.gz.
File metadata
- Download URL: netmind-0.1.3.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.18 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
335ce485de6affa27a5966994c70ac900dec0df4653e73727a1fb6330cc39b8c
|
|
| MD5 |
9c568aab527bb4222a307de8d72cdee9
|
|
| BLAKE2b-256 |
00e1e2d6eefcb294457db4cc8140d1b8b006c865dd1280fed15403e455b520fd
|
File details
Details for the file netmind-0.1.3-py3-none-any.whl.
File metadata
- Download URL: netmind-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.18 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6ab4423a936636a17ee10728b098a55d90bbb5c35ac8e22dc442db205edcb96
|
|
| MD5 |
c008b323b6531e51c2ebd6c0ec64052f
|
|
| BLAKE2b-256 |
26dd72984ef5d5d8ef29fa271c6855c11c8286394a822df666bcb9e300ac5466
|