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

# Python SDK

> Use Galileo from Python applications and notebooks.

The Python SDK provides synchronous resources and generated Pydantic response models. It supports Python 3.10 through 3.13.

<Info>
  Current preview: `0.1.0rc4`. Include `--pre` while Galileo is in preview.
</Info>

```bash theme={null}
pip install --pre physionlabs
```

```python theme={null}
import os

from physionlabs import Galileo

galileo = Galileo(api_key=os.environ["GALILEO_API_KEY"])

evaluation = galileo.evaluations.create_and_wait(
    prompt="A paper boat floats down a narrow stream.",
    video={"url": "https://example.com/boat.mp4"},
)
```

Check the terminal status before reading the result:

```python theme={null}
if evaluation.status.value == "failed":
    print(evaluation.error.message if evaluation.error else "Evaluation failed")
elif evaluation.result:
    for finding in evaluation.result.glitches:
        print(finding.type.value, finding.description)
```

## Resources

| Resource      | Methods                                                                                             |
| ------------- | --------------------------------------------------------------------------------------------------- |
| `evaluations` | `create`, `create_and_wait`, `retrieve`, `list`, `iterate`, `retry`, `delete`, `wait_until_settled` |
| `videos`      | `upload`, `retrieve`, `wait_until_ready`                                                            |
| `account`     | `retrieve`, `models`, `quota`, `credits`, `status`                                                  |

## Client lifetime

Use a context manager to close its HTTP connections:

```python theme={null}
import os

from physionlabs import Galileo

with Galileo(api_key=os.environ["GALILEO_API_KEY"]) as galileo:
    account = galileo.account.retrieve()
```

## Configuration

```python theme={null}
galileo = Galileo(
    api_key=os.environ["GALILEO_API_KEY"],
    timeout=60.0,
    max_retries=2,
    max_concurrency=4,
)
```

| Option                   | Default                      | Purpose                                            |
| ------------------------ | ---------------------------- | -------------------------------------------------- |
| `api_key`                | `GALILEO_API_KEY`            | Authenticate requests.                             |
| `base_url`               | `https://api.physionlabs.ai` | Select the API host.                               |
| `upload_base_url`        | `base_url`                   | Resolve relative upload paths.                     |
| `timeout`                | `60.0`                       | Limit one request attempt in seconds.              |
| `max_retries`            | `2`                          | Retry safe requests after transient failures.      |
| `rate_limit_budget`      | `60.0`                       | Limit total time spent waiting on `429` responses. |
| `max_rate_limit_retries` | `20`                         | Limit repeated `429` responses.                    |
| `max_concurrency`        | `4`                          | Limit requests in flight.                          |

Evaluation creation is sent once because a repeated submission can create a second evaluation. Rate-limit responses use their own time and attempt limits.

## Errors

Catch `GalileoError` for any SDK failure. API failures inherit from `APIError` and include `InvalidRequestError`, `AuthenticationError`, `NotFoundError`, `InsufficientCreditsError`, `RateLimitError`, and `ServerError`. Transport and polling failures use `ConnectionError` and `PollTimeoutError`.

[View the source on GitHub](https://github.com/Physion-Labs/galileo-python).
