To run a pipeline programmatically, you must first generate an API key.
Each pipeline will have it's own endpoint URL. /api/v1/run/{pipelineId}
curl -X POST \
'https://toolpipeline.com/api/v1/run/{pipelineId}' \
-H 'Authorization: Bearer {your_api_key}' \
-H 'Content-Type: application/json' \
-d '{
"input": "Your initial text here"
}
const pipelineId = 'your-pipeline-id';
const apiKey = 'your-api-key';
const initialInput = 'Your initial text here';
fetch('https://toolpipeline.com/api/v1/run/\${pipelineId}', {
method: 'POST',
headers: {
'Authorization': 'Bearer \${apiKey}',
'Content-Type': 'application/json'
},
body: JSON.stringify({input: initialInput})
})
.then(response => response.json())
.then(data => {
console.log('Pipeline Output:', data.output);
})
.catch(error => {
console.error('Error:', error);
});
import requests
import json
pipeline_id = "your-pipeline-id"
api_key = "your-api-key"
initial_input = "Your initial text here"
url = f"https://toolpipeline.com/api/v1/run/{pipeline_id}"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {
"input": initial_input
}
try:
response = requests.post(url, headers=headers, data=json.dumps(data))
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
output = response.json()
print("Pipeline Output:", output.get("output"))
except requests.exceptions.RequestException as e:
print(f"Error making request: {e}")
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
pipelineId := "your-pipeline-id"
apiKey := "your-api-key"
initialInput := "Your initial text here"
url := fmt.Sprintf("https://toolpipeline.com/api/v1/run/%s", pipelineId)
// Create JSON payload
payload := map[string]string{"input": initialInput}
jsonPayload, err := json.Marshal(payload)
if err != nil {
fmt.Println("Error marshalling JSON:", err)
return
}
// Create HTTP request
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Set headers
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
// Execute request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error executing request:", err)
return
}
defer resp.Body.Close()
// Check response status
if resp.StatusCode != http.StatusOK {
fmt.Printf("API returned non-200 status: %d\\n", resp.StatusCode)
return
}
// Read and decode response body
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
var result map[string]interface{}
err = json.Unmarshal(body, &result)
if err != nil {
fmt.Println("Error unmarshalling response body:", err)
return
}
// Print output
fmt.Println("Pipeline Output:", result["output"])
}