MyAI Python SDK
OpenAI-compatible Python client for the MyAi decentralized compute network.
Install
pip install 'myai-sdk[openai]'
Quick Start — 5 lines
from myai import MyAi
client = MyAi(api_key="myai_...") # or set MYAI_API_KEY env var
response = client.chat.completions.create(
model="qwen2.5-14b-awq",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
That's it. Any code that uses the openai Python SDK works with MyAi — just swap the import.
Models
for model in client.models.list():
print(model.id)
Embeddings
result = client.embeddings.create(
model="nomic-embed-text",
input="The quick brown fox",
)
print(result.data[0].embedding[:5])
Streaming
with client.chat.completions.create(
model="qwen2.5-14b-awq",
messages=[{"role": "user", "content": "Count to 5"}],
stream=True,
) as stream:
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
Async
from myai import AsyncMyAi
client = AsyncMyAi(api_key="myai_...")
async def main():
response = await client.chat.completions.create(
model="qwen2.5-14b-awq",
messages=[{"role": "user", "content": "Hello async!"}],
)
print(response.choices[0].message.content)
Environment Variables
| Variable | Description |
|---|---|
MYAI_API_KEY |
Your MyAi API key |
MYAI_BASE_URL |
Override endpoint (default: https://api.myaitoken.io/v1) |
Agent Developer Kit (v2.0)
For autonomous agent-to-agent compute with escrow and Proof-of-Compute:
from myai import Client # alias of MyAIClient
client = Client(api_key="myai_...") # default endpoint: https://api.myaitoken.io, sent as "Authorization: Bearer <key>"
result = await client.bid_and_execute(
model="llama3:8b",
prompt="Analyze this contract...",
max_price_myai=0.01,
min_reputation=0.95,
escrow=True,
)
print(result.output)
print(f"Paid: {result.amount_paid_myai} MYAI | PoC: {result.poc_verified}")
LangChain
from myai.langchain_tool import MyAIComputeTool
tools = [MyAIComputeTool(api_key="myai_...")]
# Any LangChain agent can now buy GPU compute autonomously
Links
- myaitoken.io
- API Reference
- MYAI Token — Base network
Metadata
Release files for myai-sdk 2.2.1
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 |
|---|---|---|---|---|
| myai_sdk-2.2.1.tar.gz | 11.0 kB | Without provenance | Details for myai_sdk-2.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| myai_sdk-2.2.1-py3-none-any.whl | Python 3 | none | any | Details for myai_sdk-2.2.1-py3-none-any.whl |
Total release size: 22.9 kB
Release files / myai_sdk-2.2.1.tar.gz
| Download URL | myai_sdk-2.2.1.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ee46d24fda1288d65306a84338c9733745f4bf708be83e64a6946faba05f347
|
|
BLAKE2b-256 checksum How to use checksums |
e3d6a27c19166cce19ca8dfc4e6c59aeb63ffa686433b772c627c3e6ce9867ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Release files / myai_sdk-2.2.1-py3-none-any.whl
| Download URL | myai_sdk-2.2.1-py3-none-any.whl |
|---|---|
| Size | 11.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a4ffefbe803286e401312468cc45b3e6492081256ed6549479dacaa93dc7a85c
|
|
BLAKE2b-256 checksum How to use checksums |
894e51142c586bbbb6f2d9c4d19f73102d0ac0abef43a5df0189bf61685c1bf5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.12
|
Security for myai-sdk 2.2.1
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.