> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
