Add a message to a session conversation
curl --request POST \
--url https://api.example.com/api/v1/sessions/{session_id}/messages \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"role": "<string>",
"content": "<string>",
"parts": [
{
"type": "<string>",
"text": "<string>",
"uri": "<string>",
"context_type": "<string>",
"abstract": "<string>",
"tool_id": "<string>",
"tool_name": "<string>",
"skill_uri": "<string>",
"tool_input": {},
"tool_output": "<string>",
"tool_status": "<string>"
}
]
}
'{
"status": "<string>",
"result": {
"session_id": "<string>",
"message_count": 123
},
"time": 123
}Add user or assistant messages to track conversation flow. Supports both simple text messages and structured messages with multiple parts (text, context references, tool calls).Documentation Index
Fetch the complete documentation index at: https://mintlify.com/volcengine/OpenViking/llms.txt
Use this file to discover all available pages before exploring further.
application/jsonuser or assistantparts.content and parts are provided, parts takes precedence.text, context, or toolviking://resources/docs/auth/)memory, resource, or skillpending, running, completed, or errorok or error)# Add user message
curl -X POST http://localhost:1933/api/v1/sessions/a1b2c3d4/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"role": "user",
"content": "How do I authenticate users?"
}'
curl -X POST http://localhost:1933/api/v1/sessions/a1b2c3d4/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"role": "assistant",
"parts": [
{
"type": "text",
"text": "Based on the authentication guide..."
},
{
"type": "context",
"uri": "viking://resources/docs/auth/",
"context_type": "resource",
"abstract": "OAuth 2.0 implementation guide"
}
]
}'
curl -X POST http://localhost:1933/api/v1/sessions/a1b2c3d4/messages \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"role": "assistant",
"parts": [
{
"type": "text",
"text": "Let me search for that information..."
},
{
"type": "tool",
"tool_id": "call_123",
"tool_name": "search_web",
"skill_uri": "viking://skills/search-web/",
"tool_input": {"query": "OAuth best practices"},
"tool_output": "Found 5 results...",
"tool_status": "completed"
}
]
}'
{
"status": "ok",
"result": {
"session_id": "a1b2c3d4",
"message_count": 3
},
"time": 0.1
}
TextPart(text="Your message here")
ContextPart(
uri="viking://resources/docs/auth/",
context_type="resource", # "resource", "memory", or "skill"
abstract="Brief description"
)
ToolPart(
tool_id="call_123",
tool_name="search_web",
skill_uri="viking://skills/search-web/",
tool_input={"query": "search term"},
tool_output="Results...",
tool_status="completed" # "pending", "running", "completed", "error"
)
# Search for context
results = client.search(query, session=session)
# Add message with context
session.add_message("assistant", [
TextPart(text="Based on the docs..."),
ContextPart(uri=results.resources[0].uri, context_type="resource")
])
# Mark context as actually used
session.used(contexts=[results.resources[0].uri])
# Good: Structured with parts
session.add_message("assistant", [
TextPart(text="Here's the solution:"),
ContextPart(uri="viking://resources/solution.md", context_type="resource")
])
# Avoid: Mixing URIs in text
session.add_message("assistant", [
TextPart(text="See viking://resources/solution.md for details")
])
curl --request POST \
--url https://api.example.com/api/v1/sessions/{session_id}/messages \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"role": "<string>",
"content": "<string>",
"parts": [
{
"type": "<string>",
"text": "<string>",
"uri": "<string>",
"context_type": "<string>",
"abstract": "<string>",
"tool_id": "<string>",
"tool_name": "<string>",
"skill_uri": "<string>",
"tool_input": {},
"tool_output": "<string>",
"tool_status": "<string>"
}
]
}
'{
"status": "<string>",
"result": {
"session_id": "<string>",
"message_count": 123
},
"time": 123
}