aiprompts/openai-request.md
This document describes the actual JSON structure sent to the OpenAI API in the input field of OpenAIRequest.
The input field is a JSON array containing one of three object types:
OpenAIMessage objectsOpenAIFunctionCallInput objectsOpenAIFunctionCallOutputInput objectsThese are converted from OpenAIChatMessage internal format and cleaned before transmission (see lines 485-494).
User and assistant messages sent as OpenAIMessage:
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello, analyze this image"
},
{
"type": "input_image",
"image_url": "data:image/png;base64,iVBORw0KG..."
}
]
}
Key Points:
role: Always "user" or "assistant"content: Always an array of content blocks (never a plain string){
"type": "input_text",
"text": "message content here"
}
{
"type": "input_image",
"image_url": "data:image/png;base64,..."
}
filename field is removed during cleaning{
"type": "input_file",
"file_data": "JVBERi0xLjQKJeLjz9M...",
"filename": "document.pdf"
}
file_data: Base64-encoded PDF content{
"type": "function_call",
"call_id": "call_abc123",
"name": "search_files",
"arguments": {"query": "test"}
}
Tool calls from the model sent as OpenAIFunctionCallInput:
{
"type": "function_call",
"call_id": "call_abc123",
"name": "search_files",
"arguments": "{\"query\":\"test\",\"path\":\"./src\"}"
}
Key Points:
type: Always "function_call"call_id: Unique identifier generated by modelname: Function name to executearguments: JSON-encoded string of parametersstatus: Optional ("in_progress", "completed", "incomplete")toolusedata field is removed during cleaningTool execution results sent as OpenAIFunctionCallOutputInput:
{
"type": "function_call_output",
"call_id": "call_abc123",
"output": "Found 3 files matching query"
}
Key Points:
type: Always "function_call_output"call_id: Must match the original function call's call_idoutput: Can be text, image array, or error object{
"type": "function_call_output",
"call_id": "call_abc123",
"output": "Result text here"
}
{
"type": "function_call_output",
"call_id": "call_abc123",
"output": [
{
"type": "input_image",
"image_url": "data:image/png;base64,..."
}
]
}
{
"type": "function_call_output",
"call_id": "call_abc123",
"output": "{\"ok\":\"false\",\"error\":\"File not found\"}"
}
ok and error fields{
"model": "gpt-4o",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "What files are in src/?"
}
]
},
{
"type": "function_call",
"call_id": "call_xyz789",
"name": "list_files",
"arguments": "{\"path\":\"src/\"}"
},
{
"type": "function_call_output",
"call_id": "call_xyz789",
"output": "main.go\nutil.go\nconfig.go"
},
{
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "The src/ directory contains 3 files: main.go, util.go, and config.go"
}
]
}
],
"stream": true,
"max_output_tokens": 4096
}
Before transmission, internal fields are removed (cleanup code):
previewurl field removed, filename removed from input_image blockstoolusedata field removedThis ensures the API receives only the fields it expects.