Skip to main content
This tutorial walks you through the complete process of invoking a Profy Expert from an external application — from obtaining the Expert identifier to building a full streaming chat interface.

What You’ll Build

A backend service that can invoke Profy Experts, with SSE streaming responses connected to a frontend chat interface. When complete, your application will have:
  • The ability to invoke any published Expert
  • Multi-turn conversation context retention
  • SSE stream parsing and error handling
  • Automatic per-token billing (METERED model)

What Is an Expert

An Expert is an AI Agent product on the Profy platform, published by creators on the Marketplace. Each Expert consists of: Through the Events API’s /openapi/v1/events/invoke endpoint, your application can invoke these Experts just like calling an API.

Prerequisites

Before getting started, make sure you have:
  • Profy App: Created and configured with OAuth in Studio
  • OAuth Access Token: Obtained through the authorization code flow (see SDK Quick Start)
  • Target Expert Identifier: The unique identifier of the Expert you want to invoke
POST /openapi/v1/events/invoke requires the events:write OAuth scope. Make sure your App requested this permission during creation.

Step 1: Find the Expert Identifier

Every published Expert has a unique identifier (slug format) used for API calls. How to find it:
  1. Marketplace page — Open the Expert’s detail page; the last path segment in the URL is the identifier, e.g., https://app.profy.cn/expert/data-analystdata-analyst
  2. Studio — If you’re the Expert’s creator, the identifier is shown in the basic information section of the editing page
Store the Expert Identifier in environment variables or configuration files to avoid hardcoding.

Step 2: Single-Turn Invocation

The core of invoking an Expert is sending a POST request to /openapi/v1/events/invoke, which returns an SSE stream.

Step 3: Multi-Turn Conversations

By passing a session_id parameter, the Expert continues the conversation within the same session context, retaining previous message history and memory.
The session_id is generated and managed by your application. All calls under the same session_id share conversation context. A new session_id starts a fresh conversation.

Step 4: Handling the SSE Stream

An Expert’s response is a standard SSE (Server-Sent Events) stream containing the following event types: Here’s a generic SSE stream parser:

Step 5: Error Handling

The invoke endpoint may return the following errors that your application should handle accordingly:
A 403 typically means the user hasn’t purchased this Expert. For METERED-type Experts, the user needs to subscribe on the Marketplace first; for ONE_TIME-type, the user needs to complete a one-time purchase.

Step 6: Building a Chat Interface

A minimal example of connecting the SSE stream to a frontend chat interface:
The frontend doesn’t call the Profy API directly — requests go through your backend proxy (/api/expert/invoke), which holds the OAuth Token and forwards the SSE stream. This avoids exposing the Access Token on the client side.

Complete Example

A runnable backend service that wraps Expert invocation as an API endpoint:

Expert Invocation vs AI Model Calls

The Profy Events API provides two types of AI calls. Choose the right endpoint for your scenario:
If you need a “ready-to-use domain expert,” use Expert invocation. If you need “raw model capabilities” with your own orchestration, use AI model calls. Both can be used together in the same application.

Next Steps

SDK Quick Start

Install the SDK, set up OAuth, and make your first event report

AI Model Calls

Use the OpenAI-compatible interface to call platform AI models

App Integration Tutorial

Create an App from scratch, configure OAuth, and publish to the Marketplace

API Reference

Complete field documentation for the Events Invoke endpoint