API Documentation
One prompt at a time
Complete reference for the SmartPrompt API. Generate AI-powered prompts programmatically with our RESTful API.
Getting Started
Learn the basics and make your first API call
API Endpoints
Complete reference for all available endpoints
Code Examples
Ready-to-use code snippets in multiple languages
Try It Live
Test API endpoints directly from this page
๐ Getting Started
Base URL
https://smartprompt.dev/api/v1
Authentication
Currently, the SmartPrompt API is open and doesn't require authentication. All endpoints are publicly accessible.
Content Type
All API requests should use Content-Type: application/json
for POST requests.
Response Format
All API responses follow a consistent format:
{
"success": true,
"data": { ... },
"error": null
}
๐ API Endpoints
POST
/generate
Generate a single AI-powered prompt based on type and parameters.
Request Body:
{
"type": "business|ui|service",
"params": {
"category": "string",
"complexity": "low|medium|high",
"title": "string",
"description": "string",
"language": "english|spanish|french|german|chinese|...",
"programmingLanguage": "string (for UI/Service types)",
"additionalDescription": "string (optional)",
"customCategory": "string (if category is 'custom')",
"customCategoryDescription": "string (if category is 'custom')"
}
}
Response:
{
"success": true,
"prompt": {
"type": "business",
"category": "e-commerce",
"title": "E-commerce Platform",
"prompt": "# Complete implementation guide...",
"sections": ["Executive Summary", "Technical Requirements", "..."],
"estimatedLength": {
"words": 1250,
"characters": 8500,
"estimatedReadingTime": "6 minutes"
},
"complexity": "medium"
},
"validation": {
"isValid": true,
"score": 85,
"quality": "good"
}
}
GET
/health
Check the health status of the API server.
Response:
{
"status": "healthy",
"timestamp": "2025-08-27T14:30:00.000Z",
"version": "1.20.3",
"scheduler": {
"isRunning": false,
"geminiAvailable": true
},
"gemini": {
"totalKeys": 5,
"currentKeyIndex": 0
}
}
๐ก Code Examples
Choose your preferred programming language to see implementation examples:
JavaScript (Fetch API)
// Generate a business prompt
const response = await fetch('https://smartprompt.dev/api/v1/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'business',
params: {
category: 'e-commerce',
complexity: 'medium',
title: 'Online Marketplace',
description: 'A platform for buying and selling products',
language: 'english'
}
})
});
const result = await response.json();
if (result.success) {
console.log('Generated Prompt:', result.prompt.prompt);
console.log('Word Count:', result.prompt.estimatedLength.words);
} else {
console.error('Error:', result.error);
}
Python (Requests)
import requests
import json
# Generate a UI prompt
url = 'https://smartprompt.dev/api/v1/generate'
payload = {
'type': 'ui',
'params': {
'category': 'dashboard',
'complexity': 'high',
'programmingLanguage': 'react',
'title': 'Analytics Dashboard',
'description': 'Modern analytics dashboard with charts',
'language': 'english'
}
}
response = requests.post(url, json=payload)
result = response.json()
if result['success']:
print(f"Generated Prompt: {result['prompt']['prompt']}")
print(f"Word Count: {result['prompt']['estimatedLength']['words']}")
else:
print(f"Error: {result['error']}")
cURL
# Generate a service prompt
curl -X POST https://smartprompt.dev/api/v1/generate \
-H "Content-Type: application/json" \
-d '{
"type": "service",
"params": {
"category": "api",
"complexity": "medium",
"programmingLanguage": "nodejs",
"title": "User Authentication API",
"description": "RESTful API for user authentication and authorization",
"language": "english"
}
}' | jq '.'
Java (OkHttp)
import okhttp3.*;
import com.google.gson.*;
import java.io.IOException;
public class SmartPromptClient {
private static final String BASE_URL = "https://smartprompt.dev/api/v1";
private final OkHttpClient client = new OkHttpClient();
private final Gson gson = new Gson();
public void generatePrompt() throws IOException {
// Create request payload
JsonObject params = new JsonObject();
params.addProperty("category", "e-commerce");
params.addProperty("complexity", "medium");
params.addProperty("title", "Online Marketplace");
params.addProperty("description", "A platform for buying and selling products");
params.addProperty("language", "english");
JsonObject payload = new JsonObject();
payload.addProperty("type", "business");
payload.add("params", params);
RequestBody body = RequestBody.create(
gson.toJson(payload),
MediaType.get("application/json; charset=utf-8")
);
Request request = new Request.Builder()
.url(BASE_URL + "/generate")
.post(body)
.build();
try (Response response = client.newCall(request).execute()) {
String responseBody = response.body().string();
JsonObject result = gson.fromJson(responseBody, JsonObject.class);
if (result.get("success").getAsBoolean()) {
JsonObject prompt = result.getAsJsonObject("prompt");
System.out.println("Generated Prompt: " + prompt.get("prompt").getAsString());
System.out.println("Word Count: " + prompt.getAsJsonObject("estimatedLength").get("words").getAsInt());
} else {
System.err.println("Error: " + result.get("error").getAsString());
}
}
}
}
PHP (cURL)
<?php
// Generate a UI prompt using SmartPrompt API
function generatePrompt() {
$url = 'https://smartprompt.dev/api/v1/generate';
$payload = [
'type' => 'ui',
'params' => [
'category' => 'dashboard',
'complexity' => 'high',
'programmingLanguage' => 'react',
'title' => 'Analytics Dashboard',
'description' => 'Modern analytics dashboard with charts',
'language' => 'english'
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Accept: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
$result = json_decode($response, true);
if ($result['success']) {
echo "Generated Prompt: " . $result['prompt']['prompt'] . "\n";
echo "Word Count: " . $result['prompt']['estimatedLength']['words'] . "\n";
} else {
echo "Error: " . $result['error'] . "\n";
}
} else {
echo "HTTP Error: " . $httpCode . "\n";
}
}
generatePrompt();
?>
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Params struct {
Category string `json:"category"`
Complexity string `json:"complexity"`
ProgrammingLanguage string `json:"programmingLanguage"`
Title string `json:"title"`
Description string `json:"description"`
Language string `json:"language"`
}
type Request struct {
Type string `json:"type"`
Params Params `json:"params"`
}
type EstimatedLength struct {
Words int `json:"words"`
}
type Prompt struct {
Prompt string `json:"prompt"`
EstimatedLength EstimatedLength `json:"estimatedLength"`
}
type Response struct {
Success bool `json:"success"`
Prompt Prompt `json:"prompt"`
Error string `json:"error"`
}
func generatePrompt() error {
url := "https://smartprompt.dev/api/v1/generate"
payload := Request{
Type: "service",
Params: Params{
Category: "api",
Complexity: "medium",
ProgrammingLanguage: "go",
Title: "User Authentication API",
Description: "RESTful API for user authentication",
Language: "english",
},
}
jsonData, err := json.Marshal(payload)
if err != nil {
return err
}
resp, err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
return err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
var result Response
if err := json.Unmarshal(body, &result); err != nil {
return err
}
if result.Success {
fmt.Printf("Generated Prompt: %s\n", result.Prompt.Prompt)
fmt.Printf("Word Count: %d\n", result.Prompt.EstimatedLength.Words)
} else {
fmt.Printf("Error: %s\n", result.Error)
}
return nil
}
func main() {
if err := generatePrompt(); err != nil {
fmt.Printf("Error: %v\n", err)
}
}
Ruby
require 'net/http'
require 'json'
require 'uri'
class SmartPromptClient
BASE_URL = 'https://smartprompt.dev/api/v1'
def self.generate_prompt
uri = URI("#{BASE_URL}/generate")
payload = {
type: 'business',
params: {
category: 'e-commerce',
complexity: 'medium',
title: 'Online Marketplace',
description: 'A platform for buying and selling products',
language: 'english'
}
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request.body = payload.to_json
response = http.request(request)
result = JSON.parse(response.body)
if result['success']
puts "Generated Prompt: #{result['prompt']['prompt']}"
puts "Word Count: #{result['prompt']['estimatedLength']['words']}"
else
puts "Error: #{result['error']}"
end
rescue StandardError => e
puts "Error: #{e.message}"
end
end
SmartPromptClient.generate_prompt
C# (HttpClient)
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class SmartPromptClient
{
private static readonly HttpClient client = new HttpClient();
private const string BaseUrl = "https://smartprompt.dev/api/v1";
public class Params
{
[JsonProperty("category")]
public string Category { get; set; }
[JsonProperty("complexity")]
public string Complexity { get; set; }
[JsonProperty("programmingLanguage")]
public string ProgrammingLanguage { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("description")]
public string Description { get; set; }
[JsonProperty("language")]
public string Language { get; set; }
}
public class Request
{
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("params")]
public Params Params { get; set; }
}
public class EstimatedLength
{
[JsonProperty("words")]
public int Words { get; set; }
}
public class Prompt
{
[JsonProperty("prompt")]
public string Content { get; set; }
[JsonProperty("estimatedLength")]
public EstimatedLength EstimatedLength { get; set; }
}
public class Response
{
[JsonProperty("success")]
public bool Success { get; set; }
[JsonProperty("prompt")]
public Prompt Prompt { get; set; }
[JsonProperty("error")]
public string Error { get; set; }
}
public static async Task GeneratePrompt()
{
var payload = new Request
{
Type = "ui",
Params = new Params
{
Category = "dashboard",
Complexity = "high",
ProgrammingLanguage = "react",
Title = "Analytics Dashboard",
Description = "Modern analytics dashboard with charts",
Language = "english"
}
};
var json = JsonConvert.SerializeObject(payload);
var content = new StringContent(json, Encoding.UTF8, "application/json");
try
{
var response = await client.PostAsync($"{BaseUrl}/generate", content);
var responseString = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<Response>(responseString);
if (result.Success)
{
Console.WriteLine($"Generated Prompt: {result.Prompt.Content}");
Console.WriteLine($"Word Count: {result.Prompt.EstimatedLength.Words}");
}
else
{
Console.WriteLine($"Error: {result.Error}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
public static async Task Main(string[] args)
{
await GeneratePrompt();
}
}
๐งช Try It Live
Test the API directly from this page. Generate a prompt and see the response in real-time.