Welcome to Tiiny SDK¶
Tiiny SDK simplifies the integration of Tiiny devices into your Python workflow. With its intuitive API, you can easily manage device, models, and authentication while harnessing powerful AI tasks—such as Natural Language Processing (Chat, Embedding, Rerank) and Computer Vision (Image Generation).
Key Features¶
- Device Management: Easily connect to devices via IPv6, check connection status, and monitor system/NPU resources.
- Model Management: List available models and start/stop them on the device.
- OpenAI Compatibility: The chat interface is fully compatible with the OpenAI Python SDK style, making migration seamless.
- Model Support:
- LLM Chat: Support for standard chat completions and streaming responses.
- Embeddings: Generate vector embeddings for text.
- Rerank: Re-rank documents based on query relevance.
- Image Generation: Generate images from text prompts.
Installation¶
To use the API in Python, you can use the official Tiiny SDK for Python. Get started by installing the SDK using pip:
(Note: Adjust the package name if it differs upon release)
Quick Example¶
With the Tiiny SDK installed, create a file called example.py and copy the example code into it:
from tiiny import TiinyDevice, OpenAI
# 1. Connect to device
device = TiinyDevice(device_ip="fd80:7:7:7::1")
# 2. Get API Key
api_key = device.get_api_key(master_password="your_password")
# 3. Create Client
client = OpenAI(api_key=api_key, base_url=device.get_url())
# 4. Chat
response = client.chat.completions.create(
model="your-model-id",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)