Skip to main content

Python SDK for the MutagenT Server API Documentation

Project description

╔════════════════════════════════════════════════════════════════════════════╗
║                                                                            ║
║    ███╗   ███╗██╗   ██╗████████╗ █████╗  ██████╗ ███████╗███╗   ██╗████████╗
║    ████╗ ████║██║   ██║╚══██╔══╝██╔══██╗██╔════╝ ██╔════╝████╗  ██║╚══██╔══╝
║    ██╔████╔██║██║   ██║   ██║   ███████║██║  ███╗█████╗  ██╔██╗ ██║   ██║   
║    ██║╚██╔╝██║██║   ██║   ██║   ██╔══██║██║   ██║██╔══╝  ██║╚██╗██║   ██║   
║    ██║ ╚═╝ ██║╚██████╔╝   ██║   ██║  ██║╚██████╔╝███████╗██║ ╚████║   ██║   
║    ╚═╝     ╚═╝ ╚═════╝    ╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚═╝  ╚═══╝   ╚═╝   
║                                                                            ║
║              ██████╗ ██╗   ██╗████████╗██╗  ██╗ ██████╗ ███╗   ██╗        ║
║              ██╔══██╗╚██╗ ██╔╝╚══██╔══╝██║  ██║██╔═══██╗████╗  ██║        ║
║              ██████╔╝ ╚████╔╝    ██║   ███████║██║   ██║██╔██╗ ██║        ║
║              ██╔═══╝   ╚██╔╝     ██║   ██╔══██║██║   ██║██║╚██╗██║        ║
║              ██║        ██║      ██║   ██║  ██║╚██████╔╝██║ ╚████║        ║
║              ╚═╝        ╚═╝      ╚═╝   ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═══╝        ║
║                                                                            ║
║                   Python SDK for AI-Native Development.                   ║
║                                                                            ║
╚════════════════════════════════════════════════════════════════════════════╝

PyPI Python 3.10+ httpx Pydantic v2 Apache 2.0

Type-safe. Async-first. Production-ready.
The official Python SDK for the MutagenT AI platform.


🎯 What is MutagenT Python SDK?

The MutagenT Python SDK is a developer-friendly, fully typed client for the MutagenT AI platform. Built for modern AI applications, it provides:

  • 🔒 Full Type Safety — Pydantic v2 models throughout; passes mypy --strict
  • Sync + AsyncMutagent (sync) and AsyncMutagent (async) dual surface
  • 🐍 Python 3.10+ — CPython and PyPy compatible
  • 🔁 Built-in Retries — exponential back-off with jitter, configurable per-call or globally
  • 📡 Live Tracing — OTel-aligned observability via mutagent.tracing

Core Capabilities

Feature Description
Prompt Management Create, version, and iterate on prompts programmatically
Dataset Operations Import, export, and manage evaluation datasets
Evaluation Engine Run automated evaluations against your prompts
Auto-Optimization Let the MetaTuner improve your prompts based on metrics
Trace Collection Native OTel-aligned observability — no external collector needed

📦 Installation

pip install mutagent-sdk

The PyPI distribution is mutagent-sdk; the import path remains from mutagent import ....

from mutagent import Mutagent, AsyncMutagent

🚀 Quick Start

Sync client

from mutagent import Mutagent

client = Mutagent(api_key="YOUR_API_KEY")

prompts = client.prompt.list_prompts()
print(f"Found {len(prompts.data)} prompts")

Set MUTAGENT_API_KEY in your environment and omit the argument entirely:

export MUTAGENT_API_KEY="sk_live_xxxxxxxx"
from mutagent import Mutagent

client = Mutagent()  # reads MUTAGENT_API_KEY automatically

Async client

import asyncio
from mutagent import AsyncMutagent

async def main():
    async with AsyncMutagent(api_key="YOUR_API_KEY") as client:
        # Create a prompt
        prompt = await client.prompt.create_prompt(
            name="Support Template",
            content="You are a helpful agent. User query: {{query}}",
        )
        print(f"Created prompt: {prompt.id}")

        # List datasets for the prompt
        datasets = await client.prompt_datasets.list_datasets_for_prompt(id=prompt.id)
        print(f"Datasets: {len(datasets.data)}")

asyncio.run(main())

🔍 Tracing

The tracing module provides OTel-aligned span instrumentation with no external collector required.

Initialize

from mutagent.tracing import init_tracing, shutdown_tracing

init_tracing(api_key="YOUR_API_KEY")

# ... your application code ...

await shutdown_tracing()  # flushes remaining spans

Decorate functions

from mutagent.tracing import trace

@trace(kind="agent")
async def run_support_agent(query: str) -> str:
    # Function is automatically traced — input, output, and duration captured
    response = await call_llm(query)
    return response

🧪 Testing

The SDK ships a dev extras group with everything needed for testing:

pip install "mutagent[dev]"
# Includes: pytest, pytest-asyncio, pytest-httpx, ruff, mypy

Run the test suite:

pytest tests/

pytest-httpx is used to mock outgoing HTTP calls without spinning up a server. Tests live in tests/ at the package root.


🏗️ Generated by mutagent-xgen

This package is generated by mutagent-xgen — MutagenT's proprietary in-house SDK generator. The generator ensures the Python client stays in sync with the API specification.

To regenerate after API changes:

# Fetch latest spec from running server
bash scripts/dump-spec.sh

# Regenerate SDK
mutagent-xgen run

Note: README.md is intentionally hand-written and is not tracked in gen.lock. It will not be overwritten by regeneration.


📜 License

This SDK is released under the Apache License 2.0.

Copyright 2026 MutagenT. All rights reserved.


Built with care by the MutagenT Team • mutagent.io

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

mutagent_sdk-0.1.0.tar.gz (222.8 kB view details)

Uploaded Source

Built Distribution

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

mutagent_sdk-0.1.0-py3-none-any.whl (231.3 kB view details)

Uploaded Python 3

File details

Details for the file mutagent_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: mutagent_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 222.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mutagent_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ffb790ed458ce9efeb25e58026e208c5e8a08d57cb4777cb96d88e6751b7ead6
MD5 3a03756f5bd1b6f63e8a08ca7cc8f26d
BLAKE2b-256 bad5355383d2556cc54ca2551a891862577a1ee4e7f0398aeeb6a37dad00df46

See more details on using hashes here.

File details

Details for the file mutagent_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mutagent_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 231.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mutagent_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c86c00edb66a8329ff7edc25bd60ded36f7f632a78641d15c353d3cafb88c9fd
MD5 99404117332d241c0698dc8cbd699ff8
BLAKE2b-256 2258f4052bbe968be5b4e48fd0d6463d7d2ed8e350bee9f7d05be95821b92021

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