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

# SDK Overview

> Profy App SDK: TypeScript and Python SDKs for OAuth integration, billing events, and AI model access.

# SDK Overview

Profy provides official SDKs for TypeScript and Python that wrap OAuth token management, billing event reporting, and AI model access — so you can focus on building your application.

## Install

<CodeGroup>
  ```bash TypeScript theme={null}
  npm install @profy-ai/sdk
  ```

  ```bash Python theme={null}
  pip install profy-sdk
  ```
</CodeGroup>

## What Can You Build?

<CardGroup cols={2}>
  <Card title="SaaS with Pay-per-Use" icon="receipt">
    Report custom billing events when users trigger paid actions. Profy handles credit deduction.
  </Card>

  <Card title="AI-Powered Tools" icon="wand-magic-sparkles">
    Call AI models via OpenAI-compatible API with automatic token-based billing.
  </Card>

  <Card title="Expert Integration" icon="robot">
    Embed Profy Expert agents in your app for domain-specific AI capabilities.
  </Card>

  <Card title="Multi-Platform Apps" icon="layer-group">
    Build with TypeScript or Python, with contrib storage for Drizzle and SQLAlchemy.
  </Card>
</CardGroup>

## Core Capabilities

| Capability           | Description                                                            |
| -------------------- | ---------------------------------------------------------------------- |
| **OAuth 2.0**        | Authorization Code Flow with automatic token refresh                   |
| **PER\_USE Billing** | Report custom events with fixed pricing                                |
| **METERED Billing**  | AI model calls with token-based billing                                |
| **Expert Invoke**    | Call platform Experts via SSE streaming                                |
| **Token Management** | Auto-refresh, expiry detection, contrib storage                        |
| **Error Handling**   | Typed exceptions: `AuthExpired`, `InsufficientBalance`, `InvalidEvent` |

## Architecture

```mermaid theme={null}
graph LR
    App["Your App"] --> SDK["Profy SDK"]
    SDK --> OAuth["OAuth 2.0"]
    SDK --> Events["Events API"]

    OAuth --> Token["Token Exchange & Refresh"]
    Events --> PU["PER_USE Events"]
    Events --> Chat["AI Chat (METERED)"]
    Events --> Invoke["Expert Invoke (METERED)"]

    subgraph Profy["Profy Platform"]
        Token
        PU
        Chat
        Invoke
    end

    style Profy fill:#f8f4f0,stroke:#a8866a
```

## Get Started

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/en/sdk/quickstart">
    Install the SDK and make your first API call in 5 minutes
  </Card>

  <Card title="Integration Tutorial" icon="book" href="/en/documentation/integration-quickstart">
    Complete end-to-end integration walkthrough
  </Card>
</CardGroup>
