4Z API

创建函数调用 Copy

接口: POST https://4zapi.com/v1/responses

https://platform.openai.com/docs/api-reference/responses/create 部分OpenAI模型仅支持Response格式,例如 gpt-6-astra、gpt-6.1-sol、gpt-6.1-terra 的工具调用必须走 Responses

参数

  • Content-Type (header, string, 必填): 请求体 Content-Type,一般为 application/json
  • Accept (header, string, 必填): 期望的响应 Content-Type
  • Authorization (header, string): Bearer API Key

请求体 (application/json)

  • input (array<object>): 输入内容
  • model (string): 要使用的模型的 ID。有关哪些模型可与聊天 API 一起使用的详细信息,请参阅模型端点兼容性表。

请求示例

{
  "input": [
    {
      "content": "请同时帮我做以下几件事:\n1. 获取当前系统时间\n2. 查看系统信息(操作系统、内存等)\n3. 帮我计算 123.5 + 456.7 的结果\n4. 生成3个1-100之间的随机数\n\n这是一个并行工具调用测试,请同时执行这些任务。",
      "role": "user"
    }
  ],
  "metadata": {
    "model_id": "32"
  },
  "model": "gpt-6-luna",
  "reasoning": {
    "effort": "none"
  },
  "tool_choice": "auto",
  "tools": [
    {
      "description": "生成指定范围内的随机数,支持批量生成",
      "name": "random_generator",
      "parameters": {
        "properties": {
          "count": {
            "description": "生成数量(默认1,最大10)",
            "type": "integer",
            "x-i18n": {
              "en-US": {
                "description": "Number of generations (default 1, maximum 10)"
              }
            }
          },
          "max": {
            "description": "最大值(默认100)",
            "type": "integer",
            "x-i18n": {
              "en-US": {
                "description": "Maximum value (default 100)"
              }
            }
          },
          "min": {
            "description": "最小值(默认1)",
            "type": "integer",
            "x-i18n": {
              "en-US": {
                "description": "Minimum value (default 1)"
              }
            }
          }
        },
        "type": "object"
      },
      "type": "function",
      "x-i18n": {
        "en-US": {
          "description": "Generate random numbers within a specified range, supporting batch generation"
        }
      }
    },
    {
      "description": "获取当前系统的基本信息,包括操作系统、Java版本、内存使用情况等",
      "name": "system_info",
      "parameters": {
        "properties": {},
        "type": "object"
      },
      "type": "function",
      "x-i18n": {
        "en-US": {
          "description": "Obtain basic information about the current system, including operating system, Java version, memory usage, etc."
        }
      }
    },
    {
      "description": "执行基本数学运算,支持加减乘除和幂运算",
      "name": "math_calculator",
      "parameters": {
        "properties": {
          "a": {
            "description": "第一个数字",
            "type": "number",
            "x-i18n": {
              "en-US": {
                "description": "first number"
              }
            }
          },
          "b": {
            "description": "第二个数字",
            "type": "number",
            "x-i18n": {
              "en-US": {
                "description": "second number"
              }
            }
          },
          "operation": {
            "description": "运算类型: add, subtract, multiply, divide, power",
            "type": "string",
            "x-i18n": {
              "en-US": {
                "description": "Operation types: add, subtract, multiply, divide, power"
              }
            }
          }
        },
        "required": [
          "operation",
          "a",
          "b"
        ],
        "type": "object"
      },
      "type": "function",
      "x-i18n": {
        "en-US": {
          "description": "Perform basic mathematical operations, supporting addition, subtraction, multiplication, division and exponentiation operations"
        }
      }
    },
    {
      "description": "获取当前系统时间",
      "name": "current_time",
      "parameters": {
        "properties": {},
        "type": "object"
      },
      "type": "function",
      "x-i18n": {
        "en-US": {
          "description": "Get the current system time"
        }
      }
    }
  ]
}