Docs API reference
Markdown Get an API key

API referenceChat and agents

Direct Tool Execution

Run a known synchronous composition or planning tool with exact JSON arguments. Use this when your application already knows which tool to call and does not need an LLM round to choose or rewrite the arguments.

#Execute a tool

POST /v1/creative-agent/tools/execute Auth required

Executes one synchronous composition or planning tool and returns its structured payload. Long-running media generation tools such as generate_image and generate_video are rejected here; use Creative Workflows for exact media steps, or Chat Completions when the LLM should interpret a request.

#Body

NameTypeInDescription
toolrequiredstringbodySynchronous hosted tool name. tool_name is accepted as an alias.
argumentsrequiredobjectbodyExact JSON arguments for the selected tool. Must be an object.
token_typestringbodyspark, sogni, or auto. The camelCase alias tokenType is accepted; other values return 400.
billing_modestringbodyauto (default), subscription, or tokens. billingMode is accepted.
safe_content_filterbooleanbodyOptional Sensitive Content Filter setting. safeContentFilter is accepted.
app_sourcestringbodyOptional caller label; values longer than 128 characters are truncated. The X-App-Source header is accepted.

Unknown body fields return 400.

#Supported tools

ToolUse
enhance_promptExpand or adapt rough prompts into model-ready image, video, music, or edit prompts.
compose_scriptDraft scripts, storyboards, trailers, social shorts, campaign beats, or video prompts.
compose_lyricsWrite vocal song lyrics and suggested musical parameters.
compose_instrumentalWrite instrumental structure and suggested musical parameters.
compose_workflowCompile a creative brief into a durable workflow input plan and cost estimate.
compose_workflow_templateDraft or edit a parameterized workflow template plus an example plan.

#Request

curl https://api.sogni.ai/v1/creative-agent/tools/execute \
  -H "Authorization: Bearer $SOGNI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tool": "enhance_prompt",
    "arguments": {
      "prompt": "A cinematic portrait of a glass robot",
      "target_output": "image_prompt",
      "destination_tool": "generate_image",
      "destination_model": "krea-2-turbo"
    },
    "token_type": "spark",
    "app_source": "my-app"
  }'

#Response

{
  "status": "success",
  "data": {
    "toolCallId": "direct_1773353812000",
    "tool": "enhance_prompt",
    "result": {
      "ok": true,
      "success": true,
      "tool": "enhance_prompt",
      "prompt": "Cinematic portrait of a translucent glass robot...",
      "message": "Cinematic portrait of a translucent glass robot..."
    },
    "message": "Cinematic portrait of a translucent glass robot..."
  }
}
Check result.ok. A tool-level failure, such as a missing required argument, still returns 200, with data.result.ok: false, error_type, message, retryable, and suggested_next_action. enhance_prompt requires prompt, target_output (image_prompt, video_prompt, edit_prompt, or model_prompt), and destination_model.
A shortcut, not a planner loop. This endpoint executes exactly one supported synchronous tool. It is the efficient path for prompt expansion, script and lyrics composition, and workflow planning when your app already has the tool and its arguments.