Welcome to the documentation for the PromptQL API.
The main API endpoint is available at:
/api/promptql
To use the API, send a POST request to the endpoint with a JSON body.
Example cURL request:
curl -X POST https://promptql.genexmarketing.com/.netlify/functions/promptql \
-H 'Content-Type: application/json' \
-d '{
"prompt": "Your prompt here"
}'
As described in the official documentation, PromptQL is designed to understand natural language questions and translate them into deterministic actions across your connected data sources. This means you don't need to learn a complex query language.
When supplying a prompt, you should phrase it as a clear, specific question in plain English. The system will then parse your question, map it to the relevant data, and return an accurate, reliable answer.
The key is to be as explicit as possible in your question to ensure the most accurate response from the underlying data sources.
You can call the PromptQL API from your WordPress site using the `wp_remote_post` function. Here is an example of how you can do this from your theme's `functions.php` file or a custom plugin.
<?php
function call_promptql_api( $prompt ) {
$url = 'https://promptql.genexmarketing.com/.netlify/functions/promptql';
$args = array(
'body' => json_encode( array( 'prompt' => $prompt ) ),
'headers' => array( 'Content-Type' => 'application/json' ),
'timeout' => 60,
);
$response = wp_remote_post( $url, $args );
if ( is_wp_error( $response ) ) {
$error_message = $response->get_error_message();
return "Something went wrong: $error_message";
} else {
$body = wp_remote_retrieve_body( $response );
$data = json_decode( $body );
return $data;
}
}
// Example usage:
$prompt_text = "Summarize this post for a tweet.";
$result = call_promptql_api( $prompt_text );
// var_dump( $result );
?>
The API will respond with a JSON object.