Pearl APIDocsReference

Deprecated: Expert Assistance

The verify metadata attribute is now deprecated. Please use mode instead. See Conversation modes page

The Pearl API allows you to seamlessly transition from a chat with PearlAI to a conversation with a human Expert. To request an Expert to join the conversation, include the "mode" metadata attribute with a value of "pearl-ai-expert".

from uuid import uuid4
from openai import OpenAI

client = OpenAI(
    api_key="PEARL_API_KEY",
    base_url="https://api.pearl.com/api/v1/"
)

session_id = str(uuid4())  # Generate a unique GUID

response = client.chat.completions.create(
    model="pearl-ai",
    messages=[
        {
            "role": "user",
            "content": "Explain to me how AI works"
        }
    ],
    metadata={"sessionId": session_id, "mode": "pearl-ai-expert"}
)

print(response.choices[0].message)

This will automatically connect your chat conversation with a human Expert after a certain number of replies from PearlAI. The response time depends on factors such as the complexity of the question and Expert availability.

In this case, you must implement automatic retries to handle delayed responses from the Expert or use webhook callbacks

Webhook notifications