Agents
Create, manage and invoke conversation with agents.
Agents have three main components
-
Instruction - This is very important as it tells the agent what it is supposed to do. For example, you can tell the agent that it is a sales agent and it should help the user with their purchase.
-
Knowledge Base - Agents can be trained on a knowledge base. This is a collection of data that the agent can use to respond to queries.
-
Forms - If you want to collect structured information from the user, you can use forms.
Create an Agent
Creates an agent. You can simply create an agent with the type of agent you want to create and then update the agent with more details.
- Name
title
- Type
- string
- Required
- required
- Description
Give your agent a user friendly name. This information is not used for training the agent and is only for display purposes.
- Name
instructions
- Type
- string
- Required
- optional
- Description
This is the most important part of the agent. It tells the agent what it is supposed to do. For example, you can tell the agent that it is a sales agent and it should help the user with their purchase. Make it as specific as possible. Edit this later if you want to make changes and improve responses.
Default: "You are a helpful assistant."
- Name
description
- Type
- string
- Required
- optional
- Description
Give a short description of the agent. This information is not used for training the agent and is only for display purposes.
- Name
coverimage
- Type
- string
- Required
- optional
- Description
URL of the cover image for the agent. Recommended size is 512px x 512px.
- Name
intromessage
- Type
- string
- Required
- optional
- Description
This is the first message that the agent will send to the user. You can use this to greet the user and set the context for the conversation. In voice agents, this message is adapted to the first response received from the user.
- Name
knowledge_search
- Type
- boolean
- Required
- optional
- Description
Enable knowledge base search.
- Name
knowledge_id
- Type
- string
- Required
- optional
- Description
Knowledge Base ID to be used by the agent for answering queries.
Leave this blank if you want to create a new knowledge base.
- Name
form_filling
- Type
- boolean
- Required
- optional
- Description
Enable form filling.
- Name
form_id
- Type
- string
- Required
- optional
- Description
Form ID to be used by the agent for collecting structured information. Leave this blank if you want to create a new form with a default schema.
- Name
form_schema
- Type
- string
- Required
- optional
- Description
Form schema to be used by the agent for collecting structured information. Leave this blank if you want to create a new form with a default schema.
Request
{
"title": "My First AI Agent",
"knowledge_search": true,
}
Response
{
"coverimage": "https://www.ailibrary.ai/ailibrary.svg",
"description": "An AI assistant for sales inquiries.",
"intromessage": "How can I help you today?",
"namespace": "Sales Assistant",
"title": "test_agent_kushagra",
"type": "chat",
"instructions": "You are a helpful assistant. Answer the questions based on the information you are given. If answer is not available in the context, try to navigate the conversation smartly. Answer in English only."
}
Retrieve Agent
Return information about an agent, if found.
Path parameters
- Name
namespace
- Type
- string
- Required
- required
- Description
The namespace of the agent.
Request
my_agent = client.agent.get(namespace="sales-assistant-abc123")
Response
{
"coverimage": "https://www.ailibrary.ai/ailibrary.svg",
"created_timestamp": "2025-02-07 01:11:16",
"description": "An AI assistant for sales inquiries",
"intromessage": "How can I help you today?",
"namespace": "Sales Assistant",
"response_schema": null,
"showcase": null,
"status": null,
"title": "test_agent_kushagra",
"type": "chat",
"instructions": "You are a helpful assistant. Answer the questions based on the information you are given. If answer is not available in the context, try to navigate the conversation smartly. Answer in English only.",
"meta": {"type": "support"}
}
List Agents
List agents.
Request
agents = client.agent.list_agents()
Response
{
"agents": [
{
"namespace": "agent-abc123",
"title": "Sales Assistant",
"description": "Sales inquiry assistant",
"meta": {"type": "support"}
},
// ... other agent objects
],
"meta": {"page": 1}
}
Update Agent
Updates an agent. You can specify only the properties you want to update.
Path parameters
- Name
namespace
- Type
- string
- Required
- required
- Description
The namespace of the agent.
Request body
- Name
title
- Type
- string
- Required
- optional
- Description
Give your agent a user friendly name. This information is not used for training the agent and is only for display purposes.
- Name
type
- Type
- string
- Required
- optional
- Description
Specify the type of agent you want to create.
Options -
notebook
,chat
,voice
- Name
instructions
- Type
- string
- Required
- optional
- Description
This is the most important part of the agent. It tells the agent what it is supposed to do. For example, you can tell the agent that it is a sales agent and it should help the user with their purchase. Make it as specific as possible. Edit this later if you want to make changes and improve responses.
Default: "You are a helpful assistant."
- Name
description
- Type
- string
- Required
- optional
- Description
Give a short description of the agent. This information is not used for training the agent and is only for display purposes.
- Name
coverimage
- Type
- string
- Required
- optional
- Description
URL of the cover image for the agent. Recommended size is 512px x 512px.
- Name
intromessage
- Type
- string
- Required
- optional
- Description
This is the first message that the agent will send to the user. You can use this to greet the user and set the context for the conversation. In voice agents, this message is adapted to the first response received from the user.
- Name
knowledge_search
- Type
- boolean
- Required
- optional
- Description
Enable knowledge base search.
- Name
knowledge_id
- Type
- string
- Required
- optional
- Description
Knowledge Base ID to be used by the agent for answering queries.
- Name
form_filling
- Type
- boolean
- Required
- optional
- Description
Enable form filling.
- Name
form_id
- Type
- string
- Required
- optional
- Description
Form ID to be used by the agent for collecting structured information.
Request
{
"coverimage": "https://www.burgersinghonline.com/wp-content/themes/burger-singh/front/images/logo-v=0.1.png",
"title": "My First AI Agent",
"description": "Ask me anything",
"intromessage": "How can I help you today?",
"instructions": "You are a helpful assistant. Answer the questions based on the information you are given. If answer is not available in the context, try to navigate the conversation smartly. Answer in English only.",
"knowledge_search": true,
"knowledge_id": "myfirstaiagent_1733206677149149"
}
Response
{
"response": "success"
}
Delete Agent
Deletes an agent.
What's deleted? Logs, admins, and other settings are deleted.
What's not deleted? Connected knowledge base, forms and contacts are not deleted.
Deleting connected resources:
To delete all connected resources like knowledge base and forms, set delete_connected_resources
to true
. This action is irreversible. Other agents connected to the deleted resources will be affected.
Path parameters
- Name
namespace
- Type
- string
- Required
- required
- Description
The namespace of the agent.
- Name
delete_connected_resources
- Type
- boolean
- Required
- required
- Description
Set to
true
to delete connected resources like knowledge base and forms.
Request
response = client.agent.delete(namespace="sales-assistant-abc123")
Response
{
"statusCode": 200,
"message": "Agent deleted successfully"
}
Chat
Chat with the agent.
This is a streaming API. Responses are sent as they are generated.
Path parameters
- Name
namespace
- Type
- string
- Required
- required
- Description
The namespace of the agent.
Request body
- Name
session_id
- Type
- string
- Required
- optional
- Description
A unique session id. Highly recommended, this is useful for maintaining the context of the conversation.
- Name
response_format*
- Type
- string
- Required
- optional
- Description
Options -
text
(default),json
- Name
messages
- Type
- array
- Required
- required
- Description
A list of messages comprising the conversation so far.
- Name
messages > role
- Type
- string
- Required
- required
- Description
Options -
assistant
,user
,system
- Name
messages > content
- Type
- string
- Required
- required
- Description
The message content.
Response
Chat responses are streaming by default. Three types of objects are returned for each query
Object | Description | Type |
---|---|---|
chat.completion.knowledge | this contains the details of source | array |
chat.completion.latency | latency of response | string |
chat.completion.chunk | response chunk | string |
Request
{
"session_id": "niusjndckj23",
"messages": [
{
"role": "assistant",
"content": "how are you?"
},
{
"role": "user",
"content": "doing good. thank you."
}
]
}
Response
{
"response": "Our pricing starts at $10/month for the basic plan...",
"session_id": "session_xyz789",
"conversation_id": "conv_abc123",
"meta": {"type": "pricing"}
}