Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/anil-matcha/open-generative-ai/llms.txt

Use this file to discover all available pages before exploring further.

Workflows let you chain multiple AI models into automated, multi-step pipelines — connecting image generators, video models, audio tools, and more into a single reusable flow. Every workflow you build in the visual Workflow Studio can also be executed via the API, which means you can trigger complete pipelines from your own application code without any UI interaction. The functions documented here are exported from packages/studio/src/muapi.js and cover the full lifecycle: listing, creating, managing, inspecting, and running both workflows and agents.

Workflow Management

These functions let you list, create, rename, and delete workflow definitions. All calls authenticate via the x-api-key header using your Muapi.ai API key.

getTemplateWorkflows(apiKey)

Fetch the curated library of pre-built workflow templates. Templates are a good starting point — fork one and modify it rather than building from scratch.
import { getTemplateWorkflows } from 'studio';

const templates = await getTemplateWorkflows('your-api-key');
console.log(templates);
// [{ id: 'tpl_xyz', name: 'Text → Image → Video Pipeline', ... }]
apiKey
string
required
Your Muapi.ai API key. Obtain one at muapi.ai/access-keys.
Returns: Promise<Array> — an array of template workflow objects.

getUserWorkflows(apiKey)

Retrieve all workflows saved to your account. The returned id field is the workflowId used in every other workflow call.
import { getUserWorkflows } from 'studio';

const workflows = await getUserWorkflows('your-api-key');
console.log(workflows);
// [{ id: 'wf_abc123', name: 'My Image Pipeline', ... }]
apiKey
string
required
Your Muapi.ai API key.
Returns: Promise<Array> — an array of workflow definition objects belonging to the authenticated user.

getPublishedWorkflows(apiKey)

Fetch community-published workflows shared by other Muapi.ai users. Published workflows can be executed directly using executeWorkflow.
import { getPublishedWorkflows } from 'studio';

const community = await getPublishedWorkflows('your-api-key');
console.log(community);
// [{ id: 'pub_def456', name: 'Anime Portrait Generator', author: '...', ... }]
apiKey
string
required
Your Muapi.ai API key.
Returns: Promise<Array> — an array of publicly published workflow objects.

createWorkflow(apiKey, payload)

Create a new workflow definition under your account. The payload describes the workflow structure — you can start with a template definition or build one from scratch using the node schema.
import { createWorkflow } from 'studio';

const workflow = await createWorkflow('your-api-key', {
  name: 'My New Pipeline',
  nodes: [ /* node definitions */ ],
  edges: [ /* connections between nodes */ ]
});
console.log(workflow.id); // 'wf_new789'
apiKey
string
required
Your Muapi.ai API key.
payload
object
required
The workflow definition object sent as the request body.
payload.name
string
required
Display name for the new workflow.
payload.nodes
array
Array of node definition objects describing each step in the pipeline.
payload.edges
array
Array of edge objects connecting node outputs to node inputs.
Returns: Promise<object> — the created workflow object, including the new id.

updateWorkflowName(apiKey, workflowId, name)

Rename an existing workflow. This is a lightweight POST to /workflow/update-name/{workflowId} and does not change the workflow structure.
import { updateWorkflowName } from 'studio';

await updateWorkflowName('your-api-key', 'wf_abc123', 'Refined Image Pipeline v2');
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The ID of the workflow to rename (from getUserWorkflows).
name
string
required
The new display name for the workflow.
Returns: Promise<object> — the updated workflow object.

deleteWorkflow(apiKey, workflowId)

Permanently delete a workflow definition. This action cannot be undone.
import { deleteWorkflow } from 'studio';

await deleteWorkflow('your-api-key', 'wf_abc123');
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The ID of the workflow to delete.
Deleting a workflow is permanent. Any application code that calls executeWorkflow with this ID will start receiving errors immediately.
Returns: Promise<object> — a confirmation response from the API.

getWorkflowInputs(apiKey, workflowId)

Fetch the input schema for a specific workflow. Use this before calling executeWorkflow to discover which keys the inputs object must contain and what types are expected.
import { getWorkflowInputs } from 'studio';

const schema = await getWorkflowInputs('your-api-key', 'wf_abc123');
console.log(schema);
// { prompt: { type: 'string', required: true }, style: { type: 'string', default: 'realistic' } }
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The workflow whose input schema you want to inspect.
Returns: Promise<object> — a schema object mapping input field names to their type definitions and constraints.

getWorkflowData(apiKey, workflowId)

Retrieve the complete workflow definition, including all node configurations and edge connections. Useful for inspecting or cloning an existing workflow.
import { getWorkflowData } from 'studio';

const definition = await getWorkflowData('your-api-key', 'wf_abc123');
console.log(definition.nodes); // full node array
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The workflow to inspect.
Returns: Promise<object> — the full workflow definition object.

getAllNodeSchemas(apiKey, workflowId)

Get the schemas for every node in a workflow, including internal node types. This is the lower-level counterpart to getNodeSchemas — it returns the full set of node schemas without filtering to API-exposed ones only.
import { getAllNodeSchemas } from 'studio';

const schemas = await getAllNodeSchemas('your-api-key', 'wf_abc123');
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The workflow to inspect.
Returns: Promise<object> — all node schemas in the workflow.

getNodeSchemas(apiKey, workflowId)

Get only the API-exposed node schemas for a workflow. These are the nodes that can be targeted individually via runSingleNode. The endpoint is /workflow/{workflowId}/api-node-schemas.
import { getNodeSchemas } from 'studio';

const schemas = await getNodeSchemas('your-api-key', 'wf_abc123');
console.log(Object.keys(schemas)); // ['node_generate_image', 'node_upscale', ...]
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The workflow to inspect.
Returns: Promise<object> — a map of API-accessible node IDs to their input/output schemas.

Execute a Workflow

executeWorkflow(apiKey, workflowId, inputs)

Run a complete workflow end-to-end. The function posts the inputs to /workflow/{workflowId}/api-execute, receives a run_id, then automatically polls /workflow/run/{run_id}/api-outputs every two seconds until the status is completed, succeeded, or success. The maximum polling window is 30 minutes (900 attempts × 2 s).
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The ID of the workflow to execute. Obtain this from getUserWorkflows or getTemplateWorkflows.
inputs
object
required
Key-value pairs matching the workflow’s input schema. Call getWorkflowInputs first to discover the required keys and their types.
Returns: Promise<object> — resolves to the completed workflow run result when execution finishes. Rejects with an error if the workflow fails or times out.
Always call getWorkflowInputs first so you know exactly which keys to pass. Sending an incorrect input shape is the most common cause of a failed workflow run.
Example — discover inputs, then execute:
import { getUserWorkflows, getWorkflowInputs, executeWorkflow } from 'studio';

// Step 1: list your saved workflows
const workflows = await getUserWorkflows('your-api-key');
console.log(workflows);
// [{ id: 'wf_abc123', name: 'My Image Pipeline', ... }]

// Step 2: inspect the input schema before executing
const schema = await getWorkflowInputs('your-api-key', 'wf_abc123');
console.log(schema);
// { prompt: { type: 'string', required: true }, ... }

// Step 3: execute with the correct inputs
const result = await executeWorkflow('your-api-key', 'wf_abc123', {
  prompt: 'a futuristic city at night'
});
console.log(result);

Node Execution

These functions let you run a single node in isolation or monitor and cancel an in-progress node run.

runSingleNode(apiKey, workflowId, nodeId, payload)

Execute a single node within a workflow without running the entire pipeline. The node ID must correspond to an API-exposed node from getNodeSchemas.
import { runSingleNode } from 'studio';

const run = await runSingleNode(
  'your-api-key',
  'wf_abc123',
  'node_generate_image',
  { prompt: 'a sunset over the ocean' }
);
console.log(run.run_id); // use this to poll status or cancel
apiKey
string
required
Your Muapi.ai API key.
workflowId
string
required
The workflow that contains the node.
nodeId
string
required
The ID of the node to run (from getNodeSchemas).
payload
object
required
Input values for the node, matching the node’s input schema.
Returns: Promise<object> — a run object including a run_id for status polling.

deleteNodeRun(apiKey, nodeRunId)

Cancel an in-progress node run. Issues a DELETE to /workflow/node-run/{nodeRunId}.
import { deleteNodeRun } from 'studio';

await deleteNodeRun('your-api-key', 'nr_run789');
apiKey
string
required
Your Muapi.ai API key.
nodeRunId
string
required
The run_id returned by runSingleNode.
Returns: Promise<object> — a confirmation response from the API.

getNodeStatus(apiKey, runId)

Poll the current status of a running or completed node. The endpoint is /workflow/run/{runId}/status.
import { getNodeStatus } from 'studio';

const status = await getNodeStatus('your-api-key', 'nr_run789');
console.log(status.status); // 'running' | 'completed' | 'failed'
apiKey
string
required
Your Muapi.ai API key.
runId
string
required
The run ID to check.
Returns: Promise<object> — a status object including a status field and any available output data.

Agents

Agents are conversational AI assistants that can be configured with specific capabilities and context. The agent functions mirror the workflow listing pattern.

getTemplateAgents(apiKey)

Fetch the library of pre-built agent templates from /agents/templates/agents.
import { getTemplateAgents } from 'studio';

const templates = await getTemplateAgents('your-api-key');
apiKey
string
required
Your Muapi.ai API key.
Returns: Promise<Array> — an array of agent template objects.

getUserAgents(apiKey)

Retrieve agents saved to the authenticated user’s account from /agents/user/agents.
import { getUserAgents } from 'studio';

const agents = await getUserAgents('your-api-key');
apiKey
string
required
Your Muapi.ai API key.
Returns: Promise<Array> — an array of the user’s agent objects.

getPublishedAgents(apiKey)

Fetch featured community agents from /agents/featured/agents.
import { getPublishedAgents } from 'studio';

const featured = await getPublishedAgents('your-api-key');
apiKey
string
required
Your Muapi.ai API key.
Returns: Promise<Array> — an array of publicly featured agent objects.

getUserConversations(apiKey)

Retrieve the authenticated user’s full conversation history across all agents from /agents/user/conversations.
import { getUserConversations } from 'studio';

const conversations = await getUserConversations('your-api-key');
console.log(conversations.length); // total conversation count
apiKey
string
required
Your Muapi.ai API key.
Returns: Promise<Array> — an array of conversation objects. Returns an empty array if the response is not an array.

Credit and Balance Utilities

calculateDynamicCost(apiKey, taskName, payload)

Estimate the credit cost of a generation task before submitting it. Send the same taskName and payload you intend to pass to the generation function to get a preview of how many credits will be consumed.
import { calculateDynamicCost } from 'studio';

const cost = await calculateDynamicCost('your-api-key', 'kling-v3', {
  prompt: 'a futuristic city at night',
  duration: 10,
  aspect_ratio: '16:9'
});
console.log(cost); // { credits: 42, ... }
apiKey
string
required
Your Muapi.ai API key.
taskName
string
required
The model endpoint name (e.g. 'kling-v3', 'flux-kontext-dev').
payload
object
required
The same parameters you plan to send to the generation call.
Returns: Promise<object> — an object containing the estimated credit cost.

getUserBalance(apiKey)

Check the remaining credit balance on your Muapi.ai account. Calls GET /api/v1/account/balance.
import { getUserBalance } from 'studio';

const balance = await getUserBalance('your-api-key');
console.log(balance); // { credits: 1250, ... }
apiKey
string
required
Your Muapi.ai API key.
Returns: Promise<object> — an object containing the current credit balance.
Call getUserBalance before long or expensive workflow runs to confirm you have sufficient credits. Pair it with calculateDynamicCost to build a pre-flight check before executing.

Build docs developers (and LLMs) love