> For the complete documentation index, see [llms.txt](https://docs.interactive.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.interactive.ai/sdk/platform.md).

# 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()
```


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.interactive.ai/sdk/platform.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
