> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mutagent.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK Installation

> Install the MutagenT Python SDK and configure your environment

# Python SDK Installation

The MutagenT Python SDK (`mutagent-sdk`) is the official Python client for the MutagenT platform. It provides a type-safe, async-first interface for managing prompts, datasets, evaluations, traces, and more.

## Requirements

| Requirement     | Version        |
| --------------- | -------------- |
| Python          | 3.10+          |
| Package manager | pip (standard) |

## Install

```bash theme={null}
pip install mutagent-sdk
```

The PyPI distribution is `mutagent-sdk`. The import path is `from mutagent import ...`.

<Note>
  The package name on PyPI is **mutagent-sdk** but the Python import root is **mutagent** (no dash). This is standard Python SDK convention.
</Note>

## API Key

All API calls require a MutagenT API key. Get one at [app.mutagent.io](https://app.mutagent.io) or via the CLI:

```bash theme={null}
mutagent auth login
```

Set it as an environment variable:

```bash theme={null}
export MUTAGENT_API_KEY="mt_xxxxxxxxxxxx"
```

## Verify Installation

```python theme={null}
from mutagent import Mutagent

# Requires MUTAGENT_API_KEY and MUTAGENT_SERVER_URL env vars to be set
# For production: MUTAGENT_SERVER_URL=https://api.mutagent.io
client = Mutagent()
prompts = client.prompt.list_prompts()
print(f"Connected. Found {len(prompts.data)} prompts.")
```

## Sync and Async Clients

The SDK ships two client classes:

| Class           | Usage                                                  |
| --------------- | ------------------------------------------------------ |
| `Mutagent`      | Synchronous — works everywhere, no event loop required |
| `AsyncMutagent` | Asynchronous — use with `async`/`await` and `asyncio`  |

### Sync client

```python theme={null}
from mutagent import Mutagent

# Pass server_url explicitly for production (default is http://localhost:3003)
client = Mutagent(api_key="mt_xxxxxxxxxxxx", server_url="https://api.mutagent.io")

# Or use the env vars (recommended):
# export MUTAGENT_API_KEY=mt_xxxxxxxxxxxx
# export MUTAGENT_SERVER_URL=https://api.mutagent.io
client = Mutagent()
```

### Async client

```python theme={null}
import asyncio
from mutagent import AsyncMutagent

async def main():
    async with AsyncMutagent() as client:
        prompts = await client.prompt.list_prompts()
        print(f"Found {len(prompts.data)} prompts")

asyncio.run(main())
```

## Environment Variables

| Variable              | Description                               | Default                 |
| --------------------- | ----------------------------------------- | ----------------------- |
| `MUTAGENT_API_KEY`    | Your MutagenT API key                     | Required                |
| `MUTAGENT_SERVER_URL` | Custom API endpoint for the Python client | `http://localhost:3003` |

<Note>
  The Python SDK client defaults to `http://localhost:3003` for the API endpoint. For production, set `MUTAGENT_SERVER_URL=https://api.mutagent.io` or pass `server_url="https://api.mutagent.io"` to the constructor. Note: the tracing module (`init_tracing`) uses a separate `endpoint` kwarg that defaults to `https://api.mutagent.io`.
</Note>

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/sdk/python/quickstart">
    Create your first prompt in Python
  </Card>

  <Card title="Tracing" icon="radar" href="/sdk/python/tracing">
    Add observability to your Python LLM calls
  </Card>

  <Card title="Python Integrations" icon="python" href="/integrations/python/overview">
    Auto-trace OpenAI, Anthropic, LangChain, and LangGraph
  </Card>

  <Card title="API Reference" icon="book" href="/api-reference/overview">
    Full REST API documentation
  </Card>
</CardGroup>
