Overview
The Chains API enables complex multi-step LLM workflows where outputs from one prompt feed into subsequent prompts. Design sophisticated reasoning chains, multi-agent collaborations, and iterative refinement processes.
Base URL : https://api.so1.io/v1/veritas/chains
Create Chain
Endpoint
Request Body
Chain purpose and workflow description
Ordered array of chain steps Execution order (1, 2, 3, …)
Prompt to execute in this step
Map previous step outputs to prompt variables
Key name for storing this step’s output
Execute in parallel with other steps at same order
Example Request
curl -X POST https://api.so1.io/v1/veritas/chains \
-H "Authorization: Bearer so1_key_abc123xyz" \
-H "Content-Type: application/json" \
-d '{
"name": "code-generation-chain",
"description": "Analyze requirements, design API, generate implementation, write tests",
"steps": [
{
"order": 1,
"promptId": "requirement-analyzer",
"outputKey": "requirements"
},
{
"order": 2,
"promptId": "api-designer",
"inputMapping": {
"requirements": "step_1.requirements"
},
"outputKey": "api_design"
},
{
"order": 3,
"promptId": "code-generator",
"inputMapping": {
"requirements": "step_1.requirements",
"design": "step_2.api_design"
},
"outputKey": "implementation"
},
{
"order": 4,
"promptId": "test-generator",
"inputMapping": {
"code": "step_3.implementation"
},
"outputKey": "tests"
}
]
}'
Response
{
"success" : true ,
"data" : {
"chainId" : "code-generation-chain" ,
"version" : 1 ,
"stepsCount" : 4 ,
"createdAt" : "2024-03-10T15:30:00Z"
}
}
Execute Chain
Run a chain with initial input variables.
Endpoint
POST /v1/veritas/chains/{chainId}/execute
Request Body
Variables for the first step’s prompt
model
string
default: "claude-sonnet-4"
LLM model for all steps
Example Request
curl -X POST https://api.so1.io/v1/veritas/chains/code-generation-chain/execute \
-H "Authorization: Bearer so1_key_abc123xyz" \
-H "Content-Type: application/json" \
-d '{
"initialVariables": {
"feature_description": "User authentication with JWT tokens, including login, register, and token refresh endpoints"
},
"model": "claude-sonnet-4",
"temperature": 0.7
}'
Response
{
"success" : true ,
"data" : {
"executionId" : "exec-xyz789" ,
"chainId" : "code-generation-chain" ,
"status" : "running" ,
"currentStep" : 1 ,
"totalSteps" : 4 ,
"startedAt" : "2024-03-10T15:30:00Z"
}
}
Get Chain Execution Status
Endpoint
GET /v1/veritas/chains/executions/{executionId}
Response (Running)
{
"success" : true ,
"data" : {
"executionId" : "exec-xyz789" ,
"chainId" : "code-generation-chain" ,
"status" : "running" ,
"currentStep" : 2 ,
"totalSteps" : 4 ,
"completedSteps" : [
{
"step" : 1 ,
"promptId" : "requirement-analyzer" ,
"output" : "Analyzed requirements..." ,
"tokensUsed" : 234 ,
"latency" : 1.8 ,
"completedAt" : "2024-03-10T15:30:02Z"
}
],
"startedAt" : "2024-03-10T15:30:00Z"
}
}
Response (Completed)
{
"success" : true ,
"data" : {
"executionId" : "exec-xyz789" ,
"chainId" : "code-generation-chain" ,
"status" : "completed" ,
"result" : {
"step_1" : {
"requirements" : "User authentication system with JWT..."
},
"step_2" : {
"api_design" : "POST /auth/login \n POST /auth/register..."
},
"step_3" : {
"implementation" : "import { Hono } from 'hono'..."
},
"step_4" : {
"tests" : "describe('Auth API', () => {..."
}
},
"totalTokens" : 3421 ,
"totalLatency" : 12.4 ,
"startedAt" : "2024-03-10T15:30:00Z" ,
"completedAt" : "2024-03-10T15:30:12.4Z"
}
}
Get Chain
Endpoint
GET /v1/veritas/chains/{chainId}
Response
{
"success" : true ,
"data" : {
"chainId" : "code-generation-chain" ,
"name" : "Code Generation Chain" ,
"description" : "Analyze requirements, design API, generate implementation" ,
"version" : 1 ,
"steps" : [
{
"order" : 1 ,
"promptId" : "requirement-analyzer" ,
"outputKey" : "requirements"
},
{
"order" : 2 ,
"promptId" : "api-designer" ,
"inputMapping" : { "requirements" : "step_1.requirements" },
"outputKey" : "api_design"
}
// ... more steps
],
"performance" : {
"totalExecutions" : 23 ,
"averageTokens" : 3421 ,
"averageLatency" : 12.4 ,
"successRate" : 95.7
},
"createdAt" : "2024-03-10T15:30:00Z"
}
}
List Chains
Endpoint
Query Parameters
Response
{
"success" : true ,
"data" : {
"chains" : [
{
"chainId" : "code-generation-chain" ,
"name" : "Code Generation Chain" ,
"stepsCount" : 4 ,
"executions" : 23 ,
"successRate" : 95.7
}
// ... more chains
],
"pagination" : {
"total" : 47 ,
"limit" : 20 ,
"hasMore" : true
}
}
}
Update Chain
Endpoint
PUT /v1/veritas/chains/{chainId}
Request Body
Create new version vs. update current
Response
{
"success" : true ,
"data" : {
"chainId" : "code-generation-chain" ,
"version" : 2 ,
"updatedAt" : "2024-03-10T16:00:00Z"
}
}
Delete Chain
Endpoint
DELETE /v1/veritas/chains/{chainId}
Response
{
"success" : true ,
"data" : {
"chainId" : "code-generation-chain" ,
"deletedAt" : "2024-03-10T16:00:00Z"
}
}
Common Patterns
Parallel Step Execution
const chain = {
name: 'parallel-analysis-chain' ,
steps: [
{
order: 1 ,
promptId: 'extract-requirements' ,
outputKey: 'requirements'
},
// Steps 2 and 3 run in parallel
{
order: 2 ,
promptId: 'backend-analysis' ,
inputMapping: { requirements: 'step_1.requirements' },
outputKey: 'backend_plan' ,
parallel: true
},
{
order: 2 , // Same order = parallel execution
promptId: 'frontend-analysis' ,
inputMapping: { requirements: 'step_1.requirements' },
outputKey: 'frontend_plan' ,
parallel: true
},
// Step 4 waits for both 2 and 3
{
order: 3 ,
promptId: 'integration-plan' ,
inputMapping: {
backend: 'step_2.backend_plan' ,
frontend: 'step_3.frontend_plan'
},
outputKey: 'integration'
}
]
};
Iterative Refinement Chain
const refinementChain = {
name: 'iterative-code-refinement' ,
steps: [
{ order: 1 , promptId: 'generate-initial-code' , outputKey: 'code_v1' },
{ order: 2 , promptId: 'review-code' , inputMapping: { code: 'step_1.code_v1' }, outputKey: 'review' },
{ order: 3 , promptId: 'refine-code' , inputMapping: { code: 'step_1.code_v1' , feedback: 'step_2.review' }, outputKey: 'code_v2' },
{ order: 4 , promptId: 'final-review' , inputMapping: { code: 'step_3.code_v2' }, outputKey: 'final_review' }
]
};