Official Python SDK for MegaNova AI — Inference, Cloud Agents, and Agent SDK
Project description
Meganova Python SDK
Official Python SDK for the Meganova AI platform, designed for simplicity, robustness, and performance.
Installation
pip install -e .
Note: This package requires Python 3.8+
Configuration
The SDK defaults to the production API URL: https://api.meganova.ai/v1.
You can configure the client using your API key:
from meganova import MegaNova
client = MegaNova(api_key="YOUR_API_KEY")
Alternatively, set the MEGANOVA_API_KEY environment variable.
Supported Models
Meganova supports a wide range of models across different modalities:
- Text Generation:
meganova-ai/manta-mini-1.0(Fast, 8k context)meganova-ai/manta-flash-1.0(Balanced, 32k context)meganova-ai/manta-pro-1.0(Powerful, 65k context)Qwen/Qwen3-235B-A22B-Instruct-2507(262k context)moonshotai/Kimi-K2-Thinking(Reasoning focused)
- Image Generation:
ByteDance/SeedDream-4-5(Text-to-Image)black-forest-labs/FLUX.1-dev(Text-to-Image)
- Video Generation:
Byteplus/seedance-1-0-pro-250528(Text-to-Video)
- Vision:
Qwen/Qwen2.5-VL-7B-Instruct
- Audio:
Systran/faster-whisper-large-v3(Speech-to-Text)
Use client.models.list() or client.serverless.list_models() to see the full list of available models, capabilities, and pricing.
Cloud Agents
Chat with deployed MegaNova Cloud agents using just an API key — no authentication setup required.
Quick Start
from meganova.cloud import CloudAgent
agent = CloudAgent(api_key="agent_xxx...")
# Get agent info
info = agent.info()
print(f"{info.name}: {info.welcome_message}")
# Chat
response = agent.chat("Hello!")
print(response.response)
Multi-turn Conversation
conv = agent.conversation()
r1 = conv.chat("I need help with my account")
r2 = conv.chat("My email is user@example.com")
# conversation_id is tracked automatically
Tool Confirmation
Some agents use tools (ticket creation, email, etc.) that require approval:
conv = agent.conversation()
response = conv.chat("Create a support ticket for my login issue")
if conv.pending_tool_call:
print(f"Agent wants to: {conv.pending_tool_call.description}")
result = conv.confirm() # or conv.reject()
OpenAI-compatible Completions
# Non-streaming
response = agent.completions(
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
# Streaming
for chunk in agent.completions(
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True,
):
content = chunk.choices[0].delta.content
if content:
print(content, end="", flush=True)
See examples/studio_agent_*.py for complete runnable examples.
Usage Examples
1. Basic Chat Completion
from meganova import MegaNova
client = MegaNova(api_key="YOUR_API_KEY")
response = client.chat.completions.create(
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
model="meganova-ai/manta-flash-1.0",
temperature=0.7
)
print(response.choices[0].message.content)
print(f"Usage: {response.usage}")
2. Streaming Chat
response = client.chat.completions.create(
messages=[{"role": "user", "content": "Write a haiku about space."}],
model="meganova-ai/manta-flash-1.0",
stream=True
)
print("Response: ", end="", flush=True)
for chunk in response:
content = chunk.choices[0].delta.get("content", "")
if content:
print(content, end="", flush=True)
print()
3. Listing Models
models = client.models.list()
for model in models:
print(f"ID: {model.id}")
print(f" Name: {model.name}")
print(f" Context: {model.context_length}")
print(f" Tags: {model.tags}")
4. Serverless Model Discovery
Browse available serverless models with pricing information:
# List text generation models
result = client.serverless.list_models(modality="text_generation")
print(f"Found {result.count} text models")
for model in result.models:
print(f" {model.model_name} ({model.model_alias})")
print(f" Input: ${model.cost_per_1k_input}/1K tokens")
print(f" Output: ${model.cost_per_1k_output}/1K tokens")
# List image generation models
result = client.serverless.list_models(modality="text_to_image")
print(f"Found {result.count} image models")
for model in result.models:
print(f" {model.model_name}")
5. Image Generation
Generate images from text prompts:
response = client.images.generate(
prompt="A futuristic city skyline at sunset, digital art",
model="ByteDance/SeedDream-4-5",
width=1024,
height=1024,
num_steps=4,
guidance_scale=3.5,
)
# Response contains base64-encoded image(s)
for image in response.data:
import base64
image_bytes = base64.b64decode(image.b64_json)
with open("output.png", "wb") as f:
f.write(image_bytes)
print("Image saved to output.png")
6. Audio Transcription
Transcribe audio files to text:
# From a file path
result = client.audio.transcribe("recording.mp3")
print(result.text)
# From a file object
with open("recording.mp3", "rb") as f:
result = client.audio.transcribe(f, filename="recording.mp3")
print(result.text)
# With a specific model
result = client.audio.transcribe(
"recording.mp3",
model="Systran/faster-whisper-large-v3",
)
print(result.text)
7. Usage & Billing
# Get usage summary
usage = client.usage.summary(start_date="2024-01-01", end_date="2024-01-31")
print(f"Total Requests: {usage.total_requests}")
# Get billing balance
balance = client.billing.get_balance()
print(f"Current Balance: ${balance.amount} {balance.currency}")
Running Examples
The repository includes ready-to-run examples in the examples/ directory.
-
Create a
.envfile in the root directory:MEGANOVA_API_KEY=your_api_key_here STUDIO_AGENT_KEY=agent_xxx... # Optional, for Cloud agent examples
-
Run an example:
# Inference API examples python examples/basic_chat.py python examples/streaming_chat.py python examples/list_models.py python examples/serverless_models.py python examples/image_generation.py python examples/audio_transcription.py path/to/audio.mp3 python examples/usage_billing.py # Cloud Agent examples python examples/studio_agent_chat.py python examples/studio_agent_streaming.py python examples/studio_agent_tools.py
Development & Testing
Context Length Verification
A utility script is provided to verify the actual enforced context length of a model versus its claimed metadata.
python examples/test_context_length.py meganova-ai/manta-flash-1.0
Features
- Chat Completions: Full support for streaming and non-streaming requests.
- Cloud Agents: Chat with deployed Cloud agents via simple API key — multi-turn conversations, tool confirmation, and OpenAI-compatible completions.
- Model Management: List and retrieve details for all available models.
- Serverless Model Discovery: Browse models by modality with pricing info.
- Image Generation: Generate images from text prompts with configurable parameters.
- Audio Transcription: Transcribe audio files to text (supports file paths and file objects).
- Usage & Billing: Monitor your usage and check balances programmatically.
- Type Safety: Fully typed with Pydantic models for excellent IDE support.
- Robustness: Built-in retry logic (exponential backoff) and error handling.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file meganova-0.3.0.tar.gz.
File metadata
- Download URL: meganova-0.3.0.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e5b333d221116129901facec3d1af1242009522082d9ca52fc030d92feaf7ae
|
|
| MD5 |
24e63fc52ee4c4273005629844110a61
|
|
| BLAKE2b-256 |
5e9f2bac3bc6add524ec3424ca03c26fb472ac7a6c818f8d0522f67e56884829
|
File details
Details for the file meganova-0.3.0-py3-none-any.whl.
File metadata
- Download URL: meganova-0.3.0-py3-none-any.whl
- Upload date:
- Size: 40.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ca52b951cb2c19c6705135e29ba7b2e11e2cf32a8227e5947ba3a5b36ed4b9a
|
|
| MD5 |
c9b12ec03744b42ff0bb82901461f50e
|
|
| BLAKE2b-256 |
df01892a2ed5eff4fc03d9821bcf2256d237ed8fcfaeedbc8002fa23f60bc441
|