API Documentation

PromptFoldingAI™ API

Integrate our revolutionary prompt optimization protocol into your applications with our comprehensive REST API.

API Overview

The PromptFoldingAI™ API provides programmatic access to our prompt optimization technology. Our RESTful API is designed for easy integration with any programming language or framework.

RESTful API design
JSON request/response format
Rate limiting and authentication
Comprehensive error handling

Base URL

https://api.promptfolding.ai/v2.1

Authentication

All API requests require an API key in the header:

Authorization: Bearer YOUR_API_KEY

API Endpoints

Fold Prompt

POST

Optimize a prompt using our folding algorithm to reduce token usage while maintaining quality.

Endpoint

/fold

Example Request

curl -X POST https://api.promptfolding.ai/v2.1/fold \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Write a detailed analysis of the impact of artificial intelligence on modern healthcare systems, including both benefits and potential risks.",
    "model": "gpt-4",
    "context": "healthcare_analysis"
  }'

Example Response

{
  "success": true,
  "data": {
    "original_prompt": "Write a detailed analysis...",
    "folded_prompt": "Analyze AI's healthcare impact: benefits and risks.",
    "token_reduction": 43,
    "quality_score": 0.92,
    "processing_time": 0.15
  }
}

Batch Fold

POST

Optimize multiple prompts in a single request for improved efficiency.

Endpoint

/batch-fold

Example Request

curl -X POST https://api.promptfolding.ai/v2.1/batch-fold \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompts": [
      "Explain quantum computing in simple terms",
      "Write a professional email template",
      "Create a project timeline"
    ],
    "model": "gpt-4"
  }'

Analyze Prompt

GET

Get detailed analysis of a prompt including token count, complexity, and optimization suggestions.

Endpoint

/analyze

Example Request

curl -X GET "https://api.promptfolding.ai/v2.1/analyze?prompt=Your%20prompt%20here" \
  -H "Authorization: Bearer YOUR_API_KEY"

SDKs & Libraries

Py

Python SDK

Official Python client library for easy integration with your Python applications.

import { PromptFoldingAI } from '@prompt-folding-ai/core';

client = new PromptFoldingAI('YOUR_API_KEY');
result = client.fold_prompt("Your prompt here")
JS

JavaScript SDK

Node.js and browser-compatible JavaScript library for web applications.

import { PromptFoldingAI } from '@prompt-folding-ai/core';

const client = new PromptFoldingAI('YOUR_API_KEY');
const result = await client.foldPrompt("Your prompt here");
API

REST API

Language-agnostic REST API for integration with any platform or framework.

curl -X POST https://api.promptfolding.ai/v2.1/fold \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"prompt": "Your prompt"}'

Rate Limits

100

Free Tier

100 requests per hour

1K

Pro Tier

1,000 requests per hour

10K

Enterprise

10,000+ requests per hour

Ready to Get Started?

Join thousands of developers already using PromptFoldingAI™ to build better AI applications.

Get Early Access
View Documentation
Contact Us