CLIProxyAPI
CLIProxyAPI copied to clipboard
[Bug] `/v1/responses` -> Claude sets `application/octet-stream` on raw-base64 `input_file` PDFs (ignoring `.pdf` filename) and stringifies non-array `function_call_output` media
Is it a request payload issue? [x] Yes, this is a request payload issue. I am using a client/cURL to send a request payload, but I received an unexpected error. [ ] No, it's another issue.
Describe the bug
In the OpenAI Responses -> Claude translator (internal/translator/claude/openai/responses/claude_openai-responses_request.go) on main (7df56074), there are two native multimodal translation bugs:
- Raw-base64
input_fileignoresfilename: "*.pdf"and emitsmedia_type: "application/octet-stream"(lines 447-464and1619-1638):- OpenAI Responses clients allow
input_filewith either adata:application/pdf;base64,...URI or raw base64file_data+"filename": "report.pdf"(which CLIProxyAPI's Gemini/Codex translators accept viaNormalizeOpenAIFileData+ filename fallback). - However,
claude_openai-responses_request.gohardcodesmediaType := "application/octet-stream"wheneverfileDatadoes not start withdata:, ignoringpart.Get("filename")and PDF%PDF-(JVBERi0) magic prefixes. Anthropic/v1/messagesrejectsdocumentblocks withmedia_type: "application/octet-stream"with HTTP 400.
- OpenAI Responses clients allow
- Non-array object
function_call_output.outputand unsupported media parts (lines 1231-1272):applyResponsesToolResultContentDocchecks onlyoutput.IsArray(). Iffunction_call_output.outputis a single media object (whichgemini_openai-responses_request.go:1749-1778supports), it falls through totoolResultDoc.Set("content", output.String()), dumping raw base64 JSON as plain text.- Similarly, in
openai_openai-responses_request.go:655-675, 690-736(Responses -> OpenAI Chat),input_fileinsidefunction_call_output.outputfalls back to raw JSON text instead of native file relay or explicit error.
CLI Type
claude code (via /v1/responses OpenAI Responses translator)
Model Name
claude-sonnet-4-6, claude-opus-4-6
LLM Client
OpenAI SDK (client.responses.create) / cURL
Request Information
curl http://127.0.0.1:8317/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "claude-sonnet-4-6",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "What two words are inside this PDF?"
},
{
"type": "input_file",
"filename": "sample.pdf",
"file_data": "JVBERi0xLjQKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqCjIgMCBvYmo8PC9UeXBlL1BhZ2VzL0NvdW50IDEvS2lkc1szIDAgUl0+PmVuZG9iagozIDAgb2JqPDwvVHlwZS9QYWdlL1BhcmVudCAyIDAgUi9NZWRpYUJveFswIDAgMjAwIDIwMF0vQ29udGVudHMgNCAwIFIvUmVzb3VyY2VzPDwvRm9udDw8L0YxIDUgMCBSPj4+Pj4+ZW5kb2JqCjQgMCBvYmo8PC9MZW5ndGggNDQ+PnN0cmVhbQpCVCAvRjEgMTggVGYgMjAgMTAwIFRkIChIZWxsbyBQREYpIFRqIEVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iajw8L1R5cGUvRm9udC9TdWJ0eXBlL1R5cGUxL0Jhc2VGb250L0hlbHZldGljYT4+ZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDUyIDAwMDAwIG4gCjAwMDAwMDAxMDEgMDAwMDAgbiAKMDAwMDAwMDIxMiAwMDAwMCBuIAowMDAwMDAwMzA1IDAwMDAwIG4gCnRyYWlsZXI8PC9TaXplIDYvUm9vdCAxIDAgUj4+CnN0YXJ0eHJlZgozNzUKJSVFT0YK"
}
]
}
]
}'
Expected behavior
- Infer
application/pdffromfilenameextension (.pdf) or%PDF-base64 prefix (JVBERi0) whenfile_datais raw base64, and handlefile_url-> Claude URLdocumentsource ({"type": "url", "url": ...}). - Support single-object
function_call_output.outputconsistently with arrayoutput, and reject unsupported binary modalities rather than dumping base64 as text.
OS Type
- OS: Linux (x86_64) / macOS