> For the complete documentation index, see [llms.txt](https://developer.emporix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.emporix.io/api-documentation/api-guides/artificial-intelligence/ai-service/api-reference/agent-chat.md).

# Agent Chat

Chat With Agents

## Starting agent chat

> Allows for communication with Emporix agents.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Agent Chat","description":"Chat With Agents"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agentexecution_manage_own","ai.agentexecution_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agentexecution_manage":"Needed to execute agentic chat.","ai.agentexecution_manage_own":"Needed to execute agentic chat by customers.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"schemas":{"ChatResponse":{"type":"object","properties":{"agentId":{"type":"string","description":"Unique identifier of the agent."},"agentType":{"$ref":"#/components/schemas/AgentType"},"sessionId":{"type":"string","description":"Unique identifier of the session."},"message":{"type":"string","description":"Agent message."}}},"AgentType":{"type":"string","description":"Type of the agent handling the request.","enum":["generic","complaint","anti_fraud"]},"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}},"AgenticRequest":{"type":"object","properties":{"agentId":{"type":"string","description":"Unique identifier of the agent."},"message":{"type":"string","description":"The user message to the agent."},"attachments":{"type":"array","items":{"type":"object","properties":{"attachmentId":{"type":"string","description":"Id of the attachment."},"caption":{"type":"string","description":"Caption of the attachment."},"purpose":{"type":"string","description":"Purpose of the attachment."}},"required":["attachmentId"]}}},"required":["agentId","message"]}},"responses":{"400_resp_common":{"description":"The request was syntactically incorrect.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"500_resp_common":{"description":"A server-side error occurred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"requestBodies":{"AgenticChat":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgenticRequest"}}}}}},"paths":{"/ai-service/{tenant}/agentic/chat":{"post":{"summary":"Starting agent chat","operationId":"POST-ai-agents-chat","responses":{"200":{"description":"Chat response.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ChatResponse"}}}}},"400":{"$ref":"#/components/responses/400_resp_common"},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"},"500":{"$ref":"#/components/responses/500_resp_common"}},"description":"Allows for communication with Emporix agents.","requestBody":{"$ref":"#/components/requestBodies/AgenticChat"},"tags":["Agent Chat"]}}}}
```

## Starting agent chat stream

> Allows for communication with Emporix agents using a Server-Sent Events stream.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Agent Chat","description":"Chat With Agents"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agentexecution_manage_own","ai.agentexecution_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agentexecution_manage":"Needed to execute agentic chat.","ai.agentexecution_manage_own":"Needed to execute agentic chat by customers.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"responses":{"400_resp_common":{"description":"The request was syntactically incorrect.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"500_resp_common":{"description":"A server-side error occurred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"schemas":{"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}},"AgenticRequest":{"type":"object","properties":{"agentId":{"type":"string","description":"Unique identifier of the agent."},"message":{"type":"string","description":"The user message to the agent."},"attachments":{"type":"array","items":{"type":"object","properties":{"attachmentId":{"type":"string","description":"Id of the attachment."},"caption":{"type":"string","description":"Caption of the attachment."},"purpose":{"type":"string","description":"Purpose of the attachment."}},"required":["attachmentId"]}}},"required":["agentId","message"]}},"requestBodies":{"AgenticChat":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgenticRequest"}}}}}},"paths":{"/ai-service/{tenant}/agentic/chat-stream":{"post":{"summary":"Starting agent chat stream","operationId":"POST-ai-agents-chat-stream","responses":{"200":{"description":"Chat response stream.","content":{"text/event-stream":{"schema":{"type":"string"}}}},"400":{"$ref":"#/components/responses/400_resp_common"},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"},"500":{"$ref":"#/components/responses/500_resp_common"}},"description":"Allows for communication with Emporix agents using a Server-Sent Events stream.","requestBody":{"$ref":"#/components/requestBodies/AgenticChat"},"tags":["Agent Chat"]}}}}
```

## Starting agent async chat

> Allows for communication with Emporix agents in async way.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Agent Chat","description":"Chat With Agents"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agentexecution_manage_own","ai.agentexecution_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agentexecution_manage":"Needed to execute agentic chat.","ai.agentexecution_manage_own":"Needed to execute agentic chat by customers.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"schemas":{"JobIdResponse":{"type":"object","properties":{"jobId":{"type":"string","description":"Identifier of the job."}}},"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}},"AgenticRequest":{"type":"object","properties":{"agentId":{"type":"string","description":"Unique identifier of the agent."},"message":{"type":"string","description":"The user message to the agent."},"attachments":{"type":"array","items":{"type":"object","properties":{"attachmentId":{"type":"string","description":"Id of the attachment."},"caption":{"type":"string","description":"Caption of the attachment."},"purpose":{"type":"string","description":"Purpose of the attachment."}},"required":["attachmentId"]}}},"required":["agentId","message"]}},"responses":{"400_resp_common":{"description":"The request was syntactically incorrect.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"500_resp_common":{"description":"A server-side error occurred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}},"requestBodies":{"AgenticChat":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgenticRequest"}}}}}},"paths":{"/ai-service/{tenant}/agentic/chat-async":{"post":{"summary":"Starting agent async chat","operationId":"POST-ai-agents-chat-async","responses":{"201":{"description":"Job ID response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobIdResponse"}}}},"400":{"$ref":"#/components/responses/400_resp_common"},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"},"500":{"$ref":"#/components/responses/500_resp_common"}},"description":"Allows for communication with Emporix agents in async way.","requestBody":{"$ref":"#/components/requestBodies/AgenticChat"},"tags":["Agent Chat"]}}}}
```

## Uploading attachment

> Uploads a new file and assigns it to the agent, or reuses an existing attachment in the current session.\
> \
> Send exactly one of \`attachment\` or \`attachmentId\`. Sending both or neither returns \`400\`.\
> \
> \*\*Upload a file:\*\* send the \`attachment\` form field. The response is \`201\` with the new attachment \`id\` and \`sessionId\`. Supported file extensions:\
> &#x20; \- jpg\
> &#x20; \- jpeg\
> &#x20; \- png\
> &#x20; \- pdf\
> &#x20; \- csv\
> &#x20; \- text\
> &#x20; \- txt\
> \
> \*\*Reuse an attachment:\*\* send the \`attachmentId\` form field and the \`session-id\` header of the session that already contains the attachment. The response is \`204\`.

```json
{"openapi":"3.0.0","info":{"title":"AI Service","version":"0.0.1"},"tags":[{"name":"Agent Chat","description":"Chat With Agents"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":["ai.agentexecution_manage_own","ai.agentexecution_manage"]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"scopes":{"ai.text_manage":"Needed to execute actions related to the text generation.","ai.completion_manage":"Needed to execute actions related to the AI completions.","ai.agentexecution_manage":"Needed to execute agentic chat.","ai.agentexecution_manage_own":"Needed to execute agentic chat by customers.","ai.agent_read":"Needed to read AI agents.","ai.agent_manage":"Needed to manage AI agents."},"tokenUrl":"https://api.emporix.io/oauth/token"}}}},"schemas":{"AttachmentResponse":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of the created attachment."},"sessionId":{"type":"string","description":"Unique identifier of the session. The same sessionId must be used when calling chat endpoints to ensure the correct attachment is found."}}},"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}},"description":""},"ErrorMessageFault":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}},"responses":{"400_resp_common":{"description":"The request was syntactically incorrect.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401_resp_common":{"description":"The authorization token is invalid or has expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessageFault"}}}},"403_resp_common":{"description":"Authorization scopes of the access token are not sufficient and do not match the scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"500_resp_common":{"description":"A server-side error occurred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}}},"paths":{"/ai-service/{tenant}/agentic/{agentId}/attachments":{"post":{"summary":"Uploading attachment","operationId":"POST-ai-agents-upload-attachment","responses":{"201":{"description":"Attachment created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttachmentResponse"}}}},"204":{"description":"Existing attachment reused and assigned to the agent."},"400":{"$ref":"#/components/responses/400_resp_common"},"401":{"$ref":"#/components/responses/401_resp_common"},"403":{"$ref":"#/components/responses/403_resp_common"},"500":{"$ref":"#/components/responses/500_resp_common"}},"description":"Uploads a new file and assigns it to the agent, or reuses an existing attachment in the current session.\n\nSend exactly one of `attachment` or `attachmentId`. Sending both or neither returns `400`.\n\n**Upload a file:** send the `attachment` form field. The response is `201` with the new attachment `id` and `sessionId`. Supported file extensions:\n  - jpg\n  - jpeg\n  - png\n  - pdf\n  - csv\n  - text\n  - txt\n\n**Reuse an attachment:** send the `attachmentId` form field and the `session-id` header of the session that already contains the attachment. The response is `204`.","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"oneOf":[{"type":"object","required":["attachment"],"additionalProperties":false,"properties":{"attachment":{"type":"string","format":"binary","description":"Content of the file. Use this field to upload a new file."}}},{"type":"object","required":["attachmentId"],"additionalProperties":false,"properties":{"attachmentId":{"type":"string","description":"Identifier of an existing attachment to reuse in the current session."}}}]}}}},"tags":["Agent Chat"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.emporix.io/api-documentation/api-guides/artificial-intelligence/ai-service/api-reference/agent-chat.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
