> ## Documentation Index
> Fetch the complete documentation index at: https://developer.duplik.cn/llms.txt
> Use this file to discover all available pages before exploring further.

> Execute an API or LLM tool

# Execute Tool



## OpenAPI

````yaml post /v1/tools/{tool_id}
openapi: 3.1.0
info:
  title: spectra-server
  description: The API for Spectra Backend.
  version: 0.1.0
servers:
  - url: https://api-spectra.duplik.cn
security: []
paths:
  /v1/tools/{tool_id}:
    post:
      tags:
        - Tools
      summary: Execute Tool
      description: Execute a API or LLM tool
      operationId: execute_tool_v1_tools__tool_id__post
      parameters:
        - name: tool_id
          in: path
          required: true
          schema:
            type: string
            description: Tool ID
            title: Tool Id
          description: Tool ID
        - name: api_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: API ID
            title: Api Id
          description: API ID
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ToolTestRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToolTestResponse'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
      security:
        - HTTPBearer: []
components:
  schemas:
    ToolTestRequest:
      properties:
        model_provider:
          type: string
          title: Model Provider
          default: azure
        model_name:
          type: string
          title: Model Name
          default: gpt-4o-mini
        stream:
          type: boolean
          title: Stream
          default: false
        temperature:
          anyOf:
            - type: number
            - type: 'null'
          title: Temperature
          default: 0.1
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
          default: 512
        params:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/LLMToolTestParam'
                  - $ref: '#/components/schemas/APIToolTestParam'
              type: array
            - type: 'null'
          title: Params
          description: Param List
      type: object
      title: ToolTestRequest
    ToolTestResponse:
      properties:
        status:
          type: string
          title: Status
          description: 'Test status: success, failed, or error'
        status_code:
          anyOf:
            - type: integer
            - type: 'null'
          title: Status Code
          description: HTTP status code for API tool
        response:
          anyOf:
            - {}
            - type: 'null'
          title: Response
          description: Test response content
        error:
          anyOf:
            - type: string
            - type: 'null'
          title: Error
          description: Error message if test failed
      type: object
      required:
        - status
      title: ToolTestResponse
      examples:
        - response:
            message: Success
          status: success
          status_code: 200
    ErrorResponse:
      properties:
        code:
          type: integer
          title: Code
        message:
          type: string
          title: Message
      type: object
      required:
        - code
        - message
      title: ErrorResponse
    LLMToolTestParam:
      properties:
        key:
          type: string
          title: Key
          description: Parameter key
        value:
          title: Value
          description: Test value for the parameter
      type: object
      required:
        - key
        - value
      title: LLMToolTestParam
      example:
        key: content
        value: What is the capital of France?
    APIToolTestParam:
      properties:
        key:
          type: string
          title: Key
          description: Parameter key
        value:
          title: Value
          description: Test value for the parameter
      type: object
      required:
        - key
        - value
      title: APIToolTestParam
      example:
        key: symbol
        value: 宁德时代
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````