Excerpt Generator

Description

This API endpoint allows authenticated users to interact with an Assistant that can summarize content and answers with an excerpt. Users must provide an API key and a message to receive AI-generated excerpt responses.

Endpoint

POST /wp-json/apicloud/v1/api_services/openai_assistant/excerpt-generator

You need to be logged in to view your API key.

Headers

Header NameValueDescription
Authorization

You need to be logged in to view your API key.

Your API Key

Request Parameters

Parameter NameTypeRequiredDescription
message_contentstring✅ YesThe Content that needs to be summarized

Example Request (cURL)

curl -X POST "/wp-json/api_services/openai_assistant/consume" \
     -H "Authorization: Bearer YOUR_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
         "message_content": "Content to summarize"
     }'

Example Successful Response

{
    "thread_id": "thread_0eN64M20FTJbgP0wAV8aOFM0",
    "run_status": "completed",
    "assistant_reply": "Summarized Content as Excerpt",
   "usage_log": {
        "success": true,
        "message": "AI service usage deducted successfully!",
        "service_id": 123,
        "api_service_info": "Excerpt Generator",
        "deducted_points": 10,
        "remaining_balance": 1234567
    }
}

How It Works

  1. Authentication:
    • The request must include a valid API key in the Authorization header.
  2. Processing the Request:
    • Creates a new thread for structured conversation.
    • Sends the user message to the specified Assistant.
    • Runs the Assistant and waits for completion (polling every 2 seconds).
    • Retrieves the Assistant’s response.

Error Responses

HTTP CodeError MessageDescription
401Missing API KeyThe request does not include an API key.
401Invalid API KeyThe API key provided does not match any user.
500Thread creation failedUnable to create a new thread.
500Run failedThe Assistant run did not complete successfully.

Additional Notes

  • API usage is logged, and points are deducted from the user’s balance.