Skip to main content

🤖 AI API

Currently, the AI API uses Google Gemini to convert SMS, text, and receipt data into transactions automatically. In the future, it will also support converting emails, providing useful insights, making predictions, and much more to enhance your financial experience.

📡 Base URL​

All AI endpoints are prefixed with:

/wp-json/pika/v1/ai

🚀 Endpoints​

Text to Transaction​

Convert a text like sms or user note to transaction

Endpoint: GET /wp-json/pika/v1/ai/text-to-transaction

Headers:

  • Cookie: Authentication cookie

Request Body:

{
"text":"spend RS10, soft drink, now, federal"
}

Response:

{
"account": {
"id": "1",
"name": "Federal",
"description": "Main Account",
"avatar": {
"id": "1",
"url": "http:\/\/localhost:8000\/wp-content\/uploads\/pika\/avatars\/account-6889ac3ac6f73-175389900.jpg",
"type": "image",
"name": "1000118509.jpg",
"size": "9444"
},
"lastTransactionAt": null,
"totalTransactions": 0,
"balance": "50921.7500",
"icon": "wallet",
"bgColor": "#3B82F6",
"color": "#ffffff"
},
"amount": 10,
"category": {
"id": "4",
"name": "Coffee & Snacks",
"icon": "coffee",
"color": "#FFFFFF",
"bgColor": "#975A16",
"description": "Coffee and snack expenses",
"isSystem": true,
"isParent": false,
"type": "expense",
"parentId": "1",
"children": []
},
"date": "2025-08-28 19:25:55.000000+05:30",
"note": "Spent 10 RS for soft drink from Federal account.",
"person": null,
"tags": [],
"title": "Soft Drink",
"toAccount": null,
"type": "expense"
}

Example Request:

curl 'http://localhost:5173/wp-json/pika/v1/ai/text-to-transaction' \
-b {{auth-token}}
--data-raw '{"text":"spend RS10, soft drink, now, federal"}'

Image to Transaction​

Convert a receipt image to a transaction using AI.

Endpoint: POST /wp-json/pika/v1/ai/receipt-to-transaction

Headers:

  • Cookie: Authentication cookie
  • Content-Type: multipart/form-data

Request Body:

  • receipt: The image file of the receipt (e.g., JPEG, PNG).

Response:

{
"account": null,
"amount": 681,
"category": {
"id": "2",
"name": "Dining Out",
"icon": "utensils",
"color": "#FFFFFF",
"bgColor": "#DD6B20",
"description": "Restaurant and dining out expenses",
"isSystem": true,
"isParent": false,
"type": "expense",
"parentId": "1",
"children": []
},
"date": "2025-05-06 22:20:00.000000000Z",
"note": "Dine In: F14A. Bill No: GRDYMR07611",
"person": null,
"tags": [],
"title": "ZAMZAM GRANDE",
"toAccount": null,
"type": "expense"
}

🚨 Error Responses​

AI Service Unavailable​

This error indicates the AI service is temporarily down or unreachable.

{
"code": "ai_service_unavailable",
"message": "AI service is currently unavailable.",
"data": {
"status": 503
}
}

AI Rate Limit Exceeded​

This error occurs when too many requests are sent to the AI service in a short period.

{
"code": "ai_rate_limit",
"message": "AI service rate limit exceeded. Please try again later.",
"data": {
"status": 429
}
}

Invalid AI Response​

This response is used when the AI service returns a malformed or unexpected result.

{
"code": "ai_invalid_response",
"message": "Invalid response from AI service.",
"data": {
"status": 500
}
}

Insufficient Data for AI​

This error is triggered when there isn't enough data provided to perform the requested AI analysis.

{
"code": "insufficient_data",
"message": "Insufficient data for AI analysis.",
"data": {
"status": 400
}
}

AI Features Disabled​

This error indicates that the AI features have been turned off by the administrator.

{
"code": "ai_disabled",
"message": "AI features are currently disabled.",
"data": {
"status": 403
}
}

Invalid Image File​

This error is returned when the uploaded file is not a valid image or the format is unsupported.

{
"code": "invalid_image",
"message": "Invalid image file. Please upload a valid image (PNG, JPEG, GIF, WebP) under 10MB.",
"data": {
"status": 400
}
}

File Too Large​

This error occurs if the uploaded file exceeds the maximum allowed size (e.g., 10MB).

{
"code": "file_too_large",
"message": "File is too large. Maximum size is 10MB.",
"data": {
"status": 400
}
}

Wrong File Type​

This is used when a file is uploaded that is not one of the accepted image formats.

{
"code": "wrong_file_type",
"message": "Wrong file type. Please upload an image file (PNG, JPEG, GIF, WebP).",
"data": {
"status": 400
}
}

Cannot Delete Account with Transactions​

This error prevents the deletion of an account that still has associated financial transactions.

{
"code": "account_has_transactions",
"message": "Account has transactions. Please delete the transactions first.",
"data": {
"status": 400
}
}