Skip to main content

Python client library for MuffinsCorp AI API

Project description

MuffinsCorp AI Python Client

A Python client library for the MuffinsCorp AI API.

Installation

pip install muffinscorp

Quick Start

import os
from muffinscorp import MuffinsCorp

# Set API key as environment variable
os.environ["MUFFINS_AI_API_KEY"] = "your-api-key-here"

# Initialize client
client = MuffinsCorp()

# Send a message to the AI model
response = client.chat.create(
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello, how are you today?"}
    ],
    model="chat-model-small",
    stream=False
)

print(response)

Streaming Responses

import os
from muffinscorp import MuffinsCorp

# Set API key as environment variable
os.environ["MUFFINS_AI_API_KEY"] = "your-api-key-here"

# Initialize client
client = MuffinsCorp()

# Stream the response
for chunk in client.chat.create(
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Write a short story about a robot baker."}
    ],
    model="chat-model-small",
    stream=True
):
    # Process each chunk as it arrives
    print(chunk)

Available Resources

Chat

Create chat completions with various models.

# Create a chat completion
response = client.chat.create(
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello, how are you today?"}
    ],
    model="chat-model-small",
    stream=False
)

Models

List available models.

# Get available models
models = client.models.list()
print(models)

Subscriptions

List available subscription plans.

# Get available subscription plans
plans = client.subscriptions.list()
print(plans)

Credits

Check your account balance.

# Get credit balance
balance = client.credits.get_balance()
print(f"Credits remaining: {balance['credits']}")

Error Handling

from muffinscorp import MuffinsCorp, AuthenticationError, CreditError

try:
    client = MuffinsCorp(api_key="invalid-key")
    response = client.chat.create(
        messages=[{"role": "user", "content": "Hello"}]
    )
except AuthenticationError as e:
    print(f"Authentication error: {e}")
except CreditError as e:
    print(f"Credit error: {e}, remaining credits: {e.credits_remaining}")
except Exception as e:
    print(f"General error: {e}")

License

MIT

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

muffinscorp-1.0.3.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.

muffinscorp-1.0.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file muffinscorp-1.0.3.tar.gz.

File metadata

  • Download URL: muffinscorp-1.0.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for muffinscorp-1.0.3.tar.gz
Algorithm Hash digest
SHA256 826fb27dd1a48e3d654ea1582dd3c9a9bdd5710197af188c0bc23508c396527e
MD5 ab83df16c9c09939565eee5ffa8e834f
BLAKE2b-256 f91442b1d234462194dcc71efbef0dc03649d6445204159e5e7b33b39b8e1f1f

See more details on using hashes here.

File details

Details for the file muffinscorp-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: muffinscorp-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for muffinscorp-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5e3b6d055a090456402492704379692ff1620530fd19ce5c5ce6ca31b4177ade
MD5 4aa41ff4c067fa45f7c4745a23b9082c
BLAKE2b-256 d59e8513f4809e681595442d39f5231402372747b5faa2307d83d4869d34f79a

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