Skip to main content

REST API Reference

AIP's REST API provides a way to programmatically access its core AI functionalities from external applications. You can use it to generate text and images, create embeddings, or interact with your chatbots, all without needing to log in to the WordPress dashboard.

Authentication

All API requests must be authenticated. Access is controlled by a single Public API Key that you can set in the plugin's settings.

  1. Navigate to AIP > Dashboard in your WordPress admin area.
  2. Open the Advanced accordion.
  3. In the Public API Access section, enter a strong, unique key. This key will be used to authenticate all of your API requests. Leaving this field blank disables all public API access.

Sending the API Key

You can send your API key in one of two ways with each request:

1. Authorization Header (Recommended)

Include the key in the Authorization header as a Bearer token.

curl ... -H "Authorization: Bearer YOUR_API_KEY"

2. Request Parameter

Include the key as a parameter in the request body or query string named aipkit_api_key.

curl ... -d "aipkit_api_key=YOUR_API_KEY&..."

Endpoints

All endpoints are relative to your site's REST API base URL (/wp-json/). The namespace for the plugin is aipkit/v1.


Text Generation

Generate text content using any of your configured AI providers.

  • Endpoint: POST /wp-json/aipkit/v1/generate
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringYesThe AI provider to use. One of: openai, azure, google, openrouter, deepseek.
modelstringYesThe specific model or deployment ID to use for generation.
messagesarrayYesAn array of message objects, following the standard chat completions format. The last message must have the role user.
system_instructionstringNoOptional system instructions to guide the AI's behavior. Overrides the system role message in the messages array if both are provided.
ai_paramsobjectNoAn object of AI parameters (e.g., temperature, max_tokens) to override the global defaults.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"provider": "openai",
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Write a short poem about WordPress."
}
],
"ai_params": {
"temperature": 0.8
}
}'

Example Response

{
"content": "In fields of code, a platform stands,\nWith plugins vast and themes so grand.\nA simple post, a complex site,\nWordPress shines, a guiding light.",
"usage": {
"input_tokens": 28,
"output_tokens": 35,
"total_tokens": 63
},
"provider": "OpenAI",
"model": "gpt-4o-mini"
}

Image Generation

Create images from a text prompt using your configured image generation providers.

  • Endpoint: POST /wp-json/aipkit/v1/images/generate
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringNoThe image provider. One of openai, google. Defaults to openai.
promptstringYesA text description of the desired image.
modelstringNoThe specific model to use (e.g., dall-e-3). Defaults to the one set in your plugin settings.
nintegerNoThe number of images to generate. Default is 1.
sizestringNoThe size of the generated images (e.g., 1024x1024). Defaults to the one set in your plugin settings.
qualitystringNo(DALL-E 3) The quality of the image. standard or hd.
stylestringNo(DALL-E 3) The style of the generated images. vivid or natural.
response_formatstringNoThe format of the returned image. url or b64_json. Default is url.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/images/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"prompt": "An astronaut riding a horse on Mars, photorealistic",
"provider": "openai",
"model": "dall-e-3",
"n": 1,
"size": "1024x1024",
"quality": "hd"
}'

Example Response

{
"images": [
{
"url": "https://oaidalleapiprodscus.blob.core.windows.net/private/...",
"revised_prompt": "A photorealistic image of an astronaut in a full spacesuit, gracefully riding a majestic horse across the dusty, red landscape of Mars. The Martian sky is a pale pink, and Earth is a small blue dot in the distance."
}
],
"usage": null,
"message": "1 image generated successfully."
}

Embeddings Generation

Convert text into numerical vector representations (embeddings).

  • Endpoint: POST /wp-json/aipkit/v1/embeddings
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringYesThe embedding provider. One of openai, google, azure.
modelstringYesThe specific embedding model or Azure deployment ID.
inputstring or arrayYesThe text string or array of strings to embed.
dimensionsintegerNo(OpenAI text-embedding-3, Azure) The desired number of output dimensions.
encoding_formatstringNo(OpenAI) float or base64. Default is float.
task_typestringNo(Google Gemini) The intended task for the embedding.
output_dimensionalityintegerNo(Google Gemini) Reduce the embedding dimensions.
userstringNo(OpenAI, Azure) A unique identifier for the end-user for monitoring purposes.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"provider": "openai",
"model": "text-embedding-3-small",
"input": "This is the text to embed."
}'

Example Response

{
"embeddings": [
[ -0.006929283495992422, -0.005336422473192215, ... ]
],
"usage": {
"input_tokens": 6,
"total_tokens": 6
},
"provider": "OpenAI",
"model": "text-embedding-3-small"
}

Chat Interaction

Send a message to a specific chatbot and receive a reply.

  • Endpoint: POST /wp-json/aipkit/v1/chat/{bot_id}/message
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
bot_idintegerYes(in URL) The ID of the chatbot you want to interact with.
messagesarrayYesAn array of message objects representing the conversation history. The last message must have the role user.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/chat/9453/message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"messages": [
{ "role": "user", "content": "Hello, what can you do?" }
]
}'

Example Response

{
"reply": "I am a helpful AI assistant. I can answer your questions, help you write content, and much more!",
"usage": {
"input_tokens": 15,
"output_tokens": 21,
"total_tokens": 36
},
"bot_id": 9453,
"model": "gpt-4o-mini"
}

Upsert to Vector Store

Add content to a Pinecone or Qdrant knowledge base. This endpoint will automatically create embeddings for your content and upsert the resulting vectors into your specified index or collection.

  • Endpoint: POST /wp-json/aipkit/v1/vector-stores/upsert
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringYesThe vector database provider. One of pinecone, qdrant.
target_idstringYesThe name of the target index (for Pinecone) or collection (for Qdrant).
vectorsarrayYesAn array of objects to embed and upsert. Each object must have a content key. An id and metadata are optional.
embedding_providerstringYesThe provider to use for generating embeddings (openai, google, azure).
embedding_modelstringYesThe specific model to use for generating embeddings.
namespacestringNo(Pinecone only) The namespace within the index to upsert to.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/vector-stores/upsert \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"provider": "pinecone",
"target_id": "my-knowledge-base",
"embedding_provider": "openai",
"embedding_model": "text-embedding-3-small",
"vectors": [
{
"id": "doc1",
"content": "AI Power is a WordPress plugin.",
"metadata": { "source": "manual" }
},
{
"id": "doc2",
"content": "It allows you to build chatbots and generate content.",
"metadata": { "source": "manual" }
}
]
}'

Example Response

{
"upserted_count": 2,
"status": "success"
}
I have reviewed the `aipkit_rest_controller.php` and `base_ajax_handler.php` files to understand the API endpoints and authentication. I have structured the documentation with an overview, authentication instructions, and detailed sections for each of the 5 REST endpoints. I have included the method, URL, parameters table, a `curl` example, and a sample JSON response for each endpoint to make the documentation comprehensive and easy to follow. I used simple English as requested.I will now create the documentation file for the REST API Reference.

```markdown
---
id: api-reference
slug: /api-reference
title: API Reference
sidebar_position: 14
---

import publicapi from '/img/api/public-api.png';

# REST API Reference

AIP's REST API provides a way to programmatically access its core AI functionalities from external applications. You can use it to generate text and images, create embeddings, or interact with your chatbots, all without needing to log in to the WordPress dashboard.

## Authentication

All API requests must be authenticated. Access is controlled by a single **Public API Key** that you can set in the plugin's settings.

1. Navigate to **AIP > Dashboard** in your WordPress admin area.
2. Open the **Advanced** accordion.
3. In the **Public API Access** section, enter a strong, unique key. This key will be used to authenticate all of your API requests. Leaving this field blank disables all public API access.

<img src={publicapi} width="600"/>

### Sending the API Key

You can send your API key in one of two ways with each request:

**1. Authorization Header (Recommended)**

Include the key in the `Authorization` header as a Bearer token.

```bash
curl ... -H "Authorization: Bearer YOUR_API_KEY"

2. Request Parameter

Include the key as a parameter in the request body or query string named aipkit_api_key.

curl ... -d "aipkit_api_key=YOUR_API_KEY&..."

Endpoints

All endpoints are relative to your site's REST API base URL (/wp-json/). The namespace for the plugin is aipkit/v1.


Text Generation

Generate text content using any of your configured AI providers.

  • Endpoint: POST /wp-json/aipkit/v1/generate
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringYesThe AI provider to use. One of: openai, azure, google, openrouter, deepseek.
modelstringYesThe specific model or deployment ID to use for generation.
messagesarrayYesAn array of message objects, following the standard chat completions format. The last message must have the role user.
system_instructionstringNoOptional system instructions to guide the AI's behavior. Overrides the system role message in the messages array if both are provided.
ai_paramsobjectNoAn object of AI parameters (e.g., temperature, max_tokens) to override the global defaults.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"provider": "openai",
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Write a short poem about WordPress."
}
],
"ai_params": {
"temperature": 0.8
}
}'

Example Response

{
"content": "In fields of code, a platform stands,\nWith plugins vast and themes so grand.\nA simple post, a complex site,\nWordPress shines, a guiding light.",
"usage": {
"input_tokens": 28,
"output_tokens": 35,
"total_tokens": 63
},
"provider": "OpenAI",
"model": "gpt-4o-mini"
}

Image Generation

Create images from a text prompt using your configured image generation providers.

  • Endpoint: POST /wp-json/aipkit/v1/images/generate
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringNoThe image provider. One of openai, google. Defaults to openai.
promptstringYesA text description of the desired image.
modelstringNoThe specific model to use (e.g., dall-e-3). Defaults to the one set in your plugin settings.
nintegerNoThe number of images to generate. Default is 1.
sizestringNoThe size of the generated images (e.g., 1024x1024). Defaults to the one set in your plugin settings.
qualitystringNo(DALL-E 3) The quality of the image. standard or hd.
stylestringNo(DALL-E 3) The style of the generated images. vivid or natural.
response_formatstringNoThe format of the returned image. url or b64_json. Default is url.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/images/generate \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"prompt": "An astronaut riding a horse on Mars, photorealistic",
"provider": "openai",
"model": "dall-e-3",
"n": 1,
"size": "1024x1024",
"quality": "hd"
}'

Example Response

{
"images": [
{
"url": "https://oaidalleapiprodscus.blob.core.windows.net/private/...",
"revised_prompt": "A photorealistic image of an astronaut in a full spacesuit, gracefully riding a majestic horse across the dusty, red landscape of Mars. The Martian sky is a pale pink, and Earth is a small blue dot in the distance."
}
],
"usage": null,
"message": "1 image generated successfully."
}

Embeddings Generation

Convert text into numerical vector representations (embeddings).

  • Endpoint: POST /wp-json/aipkit/v1/embeddings
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringYesThe embedding provider. One of openai, google, azure.
modelstringYesThe specific embedding model or Azure deployment ID.
inputstring or arrayYesThe text string or array of strings to embed.
dimensionsintegerNo(OpenAI text-embedding-3, Azure) The desired number of output dimensions.
encoding_formatstringNo(OpenAI) float or base64. Default is float.
task_typestringNo(Google Gemini) The intended task for the embedding.
output_dimensionalityintegerNo(Google Gemini) Reduce the embedding dimensions.
userstringNo(OpenAI, Azure) A unique identifier for the end-user for monitoring purposes.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"provider": "openai",
"model": "text-embedding-3-small",
"input": "This is the text to embed."
}'

Example Response

{
"embeddings": [
[ -0.006929283495992422, -0.005336422473192215, ... ]
],
"usage": {
"input_tokens": 6,
"total_tokens": 6
},
"provider": "OpenAI",
"model": "text-embedding-3-small"
}

Chat Interaction

Send a message to a specific chatbot and receive a reply.

  • Endpoint: POST /wp-json/aipkit/v1/chat/{bot_id}/message
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
bot_idintegerYes(in URL) The ID of the chatbot you want to interact with.
messagesarrayYesAn array of message objects representing the conversation history. The last message must have the role user.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/chat/9453/message \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"messages": [
{ "role": "user", "content": "Hello, what can you do?" }
]
}'

Example Response

{
"reply": "I am a helpful AI assistant. I can answer your questions, help you write content, and much more!",
"usage": {
"input_tokens": 15,
"output_tokens": 21,
"total_tokens": 36
},
"bot_id": 9453,
"model": "gpt-4o-mini"
}

Upsert to Vector Store

Add content to a Pinecone or Qdrant knowledge base. This endpoint will automatically create embeddings for your content and upsert the resulting vectors into your specified index or collection.

  • Endpoint: POST /wp-json/aipkit/v1/vector-stores/upsert
  • Method: POST
  • Content-Type: application/json

Parameters

ParameterTypeRequiredDescription
providerstringYesThe vector database provider. One of pinecone, qdrant.
target_idstringYesThe name of the target index (for Pinecone) or collection (for Qdrant).
vectorsarrayYesAn array of objects to embed and upsert. Each object must have a content key. An id and metadata are optional.
embedding_providerstringYesThe provider to use for generating embeddings (openai, google, azure).
embedding_modelstringYesThe specific model to use for generating embeddings.
namespacestringNo(Pinecone only) The namespace within the index to upsert to.

Example Request

curl -X POST https://your-website.com/wp-json/aipkit/v1/vector-stores/upsert \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"provider": "pinecone",
"target_id": "my-knowledge-base",
"embedding_provider": "openai",
"embedding_model": "text-embedding-3-small",
"vectors": [
{
"id": "doc1",
"content": "AI Power is a WordPress plugin.",
"metadata": { "source": "manual" }
},
{
"id": "doc2",
"content": "It allows you to build chatbots and generate content.",
"metadata": { "source": "manual" }
}
]
}'

Example Response

{
"upserted_count": 2,
"status": "success"
}