# Read Deployment Details

Every deployment includes a `valohai-metadata.json` file with details about the current deployment, version, and endpoint configuration.

### Access the metadata

Read and parse the file from your endpoint code:

```python
import json

with open("valohai-metadata.json", "r") as f:
    metadata = json.load(f)

# Access specific values
deployment_name = metadata["deployment"]["name"]
version_name = metadata["version"]["name"]
endpoint_name = metadata["endpoint"]["name"]
```

### Common use cases

**Log deployment info on startup:**

```python
print(f"Starting {metadata['endpoint']['name']} from version {metadata['version']['name']}")
```

**Conditional logic based on environment:**

```python
if metadata["deployment"]["target"] == "production-cluster":
    enable_strict_validation = True
```

**Track which model files are loaded:**

```python
model_files = [f["datum"]["name"] for f in metadata["endpoint"]["files"]]
print(f"Loaded models: {', '.join(model_files)}")
```

### Metadata structure

The JSON contains these top-level keys:

* `deployment` - Deployment details (name, target, URLs)
* `version` - Version info (name, commit, creation time)
* `endpoint` - Endpoint configuration (resources, files, status)
* `project` - Project details (name, owner)
* `meta` - Metadata about the metadata file itself

### Example metadata file

```json
{
  "deployment": {
    "name": "fraud-detection-api",
    "target": "production-cluster",
    "url": "https://app.valohai.com/api/v0/deployments/..."
  },
  "version": {
    "name": "20240315.2",
    "enabled": true,
    "ctime": "2024-03-15T14:23:11.431914Z"
  },
  "endpoint": {
    "name": "predict",
    "cpu_request": 0.1,
    "memory_limit": 512,
    "files": [
      {
        "name": "model",
        "datum": {
          "name": "fraud_model_v2.pkl",
          "size": 1048576
        }
      }
    ]
  },
  "project": {
    "name": "fraud-detection",
    "owner": {
      "username": "acme"
    }
  }
}
```

***

**Next:** Learn about [installing additional packages](https://github.com/valohai/dokuhai/blob/main/docs/install-packages.md) in your deployments.
