Skip to main content

Agent API

Public Chat API

POST https://gateway.demo.cdc.datenfab.com/byoa/api/v1/agents/chat_public

API Description

After the user's agent is deployed, this interface can be used to initiate chat sessions.

Request Parameters

ParameterTypeDescription
deploy_url_suffixstringagent_id
messagesjsonRequest content

Examples

  • Non-Streaming Request

    import requests

    url = "https://gateway.demo.cdc.datenfab.com/byoa/api/v1/agents/chat_public"

    data = {
    "deploy_url_suffix": "BMZOzoDkpnpuQGplVtXAIaYuCouGivRAvdn29xxxx",
    "messages": [
    {
    "role": "user",
    "content": "hello!"
    },
    {
    "role": "assistant",
    "content": "Hello, how can I help you?"
    },
    {
    "role": "user",
    "content": "In which year were the Olympic Games held in China?"
    }
    ]
    }

    response = requests.post(url, json=data)
    print(response.text)
  • Streaming Request

    import requests

    url = "https://gateway.demo.cdc.datenfab.com/byoa/api/v1/agents/chat_public"

    data = {
    "deploy_url_suffix": "BMZOzoDkpnpuQGplVtXAIaYuCouGivRAvdn29xxxx",
    "messages": [
    {
    "role": "user",
    "content": "hello!"
    },
    {
    "role": "assistant",
    "content": "Hello, how can I help you?"
    },
    {
    "role": "user",
    "content": "Please generate an 800-word college entrance exam essay."
    }
    ]
    }

    response = requests.post(url, json=data, stream=True)
    for line in response.iter_lines():
    print(line.decode("utf-8"))