Skip to main content

The official Python SDK for MineAI

Project description

MineAI Python SDK

The official Python SDK from MineAI-Studio.

Powered by http://getmineai.site/

Fixes:

  • Memory
  • Error Handling
  • Fix Rate Limit Error
  • Fix Authentication Error
  • Fix Generations Errors

Integrations:

Installation

pip install mineai

Quick Start

Sync Client

from mineai import MineAI, Models

client = MineAI(api_key="YOUR_API_KEY")

response = client.chat.completions.create(
    model=Models.R3_RT_Y,
    messages=[
        {"role": "user", "content": "Hello MineAI!"}
    ]
)

print(response['choices'][0]['message']['content'])

Async Client

import asyncio
from mineai import AsyncMineAI, Models

async def main():
    client = AsyncMineAI(api_key="YOUR_API_KEY")
    
    response = await client.chat.completions.create(
        model=Models.R3_RT_Z,
        messages=[
            {"role": "user", "content": "Tell me a joke."}
        ]
    )
    print(response['choices'][0]['message']['content'])

asyncio.run(main())

Streaming

from mineai import MineAI, Models

client = MineAI(api_key="YOUR_API_KEY")

stream = client.chat.completions.create(
    model=Models.O1_FREE,
    messages=[
        {"role": "user", "content": "Write a long story."}
    ],
    stream=True
)

for chunk in stream:
    if 'choices' in chunk:
        content = chunk['choices'][0].get('delta', {}).get('content', '')
        print(content, end='', flush=True)

Memory Support

from mineai import MineAI, Models

client = MineAI(api_key="YOUR_API_KEY")

# Enable database-backed memory
response = client.chat.completions.create(
    model=Models.R3_RT_Y,
    messages=[
        {"role": "user", "content": "My name is John."}
    ],
    memory=True
)
    memory=True
)

Using Parameters [NEW]

You can customize the response using temperature, max_tokens, and retry_on_failure.

response = client.chat.completions.create(
    model=Models.R3_RT_Y,
    messages=[{"role": "user", "content": "Write a poem."}],
    temperature=0.9,
    max_tokens=50,
    retry_on_failure=True
)

[!IMPORTANT] Limitation: The mine:o1-free model does NOT support memory or retry_on_failure features. These are restricted to paid models.

Error Handling

The SDK provides custom exception classes for different API error scenarios:

from mineai import MineAI, AuthenticationError, RateLimitError

try:
    client = MineAI(api_key="INVALID_KEY")
    client.chat.completions.create(...)
except AuthenticationError:
    print("Invalid API key provided.")
except RateLimitError:
    print("Rate limit exceeded.")

Supported Models

  • Models.R3_RT_Y (mine:r3-rt-y)
  • Models.R3_RT_Z (mine:r3-rt-z)
  • Models.O1_FREE (mine:o1-free)

Issues

  • Older Version Might Trigger Errrors
  • Use The Latest Version of SDK ( Recommended: 0.1.5 )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mineai-0.1.7.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mineai-0.1.7-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file mineai-0.1.7.tar.gz.

File metadata

  • Download URL: mineai-0.1.7.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for mineai-0.1.7.tar.gz
Algorithm Hash digest
SHA256 37c76791fc9c8634707e3d1eb10165bea7ce9c9b5f4a4174182ac2786c2249a1
MD5 2d14dae8fce24916b3fedc6722c0c7f1
BLAKE2b-256 539ead2adfbb682acbc8b00ba67f5fdde068b9ffacd8c188e0204a8dda937957

See more details on using hashes here.

File details

Details for the file mineai-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: mineai-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for mineai-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 490b3b7fe1aae9f4d355282a59c6ae93234b47c4bc1eba2c6e4828831c778447
MD5 9ddf953f7d9a4260024442d18f05fc1d
BLAKE2b-256 a682c964b3a704693a2bf26fb66fbed47aabef8a294f721a31cded629f5bcaaf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page