{
  "openapi":"3.1.0",
  "info":{"title":"RelayMe AI Tools API","version":"1.2.0","description":"Agent-native API for text, creative generation, asynchronous tasks, and durable workflow execution."},
  "servers":[{"url":"/"}],
  "security":[{"bearerAuth":[]}],
  "paths":{
    "/api/ai-tools/v1/skills":{"get":{"security":[],"operationId":"listAgentSkills","summary":"List installable Agent Skills","responses":{"200":{"description":"Skill catalog"}}}},
    "/api/ai-tools/v1/skills.zip":{"get":{"security":[],"operationId":"downloadAgentSkillSuite","summary":"Download all RelayMe Agent Skills","responses":{"200":{"description":"Skill suite ZIP archive","content":{"application/zip":{"schema":{"type":"string","contentEncoding":"binary"}}}}}}},
    "/api/ai-tools/v1/skills/relayme-workflows":{"get":{"security":[],"operationId":"getRelayMeWorkflowSkill","summary":"Get RelayMe workflow Skill manifest","responses":{"200":{"description":"Skill manifest"}}}},
    "/api/ai-tools/v1/skills/relayme-workflows.zip":{"get":{"security":[],"operationId":"downloadRelayMeWorkflowSkill","summary":"Download the installable RelayMe workflow Skill","responses":{"200":{"description":"Skill ZIP archive","content":{"application/zip":{"schema":{"type":"string","contentEncoding":"binary"}}}}}}},
    "/api/ai-tools/v1/models":{"get":{"operationId":"listModels","summary":"List enabled RelayMe models and their capabilities","responses":{"200":{"description":"Model catalog"}}}},
    "/api/ai-tools/v1/chat/completions":{"post":{"operationId":"createChatCompletion","summary":"Generate a synchronous text response","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"200":{"description":"Text completion"},"400":{"$ref":"#/components/responses/AgentError"}}}},
    "/api/ai-tools/v1/images/generations":{"post":{"operationId":"generateImage","summary":"Submit an asynchronous image generation task","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreativeRequest"}}}},"responses":{"200":{"description":"Task accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskAccepted"}}}}}}},
    "/api/ai-tools/v1/videos/generations":{"post":{"operationId":"generateVideo","summary":"Submit an asynchronous video generation task","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreativeRequest"}}}},"responses":{"200":{"description":"Task accepted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskAccepted"}}}}}}},
    "/api/ai-tools/v1/tasks":{"get":{"operationId":"listTasks","summary":"List recent asynchronous creative tasks","parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"Paginated task history"}}}},
    "/api/ai-tools/v1/tasks/{taskId}":{"parameters":[{"$ref":"#/components/parameters/TaskId"}],"get":{"operationId":"getTask","summary":"Get creative task status and result","responses":{"200":{"description":"Task status"},"404":{"$ref":"#/components/responses/AgentError"}}}},
    "/api/ai-tools/v1/workflows":{"get":{"operationId":"listWorkflows","summary":"List workflows","responses":{"200":{"description":"Workflow list"}}},"post":{"operationId":"createWorkflow","summary":"Create workflow","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkflowWrite"}}}},"responses":{"200":{"description":"Created"},"422":{"$ref":"#/components/responses/AgentError"}}}},
    "/api/ai-tools/v1/workflows/validate":{"post":{"operationId":"validateWorkflow","summary":"Validate a workflow graph before saving","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object"}}}}}},"responses":{"200":{"description":"Validation result"}}}},
    "/api/ai-tools/v1/workflows/{workflowId}":{"parameters":[{"$ref":"#/components/parameters/WorkflowId"}],"get":{"operationId":"getWorkflow","responses":{"200":{"description":"Workflow"},"404":{"$ref":"#/components/responses/AgentError"}}},"put":{"operationId":"updateWorkflow","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkflowWrite"}}}},"responses":{"200":{"description":"Updated"}}},"delete":{"operationId":"deleteWorkflow","responses":{"200":{"description":"Deleted"}}}},
    "/api/ai-tools/v1/workflows/{workflowId}/schema":{"parameters":[{"$ref":"#/components/parameters/WorkflowId"}],"get":{"operationId":"getWorkflowSchema","summary":"Get generated JSON input and output schemas","responses":{"200":{"description":"Schemas"},"422":{"$ref":"#/components/responses/AgentError"}}}},
    "/api/ai-tools/v1/workflows/{workflowId}/estimate":{"parameters":[{"$ref":"#/components/parameters/WorkflowId"}],"post":{"operationId":"estimateWorkflow","summary":"Estimate workflow cost without executing providers","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunInput"}}}},"responses":{"200":{"description":"Cost estimate"},"422":{"$ref":"#/components/responses/AgentError"}}}},
    "/api/ai-tools/v1/workflows/{workflowId}/runs":{"parameters":[{"$ref":"#/components/parameters/WorkflowId"}],"post":{"operationId":"runWorkflow","summary":"Start an asynchronous workflow run","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","maxLength":128}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RunInput"}}}},"responses":{"202":{"description":"Queued","headers":{"Location":{"schema":{"type":"string"}},"Retry-After":{"schema":{"type":"integer"}}}},"409":{"$ref":"#/components/responses/AgentError"}}},"get":{"operationId":"listWorkflowRuns","responses":{"200":{"description":"Run history"}}}},
    "/api/ai-tools/v1/workflow-runs/{runId}":{"parameters":[{"$ref":"#/components/parameters/RunId"}],"get":{"operationId":"getWorkflowRun","summary":"Poll workflow status","responses":{"200":{"description":"Run state","headers":{"Retry-After":{"schema":{"type":"integer"}}}},"404":{"$ref":"#/components/responses/AgentError"}}}},
    "/api/ai-tools/v1/workflow-runs/{runId}/cancel":{"parameters":[{"$ref":"#/components/parameters/RunId"}],"post":{"operationId":"cancelWorkflowRun","summary":"Request cooperative cancellation","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":500}}}}}},"responses":{"200":{"description":"Cancellation state"},"404":{"$ref":"#/components/responses/AgentError"}}}}
  },
  "components":{
    "securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"JWT or RelayMe API key (sk_...)"}},
    "parameters":{"WorkflowId":{"name":"workflowId","in":"path","required":true,"schema":{"type":"integer","minimum":1}},"RunId":{"name":"runId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},"TaskId":{"name":"taskId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}},
    "schemas":{
      "ChatMessage":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant"]},"content":{}},"additionalProperties":false},
      "ChatRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string"},"messages":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/ChatMessage"}},"systemPrompt":{"type":"string"},"temperature":{"type":"number"},"maxTokens":{"type":"integer","minimum":1}},"additionalProperties":false},
      "CreativeRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string"},"messages":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/ChatMessage"}},"imageAspectRatio":{"type":"string"},"imageQuality":{"type":"string"},"imageSampleSize":{"type":"string"},"videoAspectRatio":{"type":"string"},"videoSeconds":{"type":"integer","minimum":1},"videoResolution":{"type":"string"},"videoGenerateAudio":{"type":"boolean"}},"additionalProperties":true},
      "TaskAccepted":{"type":"object","required":["taskId"],"properties":{"taskId":{"type":"string","format":"uuid"}}},
      "WorkflowWrite":{"type":"object","required":["name","data"],"properties":{"name":{"type":"string"},"data":{"type":"object","required":["nodes","connections"],"properties":{"nodes":{"type":"array","maxItems":200,"items":{"type":"object"}},"connections":{"type":"array","maxItems":1000,"items":{"type":"object"}}}}}},
      "RunInput":{"type":"object","properties":{"inputs":{"type":"object","additionalProperties":true},"callbackUrl":{"type":"string","format":"uri","description":"Public HTTP(S) endpoint; private and metadata addresses are rejected."},"metadata":{"type":"object","maxProperties":100},"idempotencyKey":{"type":"string","maxLength":128}}},
      "AgentError":{"type":"object","required":["success","error"],"properties":{"success":{"const":false},"error":{"type":"object","required":["code","message","retryable"],"properties":{"code":{"type":"string"},"message":{"type":"string"},"retryable":{"type":"boolean"},"details":{}}}}}
    },
    "responses":{"AgentError":{"description":"Machine-readable Agent error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentError"}}}}}
  }
}