Response Formats
This reference provides detailed information about the structure and content of API responses across all endpoints.Common Response Fields
All successful responses include these standard fields:Token usage statistics for the API call
Number of input tokens processed
Number of output tokens generated
Total tokens used (input + output)
Tokens used for reasoning (if applicable)
Cached input tokens (cost savings)
Reason for response completion. Possible values:
"stop": Normal completion"length": Response truncated due to length limits"tool_calls": Response ended due to tool usage
Array of warning messages (usually empty)
Provider-specific metadata (OpenAI, etc.)
Unique request trace identifier for debugging
Generate Endpoint Response
Complete Response Structure
Step Object Structure
Type of processing step (
"initial", "tool_execution", etc.)Tool calls made during this step
Results from tool executions
Content generated during this step
Text content for this step
Streaming Response Events
Event Types
| Event Type | Description | Data Structure |
|---|---|---|
start | Run initialization | {"type":"start","runId":"uuid"} |
step-start | Step beginning | {"type":"step-start","payload":{"stepType":"initial"},"runId":"uuid"} |
text | Text content chunk | {"type":"text","text":"Hello, ","runId":"uuid"} |
tool-call | Tool call initiation | Tool call object |
tool-result | Tool execution result | Tool result object |
step-finish | Step completion | {"type":"step-finish","payload":{"finishReason":"stop"},"runId":"uuid"} |
run-finish | Run completion | {"type":"run-finish","payload":{"finishReason":"stop"},"runId":"uuid"} |
error | Error occurred | Error object |
Tool Call Event Format
Tool Result Event Format
Speech-to-Text Response
Memory Management Response
Thread Creation Response
Error Response Format
Common Error Codes
| Code | Description |
|---|---|
TOOL_EXECUTION_FAILED | Tool execution error |
MEMORY_NOT_INITIALIZED | MongoDB not configured |
INVALID_REQUEST | Malformed request |
RATE_LIMITED | Too many requests |
MODEL_ERROR | AI model processing error |
AUDIO_PROCESSING_ERROR | Speech-to-text processing failed |
Data Types Reference
Message Format
Tool Call Format
Tool Result Format
Response Size Considerations
Response Size Limits: Large responses may be truncated. Use streaming for long conversations.
Tool Results: Complex tool results are included in full, monitor response sizes.
Token Usage: Track usage statistics to manage costs and rate limits.
