- A pattern for AI APIs with 5 basic endpoints
- Regular HTTP/HTTPS requests with JSON data
- A standard way to talk to any AI service
- Based on REST: GET and POST what you need
- A framework or library you install
- A new technology or language
- A specific company's product
- An additional abstraction in any way
π‘ SLOP simply says: "AI services should work through plain web requests using patterns we've used for decades."
That's it. Just a pattern. β¨
- Everything is an HTTP request
- Every tool is an API endpoint
- Every AI is accessible
- Every developer is welcome
POST /chat
// Talk to AIPOST /tools
// Use toolsPOST /memory
// Remember stuffGET /resources
// Get knowledge/files/dataPOST /pay
// Handle money (optional)
- WebSocket for real-time
- SSE for streaming
- HTTP for everything else
- Free to use
- Open source
- No vendor lock
- Community driven
- REST based
- JSON only
- Standard HTTP
- Zero dependencies
- Any AI model
- Any tool
- Any platform
POST /chat
- Send messages to AIGET /chat/:id
- Get a specific chatGET /chat
- List recent chats
GET /tools
- List available toolsPOST /tools/:tool_id
- Use a specific toolGET /tools/:tool_id
- Get tool details
POST /memory
- Store a key-value pairGET /memory/:key
- Get value by keyGET /memory
- List all keysPUT /memory/:key
- Update existing valueDELETE /memory/:key
- Delete a key-value pairPOST /memory/query
- Search with semantic query
GET /resources
- List available resourcesGET /resources/:id
- Get a specific resourceGET /resources/search?q=query
- Search resources
POST /pay
- Create a paymentGET /pay/:id
- Get payment status
// REQUEST
POST /chat
{
"messages": [
{"role": "user", "content": "Hello, what's the weather like?"}
],
"model": "any-model-id"
}
// RESPONSE
{
"id": "chat_123",
"message": {
"role": "assistant",
"content": "I don't have real-time weather data. You could check a weather service for current conditions."
}
}
// REQUEST
GET /chat/chat_123
// RESPONSE
{
"id": "chat_123",
"messages": [
{"role": "user", "content": "Hello, what's the weather like?"},
{"role": "assistant", "content": "I don't have real-time weather data. You could check a weather service for current conditions."}
],
"model": "any-model-id",
"created_at": "2023-05-15T10:30:00Z"
}
// REQUEST
GET /chat
// RESPONSE
{
"chats": [
{
"id": "chat_123",
"snippet": "Hello, what's the weather like?",
"created_at": "2023-05-15T10:30:00Z"
},
{
"id": "chat_456",
"snippet": "Tell me about Mars",
"created_at": "2023-05-14T14:20:00Z"
}
]
}
// REQUEST
GET /tools
// RESPONSE
{
"tools": [
{
"id": "calculator",
"description": "Performs mathematical calculations",
"parameters": {
"expression": "string"
}
},
{
"id": "weather",
"description": "Gets current weather",
"parameters": {
"location": "string"
}
}
]
}
// REQUEST
POST /tools/calculator
{
"expression": "15 * 7"
}
// RESPONSE
{
"result": 105
}
// REQUEST
GET /tools/calculator
// RESPONSE
{
"id": "calculator",
"description": "Performs mathematical calculations",
"parameters": {
"expression": {
"type": "string",
"description": "Mathematical expression to evaluate"
}
},
"example": "15 * 7"
}
// REQUEST
POST /memory
{
"key": "user_preference",
"value": {
"theme": "dark",
"language": "en"
}
}
// RESPONSE
{
"status": "stored"
}
// REQUEST
GET /memory/user_preference
// RESPONSE
{
"key": "user_preference",
"value": {
"theme": "dark",
"language": "en"
},
"created_at": "2023-05-15T10:30:00Z"
}
// REQUEST
GET /memory
// RESPONSE
{
"keys": [
{
"key": "user_preference",
"created_at": "2023-05-15T10:30:00Z"
},
{
"key": "search_history",
"created_at": "2023-05-14T14:20:00Z"
}
]
}
// REQUEST
PUT /memory/user_preference
{
"value": {
"theme": "light",
"language": "en"
}
}
// RESPONSE
{
"status": "updated",
"previous_value": {
"theme": "dark",
"language": "en"
}
}
// REQUEST
DELETE /memory/user_preference
// RESPONSE
{
"status": "deleted"
}
// REQUEST
POST /memory/query
{
"query": "What theme settings do I have?",
"limit": 1
}
// RESPONSE
{
"results": [
{
"key": "user_preference",
"value": {
"theme": "dark",
"language": "en"
},
"score": 0.92
}
]
}
// REQUEST
GET /resources
// RESPONSE
{
"resources": [
{
"id": "mars-101",
"title": "Mars: The Red Planet",
"type": "article"
},
{
"id": "document-123",
"name": "project_plan.pdf",
"type": "file"
}
]
}
// REQUEST
GET /resources/mars-101
// RESPONSE
{
"id": "mars-101",
"title": "Mars: The Red Planet",
"type": "article",
"content": "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System...",
"metadata": {
"source": "astronomy-db",
"last_updated": "2023-05-10"
}
}
// REQUEST
GET /resources/search?q=mars
// RESPONSE
{
"results": [
{
"id": "mars-101",
"title": "Mars: The Red Planet",
"type": "article",
"score": 0.98
},
{
"id": "solar-system",
"title": "Our Solar System",
"type": "article",
"score": 0.75
}
]
}
// REQUEST
POST /pay
{
"amount": 5.00,
"currency": "USD",
"description": "API usage - 1000 tokens",
"payment_method": "card_token_123"
}
// RESPONSE
{
"transaction_id": "tx_987654",
"status": "success",
"receipt_url": "https://api.example.com/receipts/tx_987654"
}
// REQUEST
GET /pay/tx_987654
// RESPONSE
{
"transaction_id": "tx_987654",
"amount": 5.00,
"currency": "USD",
"description": "API usage - 1000 tokens",
"status": "success",
"created_at": "2023-05-15T10:30:00Z",
"receipt_url": "https://api.example.com/receipts/tx_987654"
}
Authentication in SLOP uses standard HTTP headers. Here are examples in both JavaScript and Python:
// Using fetch
const callSlop = async (endpoint, data) => {
const response = await fetch(`https://api.example.com${endpoint}`, {
method: 'POST',
headers: {
'Authorization': 'Bearer your-token-here',
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
return response.json();
};
// Using axios
const axios = require('axios');
const api = axios.create({
baseURL: 'https://api.example.com',
headers: {
'Authorization': 'Bearer your-token-here'
}
});
// Make authenticated requests
await api.post('/chat', {
messages: [{ content: 'Hello!' }]
});
import requests
# Using requests
headers = {
'Authorization': 'Bearer your-token-here',
'Content-Type': 'application/json'
}
# Function to make authenticated requests
def call_slop(endpoint, data=None):
base_url = 'https://api.example.com'
method = 'GET' if data is None else 'POST'
response = requests.request(
method=method,
url=f'{base_url}{endpoint}',
headers=headers,
json=data
)
return response.json()
# Make authenticated requests
chat_response = call_slop('/chat', {
'messages': [{'content': 'Hello!'}]
})
Remember: SLOP uses standard HTTP auth - no special endpoints needed! π
SLOP uses standard HTTP headers to control AI safety and permissions:
X-SLOP-Scope: chat.read,tools.calculator,memory.user.read
chat.read # Read chat history chat.write # Send messages tools.* # Access all tools tools.safe.* # Access only safe tools memory.user.* # Full user memory access memory..read # Read-only memory access
# Safe: Calculator within scope
POST /tools/calculator
X-SLOP-Scope: tools.calculator.execute
{
"expression": "2 + 2"
}
# Blocked: No execute permission
POST /tools/system-cmd
X-SLOP-Scope: tools.calculator.execute
{
"cmd": "rm -rf /"
}
// RESPONSE
{
"error": "Scope violation: tools.execute-code requires explicit permission",
"permitted": false
}
Remember: Security through simplicity! π
Let's collab! SLOP Discord: https://discord.com/invite/nwXJMnHmXP
π Enjoy using SLOP! π