Stream Message
POST https://api.credal.ai/api/v0/copilots/streamMessage Content-Type: application/json
Deprecated. Use the v1 Agents API instead: send a message with POST /v1/agents/sendMessage, then poll for the response with GET /v1/agents/fetchAgentResponse.
Previously, this endpoint streamed a response back as Server-Sent Events.
Reference: https://docs.credal.ai/api-reference/api-reference/copilots/stream-message
Authentication
Section titled “Authentication”Authorizationheader (bearer token, required) — Bearer authentication of the formBearer <token>, where token is your auth token.
Request
Section titled “Request”Body (application/json)
Section titled “Body (application/json)”This endpoint expects an object.
copilotId(UUID, required) — Credal-generated Agent ID to specify which agent to route the request to.message(string, required) — The message you want to send to your agent.email(string, required) — The user profile you want to use when sending the message.conversationId(UUID, optional) — Credal-generated conversation ID for sending follow up messages. Conversation ID is returned after initial message. Optional, to be left off for first messages on new conversations.inputVariables(list of InputVariable, optional) — Optional input variables to be used in the message. Map the name of the variable to a list of urls.
Response
Section titled “Response”This endpoint returns a stream of server sent events. These can be in two formats - one is an initial event, followed by multiple data chunks, followed by a final chunk, or the other format is just one blocked event. See the examples for more details.
- Streaming response of
StreamingChunk. event:initialconversationId(string, required)warnings(list of string, required)webSearchResults(list of WebSearchResult, required)dataFilters(DataFilter, optional)
event:data_chunkchunk(string, required)
event:end_of_messageevent:final_chunksources(list of ReferencedSource, required)
event:blockedblocks(list of string, required)conversationId(UUID, required)warnings(list of string, required)
event:error_chunkerror(ErrorChunkData, required)
InputVariable
Section titled “InputVariable”name(string, required)ids(list of UUID, required)
WebSearchResult
Section titled “WebSearchResult”title(string, required)url(string, required)contents(string, required)
DataFilter
Section titled “DataFilter”semanticSearchTerms(list of string, required)webSearchTerm(list of string, required)filteredDataSourcesPerCollection(list of CollectionFilteredData, required)
ReferencedSource
Section titled “ReferencedSource”id(string, required)externalResourceId(ExternalResourceId, required)name(string, required)url(string, optional)
ErrorChunkData
Section titled “ErrorChunkData”message(string, required)
CollectionFilteredData
Section titled “CollectionFilteredData”collectionId(UUID, required)filteredDataIds(list of UUID, required)filters(list of Filter, required)
ExternalResourceId
Section titled “ExternalResourceId”externalResourceId(string, required)resourceType(enum, required)- Allowed values:
GOOGLE_DRIVE_ITEM,MICROSOFT_DRIVE_ITEM,ZENDESK_TICKET,ZENDESK_ARTICLE,ZENDESK_GROUP,ZENDESK_ARTICLE_SECTION,ZENDESK_ARTICLE_CATEGORY,CONFLUENCE_PAGE,CONFLUENCE_SPACE,JIRA_TICKET,JIRA_PROJECT,SALESFORCE_TASK,BOX_FILE,BOX_FOLDER,NOTION_PAGE,NOTION_DATABASE,SLACK_CHANNEL,MONGO_COLLECTION_SYNC,UNKNOWN
- Allowed values:
Filter
Section titled “Filter”fieldType:stringfield(string, required)operator(enum, required)- Allowed values:
<,>,<=,>=,!=,==,contains
- Allowed values:
value(string, required)
fieldType:numberfield(string, required)operator(enum, required)- Allowed values:
<,>,<=,>=,!=,==,contains
- Allowed values:
value(integer, required)
fieldType:booleanfield(string, required)operator("==", required)value(boolean, required)
fieldType:datetimefield(string, required)operator(enum, required)- Allowed values:
<,>,<=,>=,!=,==,contains
- Allowed values:
value(date, required)
Examples
Section titled “Examples”Example Success
Section titled “Example Success”Request
{
"copilotId": "82e4b12a-6990-45d4-8ebd-85c00e030c24",
"message": "Is Credal SOC 2 compliant?",
"email": "ravin@credal.ai",
"inputVariables": [
{
"name": "input1",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c24"
]
},
{
"name": "input2",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c26"
]
}
]
}Response
event: initial
data: {"event":"initial","conversationId":"fc938005-92db-411a-88eb-32ca50d5f744","webSearchResults":[{"title":"SOC 2 Compliance","url":"https://www.credal.ai/soc2","contents":"Credal is SOC 2 compliant. Learn more about SOC 2 compliance at Credal."}],"warnings":[]}
event: data_chunk
data: {"event":"data_chunk","chunk":"Based on"}
event: data_chunk
data: {"event":"data_chunk","chunk":"the context provided,"}
event: data_chunk
data: {"event":"data_chunk","chunk":"Credal is SOC 2 compliant."}
event: end_of_message
data: {"event":"end_of_message"}
event: final_chunk
data: {"event":"final_chunk","sources":[{"id":"1","externalResourceId":{"externalResourceId":"123456","resourceType":"GOOGLE_DRIVE_ITEM"},"name":"Example Document","url":"https://drive.google.com/file/d/123456/view"}]}SDK Code
import { CredalClient } from "@credal/sdk";
async function main() {
const client = new CredalClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.copilots.streamMessage({
copilotId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
message: "Is Credal SOC 2 compliant?",
email: "ravin@credal.ai",
inputVariables: [
{
name: "input1",
ids: [
"82e4b12a-6990-45d4-8ebd-85c00e030c24",
],
},
{
name: "input2",
ids: [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c26",
],
},
],
});
}
main();
from credal import CredalV0
import uuid
from credal.copilots import InputVariable
client = CredalV0(
api_key="YOUR_TOKEN_HERE",
)
client.copilots.stream_message(
copilot_id=uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c24"),
message="Is Credal SOC 2 compliant?",
email="ravin@credal.ai",
input_variables=[
InputVariable(
name="input1",
ids=[
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c24")
],
),
InputVariable(
name="input2",
ids=[
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c25"),
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c26")
],
)
],
)
Example Blocked
Section titled “Example Blocked”Request
{
"copilotId": "82e4b12a-6990-45d4-8ebd-85c00e030c24",
"message": "Is this user eligible for benefits based on their date of birth?",
"email": "ravin@credal.ai",
"inputVariables": [
{
"name": "input1",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c26"
]
},
{
"name": "input2",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c24"
]
}
]
}Response
event: blocked
data: {"event":"blocked","conversationId":"fc938005-92db-411a-88eb-32ca50d5f744","warnings":[],"blocks":["This request contains PII"]}SDK Code
import { CredalClient } from "@credal/sdk";
async function main() {
const client = new CredalClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.copilots.streamMessage({
copilotId: "82e4b12a-6990-45d4-8ebd-85c00e030c24",
message: "Is this user eligible for benefits based on their date of birth?",
email: "ravin@credal.ai",
inputVariables: [
{
name: "input1",
ids: [
"82e4b12a-6990-45d4-8ebd-85c00e030c26",
],
},
{
name: "input2",
ids: [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c24",
],
},
],
});
}
main();
from credal import CredalV0
import uuid
from credal.copilots import InputVariable
client = CredalV0(
api_key="YOUR_TOKEN_HERE",
)
client.copilots.stream_message(
copilot_id=uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c24"),
message="Is this user eligible for benefits based on their date of birth?",
email="ravin@credal.ai",
input_variables=[
InputVariable(
name="input1",
ids=[
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c26")
],
),
InputVariable(
name="input2",
ids=[
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c25"),
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c24")
],
)
],
)
Example Error
Section titled “Example Error”Request
{
"copilotId": "82e4b12a-6990-45d4-8ebd-85c00e030c25",
"message": "Is Credal SOC 2 compliant?",
"email": "ravin@credal.ai",
"inputVariables": [
{
"name": "input1",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c24"
]
},
{
"name": "input2",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c26"
]
}
]
}Response
event: initial
data: {"event":"initial","conversationId":"fc938005-92db-411a-88eb-32ca50d5f744","webSearchResults":[{"title":"SOC 2 Compliance","url":"https://www.credal.ai/soc2","contents":"Credal is SOC 2 compliant. Learn more about SOC 2 compliance at Credal."}],"warnings":[]}
event: error_chunk
data: {"event":"error_chunk","error":{"message":"This is an error"}}
event: end_of_message
data: {"event":"end_of_message"}
event: final_chunk
data: {"event":"final_chunk","sources":[]}SDK Code
import { CredalClient } from "@credal/sdk";
async function main() {
const client = new CredalClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.copilots.streamMessage({
copilotId: "82e4b12a-6990-45d4-8ebd-85c00e030c25",
message: "Is Credal SOC 2 compliant?",
email: "ravin@credal.ai",
inputVariables: [
{
name: "input1",
ids: [
"82e4b12a-6990-45d4-8ebd-85c00e030c24",
],
},
{
name: "input2",
ids: [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c26",
],
},
],
});
}
main();
from credal import CredalV0
import uuid
from credal.copilots import InputVariable
client = CredalV0(
api_key="YOUR_TOKEN_HERE",
)
client.copilots.stream_message(
copilot_id=uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c25"),
message="Is Credal SOC 2 compliant?",
email="ravin@credal.ai",
input_variables=[
InputVariable(
name="input1",
ids=[
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c24")
],
),
InputVariable(
name="input2",
ids=[
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c25"),
uuid.UUID("82e4b12a-6990-45d4-8ebd-85c00e030c26")
],
)
],
)