- Version: 1.0
- Date: May 22, 2025
- Project: Ollama Workbench Pipeline Framework
- Base URL:
http://localhost:8001/api/v2
- API Overview
- Authentication
- Pipeline Management API
- Extension API
- Execution API
- WebSocket API
- Error Handling
- SDK Examples
- Protocol: HTTP/1.1, HTTP/2
- Content Type:
application/json - Authentication: JWT Bearer Token
- Rate Limiting: 1000 requests/hour per user
- Versioning: URL path versioning (
/api/v2/)
All API responses follow a consistent format:
{
"success": boolean,
"data": object | array | null,
"message": string,
"timestamp": "ISO 8601 string",
"request_id": "UUID",
"pagination": {
"page": number,
"limit": number,
"total": number,
"has_next": boolean,
"has_prev": boolean
}
}200- Success201- Created400- Bad Request401- Unauthorized403- Forbidden404- Not Found409- Conflict422- Validation Error429- Rate Limited500- Internal Server Error
All API requests require a valid JWT token in the Authorization header:
Authorization: Bearer <jwt_token>{
"sub": "user_id",
"email": "user@example.com",
"role": "admin|developer|user|viewer",
"permissions": ["pipelines.read", "pipelines.write"],
"exp": 1640995200,
"iat": 1640908800
}POST /api/v2/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "secure_password"
}Response:
{
"success": true,
"data": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"expires_in": 3600,
"token_type": "Bearer"
}
}Get a paginated list of pipelines accessible to the current user.
GET /api/v2/pipelines?page=1&limit=20&type=tool&owner=me&search=webQuery Parameters:
page(int, default: 1) - Page numberlimit(int, default: 20, max: 100) - Items per pagetype(string, optional) - Filter by type:tool,function,pipelineowner(string, optional) - Filter by owner:me,public,{user_id}search(string, optional) - Search in name and descriptioncategory(string, optional) - Filter by categorysort(string, default:created_at) - Sort fieldorder(string, default:desc) - Sort order:asc,desc
Response:
{
"success": true,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "web_search_tool",
"description": "Search the web for current information",
"type": "tool",
"category": "search",
"owner": {
"id": "user_id",
"username": "john_doe",
"email": "john@example.com"
},
"is_public": true,
"version": "1.2.0",
"tags": ["web", "search", "api"],
"config": {...},
"stats": {
"downloads": 1250,
"rating": 4.8,
"reviews": 23
},
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-20T14:22:00Z"
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 156,
"has_next": true,
"has_prev": false
}
}Retrieve detailed information about a specific pipeline.
GET /api/v2/pipelines/{pipeline_id}Response:
{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "web_search_tool",
"description": "Search the web for current information using multiple search engines",
"type": "tool",
"category": "search",
"owner": {
"id": "user_id",
"username": "john_doe",
"email": "john@example.com",
"avatar_url": "https://example.com/avatar.jpg"
},
"is_public": true,
"version": "1.2.0",
"tags": ["web", "search", "api"],
"config": {
"schema": {
"type": "function",
"function": {
"name": "web_search",
"description": "Search the web for current information",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Search query"
},
"num_results": {
"type": "integer",
"description": "Number of results to return",
"default": 5,
"minimum": 1,
"maximum": 20
}
},
"required": ["query"]
}
}
},
"implementation": {
"language": "python",
"entry_point": "main.py",
"dependencies": ["requests", "beautifulsoup4"],
"environment": {
"SEARCH_API_KEY": "required"
}
}
},
"stats": {
"downloads": 1250,
"rating": 4.8,
"reviews": 23,
"usage_count": 45230
},
"versions": [
{
"version": "1.2.0",
"created_at": "2025-01-20T14:22:00Z",
"changelog": "Added support for multiple search engines"
},
{
"version": "1.1.0",
"created_at": "2025-01-15T10:30:00Z",
"changelog": "Improved error handling and response formatting"
}
],
"reviews": [
{
"user": "alice_dev",
"rating": 5,
"comment": "Excellent tool, works perfectly with multiple search engines!",
"created_at": "2025-01-18T09:15:00Z"
}
],
"created_at": "2025-01-15T10:30:00Z",
"updated_at": "2025-01-20T14:22:00Z"
}
}Create a new pipeline with the specified configuration.
POST /api/v2/pipelines
Content-Type: application/json
{
"name": "custom_web_search",
"description": "A custom web search tool with enhanced filtering",
"type": "tool",
"category": "search",
"is_public": false,
"tags": ["web", "search", "custom"],
"config": {
"schema": {
"type": "function",
"function": {
"name": "custom_web_search",
"description": "Search the web with custom filters",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Search query"
},
"domain_filter": {
"type": "array",
"items": {"type": "string"},
"description": "Domains to include in search"
}
},
"required": ["query"]
}
}
},
"implementation": {
"language": "python",
"entry_point": "search.py",
"dependencies": ["requests", "urllib3"],
"source_code": "base64_encoded_zip_file"
}
}
}Response:
{
"success": true,
"data": {
"id": "660e8400-e29b-41d4-a716-446655440001",
"name": "custom_web_search",
"version": "1.0.0",
"status": "validating",
"validation_id": "val_123456789"
},
"message": "Pipeline created successfully. Validation in progress."
}Update an existing pipeline configuration.
PUT /api/v2/pipelines/{pipeline_id}
Content-Type: application/json
{
"description": "Updated description with new features",
"tags": ["web", "search", "custom", "enhanced"],
"config": {
// Updated configuration
}
}Delete a pipeline. Only the owner or admin can delete pipelines.
DELETE /api/v2/pipelines/{pipeline_id}Response:
{
"success": true,
"message": "Pipeline deleted successfully"
}Register a new tool extension for function calling.
POST /api/v2/extensions/tools
Content-Type: application/json
{
"name": "database_query",
"description": "Execute SQL queries on connected databases",
"schema": {
"type": "function",
"function": {
"name": "db_query",
"description": "Execute a SQL query",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string"},
"database": {"type": "string", "default": "default"}
},
"required": ["query"]
}
}
},
"implementation": {
"type": "container",
"image": "custom/db-tool:latest",
"resource_limits": {
"memory": "512MB",
"cpu": "0.5"
}
}
}Execute a tool with specified parameters.
POST /api/v2/extensions/tools/{tool_id}/execute
Content-Type: application/json
{
"parameters": {
"query": "SELECT * FROM users WHERE active = true",
"database": "production"
},
"context": {
"conversation_id": "conv_123",
"user_id": "user_456"
}
}Response:
{
"success": true,
"data": {
"execution_id": "exec_789",
"result": {
"status": "completed",
"output": {
"rows": 150,
"data": [...],
"execution_time": "0.045s"
}
},
"metadata": {
"tool_name": "database_query",
"execution_time": 0.045,
"resource_usage": {
"memory": "45MB",
"cpu": "0.1"
}
}
}
}Register a function that modifies request/response behavior.
POST /api/v2/extensions/functions
Content-Type: application/json
{
"name": "content_filter",
"description": "Filter content based on custom rules",
"type": "response_processor",
"config": {
"filter_rules": [
{"type": "regex", "pattern": "\\b(password|secret)\\b", "action": "redact"},
{"type": "sentiment", "threshold": -0.8, "action": "flag"}
],
"processing_order": 10
},
"implementation": {
"type": "inline",
"code": "base64_encoded_python_code"
}
}Functions are automatically applied during request/response processing. Monitor function performance:
GET /api/v2/extensions/functions/{function_id}/statsCreate a multi-step workflow pipeline.
POST /api/v2/extensions/pipelines
Content-Type: application/json
{
"name": "research_workflow",
"description": "Multi-agent research and synthesis pipeline",
"steps": [
{
"id": "search_step",
"type": "tool_call",
"tool": "web_search",
"parameters": {
"query": "${input.topic}",
"num_results": 10
}
},
{
"id": "analyze_step",
"type": "llm_call",
"model": "llama3",
"prompt": "Analyze these search results: ${search_step.output}",
"depends_on": ["search_step"]
},
{
"id": "synthesize_step",
"type": "llm_call",
"model": "claude-3",
"prompt": "Synthesize insights: ${analyze_step.output}",
"depends_on": ["analyze_step"]
}
],
"output_mapping": {
"summary": "${synthesize_step.output}",
"sources": "${search_step.output.sources}"
}
}Execute a pipeline with input parameters.
POST /api/v2/execution/pipelines/{pipeline_id}/execute
Content-Type: application/json
{
"input": {
"topic": "artificial intelligence trends 2025",
"depth": "comprehensive"
},
"options": {
"timeout": 300,
"retry_count": 2,
"async": true
},
"context": {
"conversation_id": "conv_123",
"user_preferences": {
"language": "en",
"detail_level": "high"
}
}
}Response (Async):
{
"success": true,
"data": {
"execution_id": "exec_550e8400",
"status": "running",
"pipeline_id": "pipeline_123",
"started_at": "2025-01-22T15:30:00Z",
"estimated_completion": "2025-01-22T15:35:00Z",
"progress": {
"completed_steps": 1,
"total_steps": 3,
"current_step": "analyze_step"
}
}
}Check the status of a running pipeline execution.
GET /api/v2/execution/{execution_id}Response:
{
"success": true,
"data": {
"execution_id": "exec_550e8400",
"status": "completed",
"pipeline_id": "pipeline_123",
"started_at": "2025-01-22T15:30:00Z",
"completed_at": "2025-01-22T15:34:23Z",
"duration": 263.45,
"progress": {
"completed_steps": 3,
"total_steps": 3,
"current_step": null
},
"result": {
"summary": "AI trends analysis...",
"sources": [...]
},
"step_results": [
{
"step_id": "search_step",
"status": "completed",
"duration": 2.3,
"output": {...}
},
{
"step_id": "analyze_step",
"status": "completed",
"duration": 45.2,
"output": {...}
},
{
"step_id": "synthesize_step",
"status": "completed",
"duration": 215.95,
"output": {...}
}
],
"resource_usage": {
"total_memory": "1.2GB",
"peak_cpu": "2.1",
"network_io": "15MB"
}
}
}Cancel a running pipeline execution.
DELETE /api/v2/execution/{execution_id}Retrieve detailed logs for a pipeline execution.
GET /api/v2/execution/{execution_id}/logs?level=info&step=analyze_stepQuery Parameters:
level(string, optional) - Log level:debug,info,warn,errorstep(string, optional) - Filter logs by step IDstart_time(ISO string, optional) - Start time filterend_time(ISO string, optional) - End time filter
Connect to WebSocket for real-time updates.
const ws = new WebSocket('ws://localhost:8001/ws/execution/{execution_id}?token={jwt_token}');{
"type": "execution_progress",
"data": {
"execution_id": "exec_550e8400",
"progress": {
"completed_steps": 2,
"total_steps": 3,
"current_step": "synthesize_step"
},
"step_status": {
"step_id": "synthesize_step",
"status": "running",
"progress": 0.65
}
}
}{
"type": "step_completed",
"data": {
"execution_id": "exec_550e8400",
"step_id": "analyze_step",
"status": "completed",
"duration": 45.2,
"output_preview": "Analysis completed successfully..."
}
}{
"type": "execution_completed",
"data": {
"execution_id": "exec_550e8400",
"status": "completed",
"duration": 263.45,
"result_summary": "Research workflow completed successfully"
}
}{
"type": "execution_error",
"data": {
"execution_id": "exec_550e8400",
"error": {
"code": "STEP_TIMEOUT",
"message": "Step 'analyze_step' timed out after 60 seconds",
"step_id": "analyze_step",
"recoverable": true
}
}
}{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid pipeline configuration",
"details": {
"field": "config.schema.function.parameters",
"reason": "Missing required property 'type'"
}
},
"timestamp": "2025-01-22T15:30:00Z",
"request_id": "req_550e8400"
}AUTH_TOKEN_MISSING- No authorization token providedAUTH_TOKEN_INVALID- Invalid or expired tokenAUTH_INSUFFICIENT_PERMISSIONS- User lacks required permissions
VALIDATION_ERROR- Request data validation failedSCHEMA_INVALID- Pipeline schema validation failedDEPENDENCY_MISSING- Required dependency not available
EXECUTION_TIMEOUT- Pipeline execution timed outRESOURCE_LIMIT_EXCEEDED- Resource limits exceededSTEP_FAILED- Individual step execution failedCONTAINER_ERROR- Container execution error
RATE_LIMIT_EXCEEDED- API rate limit exceededSERVICE_UNAVAILABLE- Service temporarily unavailableINTERNAL_ERROR- Unexpected system error
pip install ollama-workbench-sdkfrom ollama_workbench import PipelineClient
# Initialize client
client = PipelineClient(
base_url="http://localhost:8001",
token="your_jwt_token"
)
# List pipelines
pipelines = client.pipelines.list(type="tool", limit=10)
# Get pipeline details
pipeline = client.pipelines.get("pipeline_id")
# Execute pipeline
execution = client.execute(
pipeline_id="pipeline_id",
input={"query": "search term"},
async_mode=True
)
# Monitor execution
while execution.status in ["running", "queued"]:
execution.refresh()
print(f"Progress: {execution.progress}")
time.sleep(2)
print(f"Result: {execution.result}")# Create a new tool
tool_config = {
"name": "custom_tool",
"description": "My custom tool",
"schema": {
"type": "function",
"function": {
"name": "custom_function",
"parameters": {
"type": "object",
"properties": {
"input": {"type": "string"}
}
}
}
},
"implementation": {
"type": "container",
"image": "my/custom-tool:latest"
}
}
tool = client.tools.create(tool_config)
# Execute with real-time updates
def on_progress(event):
print(f"Step {event.step_id}: {event.progress}%")
def on_completion(event):
print(f"Completed: {event.result}")
execution = client.execute(
pipeline_id=tool.id,
input={"input": "test data"},
callbacks={
"progress": on_progress,
"completion": on_completion
}
)npm install @ollama-workbench/sdkimport { PipelineClient } from '@ollama-workbench/sdk';
// Initialize client
const client = new PipelineClient({
baseURL: 'http://localhost:8001',
token: 'your_jwt_token'
});
// List pipelines
const pipelines = await client.pipelines.list({
type: 'tool',
limit: 10
});
// Execute pipeline with WebSocket updates
const execution = await client.execute({
pipelineId: 'pipeline_id',
input: { query: 'search term' },
onProgress: (progress) => {
console.log(`Progress: ${progress.percentage}%`);
},
onStepComplete: (step) => {
console.log(`Step ${step.id} completed`);
},
onComplete: (result) => {
console.log('Execution completed:', result);
},
onError: (error) => {
console.error('Execution failed:', error);
}
});# Create pipeline
curl -X POST http://localhost:8001/api/v2/pipelines \
-H "Authorization: Bearer ${JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "test_pipeline",
"type": "tool",
"config": {...}
}'
# Execute pipeline
curl -X POST http://localhost:8001/api/v2/execution/pipelines/pipeline_id/execute \
-H "Authorization: Bearer ${JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"input": {"query": "test"},
"options": {"async": true}
}'
# Check execution status
curl -X GET http://localhost:8001/api/v2/execution/exec_id \
-H "Authorization: Bearer ${JWT_TOKEN}"This API documentation provides comprehensive coverage of the Ollama Workbench Pipeline Framework API, enabling developers to integrate with and extend the platform effectively.