Continue Conversation

API Endpoint

POST https://api.genaifactory.ai/v1/conversations/{session_id}

Headers

Name
Type
Required
Description

formacloud-api-key

string

Yes

API key for authentication

Available Action Types

ActionType
Value
Description

CALL_TOOL

"CallTool"

The system invokes an external tool to process the request. If this action is returned, the API must be called again to retrieve the tool's response.

ASK_USER

"AskUser"

The system requires user input to proceed. In this case, the user_input field must be provided in the next API call.

FINISH

"Finish"

The conversation session has reached its final state.

PLAN

"Plan"

The system is generating a structured plan for further execution.

CREATE_TOOL

"CreateTool"

The system dynamically creates a new tool or function based on the conversation's requirements.

Request Body

Name
Type
Required
Description

user_input

string

Yes (if Last StepActionType = ASK_USER)

The user's response in the conversation. Required when the previous action type is ASK_USER. Otherwise, send an empty {}.

query_step_result

bool

No

If true, the API only returns the latest step result without executing a new step. (default: false)

Example Request

When ActionType = ASK_USER (user_input is required)

curl --location 'https://api.genaifactory.ai/v1/conversations/shuxuan-test-1' \
--header 'formacloud-api-key: abc123' \
--header 'Content-Type: application/json' \
--data '{
    "user_input": "create a dog image"
}'

When ActionType is NOT ASK_USER (send an empty {})

curl --location 'https://api.genaifactory.ai/v1/conversations/shuxuan-test-1' \
--header 'formacloud-api-key: abc123' \
--header 'Content-Type: application/json' \
--data '{}'

Get the latest step result without executing a new step

curl --location 'https://api.genaifactory.ai/v1/conversations/shuxuan-test-1' \
--header 'formacloud-api-key: abc123' \
--header 'Content-Type: application/json' \
--data '{"query_step_result": true}'

Response

Returns a JSON object containing the updated conversation step.

Field
Type
Description

session_id

string

Unique session identifier

current_step

object

The latest step in the conversation

Response Handling

If the response contains:ActionType = CALL_TOOL, you must call this API again to retrieve the step result.

Example Response 1

{
    "current_step": {
        "agent_response": {
            "action": "AskUser",
            "parameters": {
                "question": "I'll help you create a dog image! To get the best result, could you please provide more details about:\n\n1. What breed of dog would you like? (e.g., Golden Retriever, Husky, etc.)\n2. What should the dog be doing? (e.g., sitting, running, playing)\n3. Any specific setting or background you'd like? (e.g., park, beach, home)\n4. Any particular style you prefer? (e.g., realistic, cartoon, artistic)\n\nThe more details you provide, the better the image will match your vision!"
            },
            "reasoning": "The user wants to create a dog image. We can use the text-to-image generation tool (generate_image_by_recraft) for this. However, before generating the image, I should ask for more specific details about the type of dog image they want to ensure we get the best possible result.",
            "selected_tool": ""
        },
        "id": 1,
        "step_result": null,
        "timestamp": "2025-02-21T04:48:59.812834+00:00"
    },
    "session_id": "shuxuan-test-1"
}

Example Response 2

{
    "current_step": {
        "agent_response": {
            "action": "CallTool",
            "parameters": {
                "prompt": "A photorealistic dog running at full speed in an open field with grass. The dog's muscles are tense, fur flowing in the wind, captured in mid-stride with all four paws off the ground. Natural lighting, high detail, crisp focus on the dog's determined expression."
            },
            "reasoning": "The user has requested a running and realistic dog image. Now I need to generate this image using the 'generate_image_by_recraft' tool, which allows for text-to-image generation. I'll craft a detailed prompt to create the realistic running dog image the user wants.",
            "selected_tool": "generate_image_by_recraft"
        },
        "id": 2,
        "step_result": null,
        "timestamp": "2025-02-25T11:38:51.634443+00:00"
    },
    "session_id": "shuxuan-test-1"
}

Next Step: If "action": "CALL_TOOL" and "step_result": null, make another API request to get the step result.

Last updated

Was this helpful?