Instill Core Python SDK
Overview
Welcome to Instill Python SDK, where the world of AI-first application comes alive in the form of Python.
Before you jump into creating your first application with this SDK tool, we recommend you to get familiar with the core concepts of Instill Product first. You can check out our documentation here:
Setup
Requirements
- Python 3.9 - 3.12
- CUDA 12.2 - 12.8 (if you want to build a model with GPU support)
Installation
GRPC_PYTHON_LDFLAGS=" -framework CoreFoundation" pip install grpcio --no-binary :all:
Install it directly into an activated virtual environment:
pip install instill-sdk
or add it to your Poetry project:
poetry add instill-sdk
Check import
After installation, you can check if it has been installed correctly:
python
>>> import instill
>>> instill.__version__
Config Instill Core or Managed Instill Core instance
Before we can start using this SDK, you will need to properly config your target instance. We support two ways to setup the configs, which are
Config file
create a config file under this path ${HOME}/.config/instill/sdk/python/config.yml, and within that path you will need to fill in some basic parameters for your desired host.1
Within the config file, you can define multiple instances with the alias of your liking, later in the SDK you can refer to this alias to switch between instances.2
hosts:
alias1:
url: str
secure: bool
token: str
alias2:
url: str
secure: bool
token: str
...
...
Example:
hosts:
default:
url: localhost:8080
secure: false
token: instill_sk***
cloud:
url: api.instill-ai.com
secure: true
token: instill_sk***
At runtime
If you do not like the idea of having to create a config file, you can also setup your target instance by doing the following at the very beginning of your script.
from instill.config import global_config
global_config.set_default(
url="api.instill-ai.com",
token="instill_sk***",
secure=True,
)
Usage
Before we get into this, please make sure a local instance of Instill VDP and Instill Model is running, and the config file had been populated with the correct url and api_token
Let's get started!
Import packages
To Form a pipeline, it required a start operator and a end operator, we have helper functions to create both
from instill.clients import InstillClient
Get the client
Get the unified client that connect to all the available services offered by Instill VDP and Instill Model, including
- mgmt_service
- pipeline_service
- model_service
- artifact_service
client = InstillClient()
user = client.mgmt_service.get_user()
# name: "users/admin"
# uid: "4767b74d-640a-4cdf-9c6d-7bb0e36098a0"
# id: "admin"
# ...
# ...
Please find more usages for this SDK in our documentation
You can also find some notebook examples in our notebooks directory
Create a model
Now create a model text-generation in Instill Model for later use
import instill.protogen.common.task.v1alpha.task_pb2 as task_interface
model_id = "model_text-generation"
client.model_service.create_model(
model_id,
task_interface.Task.TASK_TEXT_GENERATION,
"REGION_GCP_EUROPE_WEST4",
"CPU",
"model-definitions/container",
{},
)
Build and deploy the model
Instill Model is an advanced MLOps/LLMOps platform that was specifically crafted to facilitate the efficient management and orchestration of model deployments for unstructured data ETL. With Instill Model, you can easily create, manage, and deploy your own custom models with ease in Instill Core or on the cloud with Instill Cloud.
Follow the model creation guide to build and deploy your model.
Create pipeline
In the section we will be creating a pipeline using this python-sdk to harness the power of Instill VDP!
The pipeline receipt below is a sample for demo. It simply returns the input string value.
pipeline_id = "pipeline_demo"
client.pipeline_service.create_pipeline(
pipeline_id,
"this is a pipeline for demo",
{
"output": {"result": {"title": "result", "value": "${variable.input}"}},
"variable": {"input": {"instillFormat": "string", "title": "input"}},
},
)
Validate the pipeline
Before we trigger the pipeline, it is recommended to first validate the pipeline recipe first
# validate the pipeline recipe
client.pipeline_service.validate_pipeline(pipeline_id)
Trigger the pipeline
Finally the pipeline is done, now let us test it by triggering it!
# we can trigger the pipeline now
client.pipeline_service.trigger_pipeline(pipeline_id, [], [{"input": "hello world"}])
And the output should be exactly the same as your input.
Contributing
Please refer to the Contributing Guidelines for more details.
Community support
Please refer to the community repository.
License
See the LICENSE file for licensing information.
Metadata
Release files for instill-sdk 0.18.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 |
|---|---|---|---|---|
| instill_sdk-0.18.0.tar.gz | 359.9 kB | Without provenance | Details for instill_sdk-0.18.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| instill_sdk-0.18.0-py3-none-any.whl | Python 3 | none | any | Details for instill_sdk-0.18.0-py3-none-any.whl |
Total release size: 800.1 kB
Release files / instill_sdk-0.18.0.tar.gz
| Download URL | instill_sdk-0.18.0.tar.gz |
|---|---|
| Size | 359.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6c1678205156abcbf76744e5cc932b57fddad9853e5960fb686550486d9bd7f3
|
|
BLAKE2b-256 checksum How to use checksums |
18d21d5f28bdc950e2fa390bf0a47cc6fbd49c1e194f959e2f75d8255e375780
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.12.3 Linux/6.11.0-1015-azure
|
Release files / instill_sdk-0.18.0-py3-none-any.whl
| Download URL | instill_sdk-0.18.0-py3-none-any.whl |
|---|---|
| Size | 440.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a9bdff0b4711d2ede430d5915004ed54ac042b8ff1011ca2643b00e2d9844228
|
|
BLAKE2b-256 checksum How to use checksums |
e68c9663e2c7feab88a7f6a77e171d8a0d4acce308dd3ef321ca3779b0260c42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.12.3 Linux/6.11.0-1015-azure
|
Security for instill-sdk 0.18.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.