> For the complete documentation index, see [llms.txt](https://docs.valohai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.valohai.com/serving-your-models/real-time-endpoints/metadata.md).

# 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.valohai.com/serving-your-models/real-time-endpoints/metadata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
