{
  "name": "03 Kimi K2.5 Router - Thinking API",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "kimi-think",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "c3d4e5f6-3333-4ccc-b333-000000000001",
      "name": "Webhook POST /kimi-think",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "prompt-val",
              "name": "prompt",
              "value": "={{ $json.body.prompt || 'Analyze this situation and provide strategic advice.' }}",
              "type": "string"
            },
            {
              "id": "system-val",
              "name": "system_message",
              "value": "={{ $json.body.system || 'You are a strategic AI advisor for Maurice\\'s AI Empire. Think deeply, provide actionable insights, and focus on revenue generation. Be direct and concise.' }}",
              "type": "string"
            },
            {
              "id": "max-tokens-val",
              "name": "max_tokens",
              "value": "={{ $json.body.max_tokens || 2048 }}",
              "type": "number"
            }
          ]
        }
      },
      "id": "c3d4e5f6-3333-4ccc-b333-000000000002",
      "name": "Parse Input",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.moonshot.ai/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ \"model\": \"moonshot-v1-auto\", \"messages\": [ { \"role\": \"system\", \"content\": $json.system_message }, { \"role\": \"user\", \"content\": $json.prompt } ], \"temperature\": 1.0, \"max_tokens\": $json.max_tokens, \"stream\": false }) }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{ $env.MOONSHOT_API_KEY }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "options": {
          "timeout": 90000
        }
      },
      "id": "c3d4e5f6-3333-4ccc-b333-000000000003",
      "name": "Kimi API Call",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "response-text",
              "name": "response",
              "value": "={{ $json.choices[0].message.content }}",
              "type": "string"
            },
            {
              "id": "model-used",
              "name": "model",
              "value": "={{ $json.model }}",
              "type": "string"
            },
            {
              "id": "usage-prompt",
              "name": "prompt_tokens",
              "value": "={{ $json.usage.prompt_tokens }}",
              "type": "number"
            },
            {
              "id": "usage-completion",
              "name": "completion_tokens",
              "value": "={{ $json.usage.completion_tokens }}",
              "type": "number"
            },
            {
              "id": "usage-total",
              "name": "total_tokens",
              "value": "={{ $json.usage.total_tokens }}",
              "type": "number"
            },
            {
              "id": "finish-reason",
              "name": "finish_reason",
              "value": "={{ $json.choices[0].finish_reason }}",
              "type": "string"
            },
            {
              "id": "cost-estimate",
              "name": "estimated_cost_usd",
              "value": "={{ ($json.usage.total_tokens || 0) * 0.000003 }}",
              "type": "number"
            }
          ]
        }
      },
      "id": "c3d4e5f6-3333-4ccc-b333-000000000004",
      "name": "Format Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ \"success\": true, \"response\": $json.response, \"model\": $json.model, \"tokens\": { \"prompt\": $json.prompt_tokens, \"completion\": $json.completion_tokens, \"total\": $json.total_tokens }, \"estimated_cost_usd\": $json.estimated_cost_usd, \"finish_reason\": $json.finish_reason }) }}",
        "options": {
          "responseCode": 200
        }
      },
      "id": "c3d4e5f6-3333-4ccc-b333-000000000005",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1120,
        300
      ]
    }
  ],
  "connections": {
    "Webhook POST /kimi-think": {
      "main": [
        [
          {
            "node": "Parse Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Input": {
      "main": [
        [
          {
            "node": "Kimi API Call",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Kimi API Call": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    {
      "name": "kimi",
      "createdAt": "2026-02-08T00:00:00.000Z",
      "updatedAt": "2026-02-08T00:00:00.000Z"
    },
    {
      "name": "ai-empire",
      "createdAt": "2026-02-08T00:00:00.000Z",
      "updatedAt": "2026-02-08T00:00:00.000Z"
    }
  ]
}