Skip to main content

Python SDK for Mira Network API

Project description

Mira SDK

A Python SDK for interacting with the Mira Network API. This SDK provides a simple interface to access all Mira API endpoints including model inference, flow management, and credit system.

Installation

pip install mira-sdk

Quick Start

import asyncio
from mira_sdk import MiraClient, Message, AiRequest

async def main():
    # Initialize client
    client = MiraClient(
        base_url="https://api.mira.example.com",
        api_token="your-api-token"
    )
    
    # List available models
    models = await client.list_models()
    print("Available models:", models)
    
    # Generate text
    request = AiRequest(
        model="mira/llama3.1",
        messages=[
            Message(role="system", content="You are a helpful assistant."),
            Message(role="user", content="Hello!")
        ],
        model_provider=None
    )
    
    response = await client.generate(request)
    print("Response:", response)

if __name__ == "__main__":
    asyncio.run(main())

Features

  • Asynchronous API using httpx
  • Full type hints support
  • Pydantic models for request/response validation
  • Support for all Mira API endpoints:
    • Model inference
    • Flow management
    • API token management
    • Credit system

API Reference

Models

  • Message: Represents a chat message
  • ModelProvider: Configuration for custom model providers
  • AiRequest: Request for model inference
  • FlowChatCompletion: Request for flow-based chat completion
  • FlowRequest: Request for creating/updating flows
  • ApiTokenRequest: Request for creating API tokens
  • AddCreditRequest: Request for adding credits

Client Methods

Model Operations

  • list_models(): List available models
  • generate(request: AiRequest): Generate text using specified model

Flow Operations

  • list_flows(): List all flows
  • get_flow(flow_id: str): Get flow details
  • create_flow(request: FlowRequest): Create new flow
  • update_flow(flow_id: str, request: FlowRequest): Update flow
  • delete_flow(flow_id: str): Delete flow
  • generate_with_flow(flow_id: str, request: FlowChatCompletion): Generate using flow

Token Operations

  • create_api_token(request: ApiTokenRequest): Create API token
  • list_api_tokens(): List API tokens
  • delete_api_token(token: str): Delete API token

Credit Operations

  • get_user_credits(): Get credit information
  • add_credit(request: AddCreditRequest): Add credits
  • get_credits_history(): Get credit history

License

MIT License

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

mira_network-0.1.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

mira_network-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file mira_network-0.1.1.tar.gz.

File metadata

  • Download URL: mira_network-0.1.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.21.0 CPython/3.10.15 Darwin/24.2.0

File hashes

Hashes for mira_network-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3617be3420ebd109536cb491d5ad00560931fc96a65442cb6e3319b8d5864559
MD5 09361e7c0bf1519fd3489868da556fff
BLAKE2b-256 31f8daf61ac67fb3dc73c1d8e62c94ef18584d80eb215e3b697a46a6172d73f5

See more details on using hashes here.

File details

Details for the file mira_network-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mira_network-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.21.0 CPython/3.10.15 Darwin/24.2.0

File hashes

Hashes for mira_network-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ba2a463b4eff3d49399cb236e971eacc9d81bc439c3f8c04134566e643d841a
MD5 03074216a8835422dfe09fb45f663486
BLAKE2b-256 6b3e692dd384289f4a6fc80a9d052687218842b66dc736953377b5de35e6119b

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