Dify Chat Messages API
Operations related to chat messages and interactions.
Operations related to chat messages and interactions.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/dify-chat-messages-api"
curl "https://apis.io/api/v1/apis?limit=25"
Discovery needs no key. Ratings and market analysis are Pro.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Dify Service Chat Messages API
description: REST API for Dify applications and knowledge bases. Application endpoints authenticate with an app API key; knowledge endpoints authenticate with a dataset API key.
version: 1.0.0
servers:
- url: https://{api_base_url}
description: Base URL of the Dify Service API. For self-hosted deployments, replace it with your own API base URL.
variables:
api_base_url:
default: api.dify.ai/v1
description: Host and path of the API base URL, without the `https://` prefix.
security:
- ApiKeyAuth: []
tags:
- name: Chat Messages
description: Operations related to chat messages and interactions.
paths:
/chat-messages:
post:
summary: Send Chat Message
description: '**Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps.
Sends a message to a chat app and returns the assistant''s reply. The events in the streaming response vary by app type.'
operationId: sendChatMessage
tags:
- Chat Messages
requestBody:
description: Request body to send a chat message.
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ChatRequest'
examples:
streaming_example:
summary: Request Example - Streaming mode
value:
inputs:
city: San Francisco
query: What are the specs of the iPhone 13 Pro Max?
response_mode: streaming
conversation_id: ''
user: abc-123
files:
- type: image
transfer_method: remote_url
url: https://cloud.dify.ai/logo/logo-site.png
blocking_example:
summary: Request Example - Blocking mode
value:
inputs: {}
query: What are the specs of the iPhone 13 Pro Max?
response_mode: blocking
conversation_id: 45701982-8118-4bc5-8e9b-64562b4555f2
user: abc-123
responses:
'200':
description: 'Successful response. The content type and structure depend on the `response_mode` parameter in the request.
- If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object.
- If `response_mode` is `streaming`, returns `text/event-stream` with a stream of Server-Sent Events.'
content:
application/json:
schema:
$ref: '#/components/schemas/ChatCompletionResponse'
examples:
blockingResponse:
summary: Response Example - Blocking mode
value:
event: message
task_id: c3800678-a077-43df-a102-53f23ed20b88
id: b01a39de-3480-4f3e-9f1e-4841a80f8e5e
message_id: 9da23599-e713-473b-982c-4328d4f5c78a
conversation_id: 45701982-8118-4bc5-8e9b-64562b4555f2
mode: chat
answer: iPhone 13 Pro Max specs are listed here:...
metadata:
usage:
prompt_tokens: 1033
prompt_unit_price: '0.001'
prompt_price_unit: '0.001'
prompt_price: '0.0010330'
completion_tokens: 128
completion_unit_price: '0.002'
completion_price_unit: '0.001'
completion_price: '0.0002560'
total_tokens: 1161
total_price: '0.0012890'
currency: USD
latency: 0.7682376249867957
retriever_resources:
- position: 1
dataset_id: 101b4c97-fc2e-463c-90b1-5261a4cdcafb
dataset_name: iPhone
document_id: 8dd1ad74-0b5f-4175-b735-7d98bbbb4e00
document_name: iPhone List
segment_id: ed599c7f-2766-4294-9d1d-e5235a61270a
score: 0.98457545
content: '"Model","Release Date","Display Size","Resolution","Processor","RAM","Storage","Camera","Battery","Operating System" "iPhone 13 Pro Max","September 24, 2021","6.7 inch","1284 x 2778","Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)","6 GB","128, 256, 512 GB, 1TB","12 MP","4352 mAh","iOS 15"'
created_at: 1705407629
text/event-stream:
schema:
type: string
description: "A stream of Server-Sent Events. Parse it per the [SSE Streaming guide](/en/api-reference/guides/streaming): read `data:` lines, dispatch on the `event` field, skip `ping` (keep-alive; a Chatflow stream opens with one, then more arrive roughly every 10 seconds).\n\n**Events by app type** (the reply events, then how the stream closes):\n\n- **Chatbot**: `message` chunks (concatenate in order) → `message_end`.\n- **Legacy Agent**: `agent_thought` reasoning and tool-call steps alongside `agent_message` chunks → `message_end`.\n- **Agent**: `agent_message` chunks with `agent_thought` steps alongside → one closing `message` carrying the complete answer (treat it as the final answer, not extra text to append) → `message_end`. Its `message_end` metadata carries `usage` (plus `annotation_reply` on an annotation match) and never `retriever_resources`.\n- **Chatflow**: `workflow_started` → node events (`node_started`, `node_finished`, plus iteration and loop variants) alongside `message` chunks → then, by outcome:\n - **Success**: `message_end`, then `workflow_finished`\n - **Failure**: `workflow_finished` with status `failed`, then `error`; no `message_end`\n - **Pause**: `human_input_required`, then `workflow_paused` (the stream ends here; the run resumes separately)\n\n**Add-ons**:\n\n- Text-to-speech auto-play: `tts_message` audio chunks interleave, and `tts_message_end` trails the closing event.\n- Chatflow LLM nodes with `reasoning_format: separated` also emit `reasoning_chunk` deltas carrying the model's reasoning.\n\n**Common fields**: apart from `ping`, every event includes `conversation_id`, `message_id`, and `created_at` (Unix epoch seconds); all but `error` also include `task_id`. Workflow, node, and human-input events (Chatflow apps) nest their payload under `data` and, except for `agent_log`, carry a top-level `workflow_run_id`.\n\n**Reply events**\n\n| Event | App | Fires on | Key fields |\n|:---|:---|:---|:---|\n| `message` | Chatbot, Chatflow, Agent | each answer chunk (concatenate in order); for Agent, one closing chunk with the complete answer | `answer` |\n| `agent_message` | Legacy Agent, Agent | each answer chunk (concatenate in order) | `answer` |\n| `agent_thought` | Legacy Agent, Agent | each reasoning or tool-call step | `position`, `thought`, `tool`, `tool_input` (JSON), `observation`, `message_files` |\n| `message_replace` | All | output moderation replaces the answer so far | `answer`; Chatflow also `reason` |\n| `reasoning_chunk` | Chatflow | each reasoning-content delta, when an LLM node uses `reasoning_format: separated` (concatenate in order; a final `is_final: true` event marks reasoning finished and may carry an empty `reasoning`) | `data.message_id`, `data.reasoning`, `data.node_id`, `data.is_final` |\n| `message_file` | Chatbot, Legacy Agent | the assistant returns a file | `type`, `belongs_to`, `url` |\n| `message_end` | All | the answer is complete | `metadata` (`usage`, `retriever_resources`) |\n| `tts_message`, `tts_message_end` | Chatbot, Legacy Agent, Chatflow | audio chunk / end, when TTS auto-play is on | `audio` |\n\n**Workflow and node events** (Chatflow apps only)\n\nEach event nests its payload under a `data` object.\n\n| Event | Fires on | Key `data` fields |\n|:---|:---|:---|\n| `workflow_started` | the run begins | `inputs` |\n| `node_started` | a node begins | `node_id`, `node_type`, `title` |\n| `node_finished` | a node ends | `status`, `outputs`, `execution_metadata` |\n| `node_retry` | a node retries after a failure | `retry_index` |\n| `iteration_started`, `iteration_next`, `iteration_completed` | Iteration node progress (informational) | `data` |\n| `loop_started`, `loop_next`, `loop_completed` | Loop node progress (informational) | `data` |\n| `agent_log` | an Agent node step log (informational; no `workflow_run_id`) | `data` |\n| `workflow_finished` | the run ends | `status` (`succeeded`, `failed`, `partial-succeeded`, `stopped`), `outputs`, `total_tokens` |\n| `workflow_paused` | the run pauses | `paused_nodes`, `reasons` |\n| `human_input_required` | the run reaches a Human Input node | `form_token`, `form_content`, `expiration_time` |\n\nAfter a pause this stream ends at `workflow_paused`. Submit the form via [Submit Human Input Form](/en/api-reference/human-input/submit-human-input-form) or let it time out; the resumed run, including `human_input_form_filled`/`human_input_form_timeout` through `workflow_finished`, streams from [Stream Workflow Events](/en/api-reference/workflow-runs/stream-workflow-events).\n\n**Transport events**\n\n| Event | Fires on | Key fields |\n|:---|:---|:---|\n| `error` | a failure ends the stream; HTTP stays `200` | `status` (e.g. `400`), `code` (e.g. `invalid_param`), `message` |\n| `ping` | keep-alive; opens every Chatflow stream, then roughly every 10 seconds | none |"
examples:
streamingResponseBasic:
summary: Response Example - Streaming (Basic)
value: 'data: {"event": "message", "task_id": "mock_task_id", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "answer": " I", "created_at": 1679586595}
data: {"event": "message_end", "task_id": "mock_task_id", "message_id": "5ad4cb98-f0c7-4085-b384-88c403be6290", "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", "created_at": 1679586595, "metadata": {"usage": {"total_tokens": 10, "latency": 1.0}}}'
streamingResponseAgent:
summary: Response Example - Streaming (Agent)
value: 'data: {"event": "agent_thought", "id": "agent_thought_id_1", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "position": 1, "thought": "Thinking about calling a tool...", "tool": "dalle3", "tool_input": "{\"dalle3\": {\"prompt\": \"a cute cat\"}}", "created_at": 1705395332}
data: {"event": "message_file", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "id": "file_id_1", "type": "image", "belongs_to": "assistant", "url": "https://example.com/cat.png", "created_at": 1705395332}
data: {"event": "agent_message", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "answer": "Here is the image: ", "created_at": 1705395333}
data: {"event": "message_end", "task_id":"task123", "message_id": "msg123", "conversation_id": "conv123", "metadata": {"usage": {"total_tokens": 50, "latency": 2.5}}}'
streamingResponseWorkflow:
summary: Response Example - Streaming (Workflow)
value: 'event: ping
data: {"event": "workflow_started", "task_id": "task123", "workflow_run_id": "wfr_abc123", "message_id": "msg123", "conversation_id": "conv123", "created_at": 1705395332, "data": {"id": "wfr_abc123", "workflow_id": "wf_def456", "inputs": {"city": "San Francisco"}, "created_at": 1705395332}}
data: {"event": "node_started", "task_id": "task123", "workflow_run_id": "wfr_abc123", "message_id": "msg123", "conversation_id": "conv123", "created_at": 1705395332, "data": {"id": "ne_001", "node_id": "node_llm_1", "node_type": "llm", "title": "LLM", "index": 1, "created_at": 1705395332}}
data: {"event": "reasoning_chunk", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "created_at": 1705395333, "data": {"message_id": "msg123", "reasoning": "The user greeted me, so", "node_id": "node_llm_1", "is_final": false}}
data: {"event": "reasoning_chunk", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "created_at": 1705395333, "data": {"message_id": "msg123", "reasoning": "", "node_id": "node_llm_1", "is_final": true}}
data: {"event": "message", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "answer": " I", "created_at": 1705395333}
data: {"event": "node_finished", "task_id": "task123", "workflow_run_id": "wfr_abc123", "message_id": "msg123", "conversation_id": "conv123", "created_at": 1705395334, "data": {"id": "ne_001", "node_id": "node_llm_1", "node_type": "llm", "title": "LLM", "index": 1, "status": "succeeded", "elapsed_time": 1.5, "created_at": 1705395332, "finished_at": 1705395334}}
data: {"event": "message_end", "task_id": "task123", "message_id": "msg123", "conversation_id": "conv123", "created_at": 1705395334, "metadata": {"usage": {"total_tokens": 50, "latency": 2.5}}}
data: {"event": "workflow_finished", "task_id": "task123", "workflow_run_id": "wfr_abc123", "message_id": "msg123", "conversation_id": "conv123", "created_at": 1705395335, "data": {"id": "wfr_abc123", "workflow_id": "wf_def456", "status": "succeeded", "elapsed_time": 2.5, "total_tokens": 50, "total_steps": 2, "created_at": 1705395332, "finished_at": 1705395335}}'
humanInputPause:
summary: Response Example - Human Input pause
value: 'event: ping
data: {"event": "workflow_started", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "message_id": "2e4f6a8b-1c3d-5e7f-9a0b-2c4d6e8f0a1b", "conversation_id": "9d3a2f1b-6c7d-4e8f-a0b1-c2d3e4f5a6b7", "created_at": 1705407629, "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "workflow_id": "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345", "inputs": {"draft": "Hello"}, "created_at": 1705407629, "reason": "initial"}}
data: {"event": "human_input_required", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "message_id": "2e4f6a8b-1c3d-5e7f-9a0b-2c4d6e8f0a1b", "conversation_id": "9d3a2f1b-6c7d-4e8f-a0b1-c2d3e4f5a6b7", "created_at": 1705407629, "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"form_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "form_token": "tok_abc123", "node_id": "approval_node", "node_title": "Approval", "form_content": "Please review the draft.", "inputs": [{"type": "paragraph", "output_variable_name": "comment", "default": null}], "actions": [{"id": "approve", "title": "Approve", "button_style": "primary"}], "display_in_ui": false, "resolved_default_values": {"comment": ""}, "expiration_time": 1705494029}}
data: {"event": "workflow_paused", "task_id": "c3800678-a077-43df-a102-53f23ed20b88", "message_id": "2e4f6a8b-1c3d-5e7f-9a0b-2c4d6e8f0a1b", "conversation_id": "9d3a2f1b-6c7d-4e8f-a0b1-c2d3e4f5a6b7", "created_at": 1705407629, "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "paused_nodes": ["approval_node"], "outputs": {}, "reasons": [{"TYPE": "human_input_required", "form_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "form_content": "Please review the draft.", "inputs": [{"type": "paragraph", "output_variable_name": "comment", "default": null}], "actions": [{"id": "approve", "title": "Approve", "button_style": "primary"}], "node_id": "approval_node", "node_title": "Approval", "resolved_default_values": {"comment": ""}, "form_token": "tok_abc123", "expiration_time": 1705494029}], "status": "paused", "created_at": 1705407629, "elapsed_time": 0.5, "total_tokens": 0, "total_steps": 1}}'
'400':
description: '- `app_unavailable` : App unavailable or misconfigured.
- `not_chat_app` : App mode does not match the API route.
- `provider_not_initialize` : No valid model provider credentials found.
- `provider_quota_exceeded` : Model provider quota exhausted.
- `model_currently_not_support` : Current model unavailable.
- `completion_request_error` : Text generation failed.
- `bad_request` : Cannot use draft workflow version.
- `bad_request` : Invalid `workflow_id` format.
- `bad_request` : `blocking` response mode with an Agent app.
- `invalid_param` : The Agent app has no bound Agent.
- `agent_not_published` : The bound Agent has no published version. (Agent apps)
- `conversation_completed` : The conversation has ended; start a new one by omitting `conversation_id`.'
content:
application/json:
examples:
app_unavailable:
summary: app_unavailable
value:
status: 400
code: app_unavailable
message: App unavailable, please check your app configurations.
not_chat_app:
summary: not_chat_app
value:
status: 400
code: not_chat_app
message: Please check if your app mode matches the right API route.
provider_not_initialize:
summary: provider_not_initialize
value:
status: 400
code: provider_not_initialize
message: No valid model provider credentials found. Please go to Settings -> Model Provider to complete your provider credentials.
provider_quota_exceeded:
summary: provider_quota_exceeded
value:
status: 400
code: provider_quota_exceeded
message: Your quota for Dify Hosted OpenAI has been exhausted. Please go to Settings -> Model Provider to complete your own provider credentials.
model_currently_not_support:
summary: model_currently_not_support
value:
status: 400
code: model_currently_not_support
message: Dify Hosted OpenAI trial currently not support the GPT-4 model.
completion_request_error:
summary: completion_request_error
value:
status: 400
code: completion_request_error
message: Completion request failed.
is_draft_workflow:
summary: bad_request
value:
status: 400
code: bad_request
message: 'Cannot use draft workflow version. Workflow ID: a1b2c3d4-5678-90ab-cdef-1234567890ab. '
workflow_id_format_error:
summary: bad_request
value:
status: 400
code: bad_request
message: 'Invalid workflow_id format: ''not-a-valid-id''. '
new_agent_streaming_only:
summary: bad_request
value:
code: bad_request
message: Agent App only supports streaming response mode.
status: 400
new_agent_not_bound:
summary: invalid_param
value:
code: invalid_param
message: Agent App has no bound Agent
status: 400
new_agent_not_published:
summary: agent_not_published
value:
code: agent_not_published
message: Agent has not been published. Please publish the Agent before using the API.
status: 400
conversation_completed:
summary: conversation_completed
value:
status: 400
code: conversation_completed
message: The conversation has ended. Please start a new conversation.
'403':
description: '`workflow_version_execution_not_allowed` : A Chatflow request pinned a workflow version via `workflow_id` on the Dify Cloud Sandbox plan.'
content:
application/json:
examples:
workflow_version_execution_not_allowed:
summary: workflow_version_execution_not_allowed
value:
status: 403
code: workflow_version_execution_not_allowed
message: Workflow version execution is not available on your current plan. Please upgrade to a paid plan.
'404':
description: '- `not_found` : Conversation does not exist.
- `not_found` : Workflow not found with the specified `workflow_id`.'
content:
application/json:
examples:
conversation_not_exists:
summary: not_found
value:
status: 404
code: not_found
message: Conversation Not Exists.
workflow_not_found:
summary: not_found
value:
status: 404
code: not_found
message: 'Workflow not found with id: a1b2c3d4-5678-90ab-cdef-1234567890ab'
'429':
description: '- `too_many_requests` : Too many concurrent requests for this app.
- `rate_limit_error` : The workspace''s Dify Cloud quota for workflow executions has been exhausted.'
content:
application/json:
examples:
too_many_requests:
summary: too_many_requests
value:
status: 429
code: too_many_requests
message: Too many requests. Please try again later.
rate_limit_error:
summary: rate_limit_error
value:
status: 429
code: rate_limit_error
message: Rate Limit Error
'500':
description: '`internal_server_error` : Internal server error.'
content:
application/json:
examples:
internal_server_error:
summary: internal_server_error
value:
status: 500
code: internal_server_error
message: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
x-mint:
href: /en/api-reference/chat-messages/send-chat-message
metadata:
title: Send Chat Message
sidebarTitle: Send Chat Message
/chat-messages/{task_id}/stop:
post:
summary: Stop Chat Message Generation
description: '**Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps.
Stops a chat message generation task. Only supported in `streaming` mode.'
operationId: stopChatMessageGeneration
tags:
- Chat Messages
parameters:
- name: task_id
in: path
required: true
description: Task ID, from the streaming events of [Send Chat Message](/en/api-reference/chat-messages/send-chat-message).
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- user
properties:
user:
type: string
description: End-user identifier, defined by your app and unique within it. Must match the `user` sent with the original message; if it differs, the stop silently does nothing and still returns success. See [End User Identity](/en/api-reference/guides/end-user-identity).
examples:
example:
summary: Request Example
value:
user: abc-123
responses:
'200':
$ref: '#/components/responses/SuccessResult'
'400':
description: '- `not_chat_app` : App mode does not match the API route.
- `invalid_param` : The required `user` field is missing.'
content:
application/json:
examples:
not_chat_app:
summary: not_chat_app
value:
status: 400
code: not_chat_app
message: Please check if your app mode matches the right API route.
invalid_param:
summary: invalid_param
value:
status: 400
code: invalid_param
message: Arg user must be provided.
x-mint:
href: /en/api-reference/chat-messages/stop-chat-message-generation
metadata:
title: Stop Chat Message Generation
sidebarTitle: Stop Chat Message Generation
/messages/{message_id}/suggested:
get:
summary: Get Next Suggested Questions
description: '**Available for**: Chatflow, Agent, Chatbot, Legacy Agent apps.
Returns the follow-up questions suggested for a message.'
operationId: getSuggestedQuestions
tags:
- Chat Messages
parameters:
- name: message_id
in: path
required: true
description: ID of the message to get suggestions for. Get it from a chat response or [List Conversation Messages](/en/api-reference/conversations/list-conversation-messages).
schema:
type: string
format: uuid
- name: user
in: query
required: true
description: End-user identifier, defined by your app and unique within it. See [End User Identity](/en/api-reference/guides/end-user-identity).
schema:
type: string
responses:
'200':
description: Successfully retrieved suggested questions.
content:
application/json:
schema:
$ref: '#/components/schemas/SuggestedQuestionsResponse'
examples:
suggestedQuestions:
summary: Response Example
value:
result: success
data:
- What colors does the iPhone 13 Pro Max come in?
- How does the battery compare to iPhone 12?
- What is the price range?
'400':
description: '- `not_chat_app` : App mode does not match the API route.
- `bad_request` : Suggested questions feature is disabled.'
content:
application/json:
examples:
not_chat_app:
summary: not_chat_app
value:
status: 400
code: not_chat_app
message: Please check if your app mode matches the right API route.
bad_request:
summary: bad_request
value:
status: 400
code: bad_request
message: Suggested Questions Is Disabled.
'404':
description: '`not_found` : Message does not exist.'
content:
application/json:
examples:
message_not_exists:
summary: not_found
value:
status: 404
code: not_found
message: Message Not Exists.
'500':
description: '`internal_server_error` : Internal server error.'
content:
application/json:
examples:
internal_server_error:
summary: internal_server_error
value:
status: 500
code: internal_server_error
message: The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
x-mint:
href: /en/api-reference/chat-messages/get-next-suggested-questions
metadata:
title: Get Next Suggested Questions
sidebarTitle: Get Next Suggested Questions
components:
schemas:
SuggestedQuestionsResponse:
type: object
properties:
result:
type: string
description: Result status.
data:
type: array
items:
type: string
description: List of suggested questions.
RetrieverResource:
type: object
description: Citation and attribution information for a retriever resource.
properties:
id:
type: string
format: uuid
description: Unique ID of the retriever resource.
message_id:
type: string
format: uuid
description: ID of the message this resource belongs to.
position:
type: integer
description: Position of the resource in the list.
dataset_id:
type: string
format: uuid
description: ID of the knowledge base.
dataset_name:
type: string
description: Name of the knowledge base.
document_id:
type: string
format: uuid
description: ID of the document.
document_name:
type: string
description: Name of the document.
data_source_type:
type: string
description: Type of the data source.
segment_id:
type: string
format: uuid
description: ID of the specific chunk within the document.
score:
type: number
format: float
description: Similarity score of the resource.
hit_count:
type: integer
description: Number of times this chunk was hit.
word_count:
type: integer
description: Word count of the chunk.
segment_position:
type: integer
description: Position of the chunk within the document.
index_node_hash:
type: string
description: Hash of the index node.
content:
type: string
description: Content snippet from the resource.
summary:
type:
- string
- 'null'
description: Summary of the chunk content.
created_at:
type: integer
format: int64
description: Creation timestamp (Unix epoch seconds).
Usage:
type: object
description: Model usage information.
properties:
prompt_tokens:
type: integer
description: Number of tokens in the prompt.
prompt_unit_price:
type: string
format: decimal
description: Unit price per prompt token.
prompt_price_unit:
type: string
format: decimal
description: Price unit for prompt tokens.
prompt_price:
type: string
format: decimal
description: Total price for prompt tokens.
completion_tokens:
type: integer
description: Number of tokens in the completion.
completion_unit_price:
type: string
format: decimal
description: Unit price per completion token.
completion_price_unit:
type: string
format: decimal
description: Price unit for completion tokens.
completion_price:
type: string
format: decimal
description: Total price for completion tokens.
total_tokens:
type: integer
description: Total number of tokens used.
total_price:
type: string
format: decimal
description: Total price for all tokens
# --- truncated at 32 KB (38 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/dify/refs/heads/main/openapi/dify-chat-messages-api-openapi.yml