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

# Python SDK

> Official Visent Python SDK for API integration, monitoring, and automation

# Python SDK

The official Visent Python SDK provides comprehensive integration with all Visent APIs, including Telemetry monitoring, Atlas pricing intelligence, and Forge benchmarking. Built with modern Python practices, type hints, and asyncio support for high-performance applications.

Supports Python 3.8+ with both synchronous and asynchronous API clients.

## Installation

```bash theme={null}
# Using pip
pip install visent-sdk

# Using poetry
poetry add visent-sdk

# Using conda
conda install -c conda-forge visent-sdk
```

## Quick Start

### Basic Setup

```python theme={null}
from visent import VisentClient

# Initialize client
client = VisentClient(api_key='your_api_key_here')

# Or use environment variable
import os
client = VisentClient(api_key=os.getenv('VISENT_API_KEY'))
```

### Telemetry API

```python theme={null}
# Get current GPU metrics
metrics = client.telemetry.get_metrics(
    node='gpu-worker-1',
    gpu=0
)

print(f"GPU Utilization: {metrics.utilization}%")
print(f"Memory Usage: {metrics.memory_used / 1e9:.1f} GB")
print(f"Temperature: {metrics.temperature}°C")

# Get historical metrics
historical = client.telemetry.get_historical_metrics(
    node='gpu-worker-1',
    start_time='2024-01-01T00:00:00Z',
    end_time='2024-01-02T00:00:00Z'
)

# Create alert rule
alert = client.telemetry.create_alert(
    name='High GPU Temperature',
    condition='gpu_temperature > 85',
    duration='5m',
    severity='critical'
)
```

### Atlas API

```python theme={null}
# Get current pricing
pricing = client.atlas.get_current_pricing(
    gpu='h100',
    provider='aws',
    region='us-east-1'
)

print(f"Price: ${pricing.price_per_hour}/hour")
print(f"Availability: {pricing.availability}")

# Get market trends
trends = client.atlas.get_market_trends(
    gpu='h100',
    period='30d'
)

# Cost optimization
recommendations = client.atlas.get_optimization_recommendations(
    workload='ml-training',
    budget=10000,
    requirements={
        'min_gpus': 8,
        'memory_per_gpu': '80GB'
    }
)
```

### Forge API

```python theme={null}
# Start a benchmark
benchmark = client.forge.start_benchmark(
    type='ml-training',
    gpu='h100',
    config={
        'model': 'resnet50',
        'batch_size': 32,
        'iterations': 100
    }
)

print(f"Benchmark started: {benchmark.job_id}")

# Wait for completion
result = client.forge.wait_for_completion(
    benchmark.job_id,
    timeout=3600  # 1 hour timeout
)

print(f"Throughput: {result.metrics.throughput} ops/sec")
print(f"Latency: {result.metrics.latency} ms")

# Get benchmark report
report = client.forge.get_report(
    benchmark.job_id,
    format='json'
)
```

## Async Support

```python theme={null}
import asyncio
from visent import AsyncVisentClient

async def main():
    client = AsyncVisentClient(api_key='your_api_key_here')
    
    # Async API calls
    metrics = await client.telemetry.get_metrics(node='gpu-worker-1')
    pricing = await client.atlas.get_current_pricing(gpu='h100')
    
    await client.close()

# Run async code
asyncio.run(main())
```

## Error Handling

```python theme={null}
from visent.exceptions import VisentAPIError, RateLimitError

try:
    metrics = client.telemetry.get_metrics(node='invalid-node')
except RateLimitError as e:
    print(f"Rate limited: {e.retry_after} seconds")
except VisentAPIError as e:
    print(f"API error: {e.message}")
```

## Configuration

Coming soon - advanced configuration options and client customization.

## Data Models

Coming soon - Pydantic models and type definitions.

## Pagination

Coming soon - handling paginated API responses.

## Testing

Coming soon - testing applications with the Visent SDK.

## Examples

Coming soon - comprehensive examples and integration patterns.

## Next Steps

* [Set up authentication](../api/authentication) for API access
* [Explore JavaScript SDK](javascript) for Node.js applications
* [View practical examples](examples) and code samples
