Skip to main content
Credal | Documentation

Search documentation

Type to search this documentation.

On this pageOverview

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

  • Authorization header (bearer token, required) — Bearer authentication of the form Bearer <token>, where token is your auth token.

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.

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: initial
    • conversationId (string, required)
    • warnings (list of string, required)
    • webSearchResults (list of WebSearchResult, required)
    • dataFilters (DataFilter, optional)
  • event: data_chunk
    • chunk (string, required)
  • event: end_of_message
  • event: final_chunk
    • sources (list of ReferencedSource, required)
  • event: blocked
    • blocks (list of string, required)
    • conversationId (UUID, required)
    • warnings (list of string, required)
  • event: error_chunk
    • error (ErrorChunkData, required)
  • name (string, required)
  • ids (list of UUID, required)
  • title (string, required)
  • url (string, required)
  • contents (string, required)
  • semanticSearchTerms (list of string, required)
  • webSearchTerm (list of string, required)
  • filteredDataSourcesPerCollection (list of CollectionFilteredData, required)
  • id (string, required)
  • externalResourceId (ExternalResourceId, required)
  • name (string, required)
  • url (string, optional)
  • message (string, required)
  • collectionId (UUID, required)
  • filteredDataIds (list of UUID, required)
  • filters (list of Filter, required)
  • 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
  • fieldType: string
    • field (string, required)
    • operator (enum, required)
      • Allowed values: <, >, <=, >=, !=, ==, contains
    • value (string, required)
  • fieldType: number
    • field (string, required)
    • operator (enum, required)
      • Allowed values: <, >, <=, >=, !=, ==, contains
    • value (integer, required)
  • fieldType: boolean
    • field (string, required)
    • operator ("==", required)
    • value (boolean, required)
  • fieldType: datetime
    • field (string, required)
    • operator (enum, required)
      • Allowed values: <, >, <=, >=, !=, ==, contains
    • value (date, required)

Request

JSON
{
  "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

text
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

Example
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();
Example
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")
            ],
        )
    ],
)

Request

JSON
{
  "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

text
event: blocked
data: {"event":"blocked","conversationId":"fc938005-92db-411a-88eb-32ca50d5f744","warnings":[],"blocks":["This request contains PII"]}

SDK Code

Example
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();
Example
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")
            ],
        )
    ],
)

Request

JSON
{
  "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

text
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

Example
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();
Example
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")
            ],
        )
    ],
)
Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu