# Platform

## Overview

Client lifecycle, authentication, and platform API access.

`flush` and `shutdown` control the span export pipeline. `auth_check` validates API credentials. The `platform` property exposes the async PlatformClient for secrets and other platform features.

***

## `auth_check` [(source)](https://github.com/interactive-ai/interactiveai-python-sdk/blob/main/interactiveai/_client/client.py#L2781)

Check if the provided credentials (public and secret key) are valid.

```python
auth_check() -> bool
```

***

## `flush` [(source)](https://github.com/interactive-ai/interactiveai-python-sdk/blob/main/interactiveai/_client/client.py#L2150)

Force flush all pending spans and events to the InteractiveAI API.

This method manually flushes any pending spans, scores, and other events to the InteractiveAI API. It's useful in scenarios where you want to ensure all data is sent before proceeding, without waiting for the automatic flush interval.

```python
flush() -> None
```

**Example**

```python
# Record some spans and scores
with interactiveai.start_as_current_span(name="operation") as span:
    # Do work...
    pass

# Ensure all data is sent to InteractiveAI before proceeding
interactiveai.flush()

# Continue with other work
```

***

## `platform` [(source)](https://github.com/interactive-ai/interactiveai-python-sdk/blob/main/interactiveai/_client/client.py#L328)

Access the platform API for secrets management and other platform features.

The PlatformClient is lazily initialized on first access and provides async methods for managing secrets stored in the InteractiveAI platform.

Returns: PlatformClient: A client for interacting with platform features.

Example: \`\`\`python # List all secrets secrets = await client.platform.secrets.list()

````
# Get a specific secret
secret = await client.platform.secrets.get("my-api-key")

# Create a new secret
await client.platform.secrets.create("my-secret", {"api_key": "value"})
```
````

***

## `shutdown` [(source)](https://github.com/interactive-ai/interactiveai-python-sdk/blob/main/interactiveai/_client/client.py#L2173)

Shut down the InteractiveAI client and flush all pending data.

This method cleanly shuts down the InteractiveAI client, ensuring all pending data is flushed to the API and all background threads are properly terminated.

It's important to call this method when your application is shutting down to prevent data loss and resource leaks. For most applications, using the client as a context manager or relying on the automatic shutdown via atexit is sufficient.

```python
shutdown() -> None
```

**Example**

```python
# Initialize Interactive
interactiveai = Interactive(public_key="...", secret_key="...")

# Use Interactive throughout your application
# ...

# When application is shutting down
interactiveai.shutdown()
```
