Skip to main content

Give Your AI Agent a Chat Interface

Code Capsules provides an integrated chat window for Agent Capsules. In order for this to be fully functional, there are a few endpoints which the API needs to expose.

API Requirements​

The deployed codebase needs to expose a few endpoints, each with their own pre-described payload. Data is always returned in the ApiResponse format. Errors are returned in the Error format.

OpenAPI code-capsules-api

Endpoints​

Below describes the endpoints required to use the integrated chat window:

EndpointPurposeMandatorySample Docs

POST

/api/chat/message

Send a message to the agent with an instant response.Yes*#post-api-chat-message

POST

/api/chat/message/stream

Send a message to the agent, streaming back the response.Yes*#post-api-chat-message-stream

GET

/api/chat/history

Get the chat history for the user.Yes#get-api-chat-history

POST

/api/context/text

Submit context to the agent using text.No#post-api-context-text

POST

/api/context/url

Submit context to the agent using a URL.No#post-api-context-url

*Only one of these are required

Request Headers from Code Capsules​

All of the above endpoints will also be passed the following headers. This allows for some simple security when testing the agent using the integrated chat window:

HeaderDescriptionMandatory
X-CC-API-KEYThis value will be the value as generated in the INTERNAL_API_KEY environment variable on creation of the Agent capsule.No
X-CC-EMAILThis value will be the email of the user who has logged into Code Capsules, allowing for testing with unique chat sessions and chat history.No