-
Notifications
You must be signed in to change notification settings - Fork 326
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Please update gptel first -- errors are often fixed by the time they're reported.
- I have updated gptel to the latest commit and tested that the issue still exists
Bug Description
I can not send pdf file in GPT-4o and Gemini 2.5 pro from context (gptel-add-file) or using standalone links to the file in the buffer while using gptel with through OpenRouter.ai. After gptel-send comand I get error
OpenRouter error: (HTTP/2 400) Provider returned error
When sending a text-only query or query with image, everything works well.
The OpenRouter website says that this error code means - 400: Bad Request (invalid or missing params, CORS).
Backend
None
Steps to Reproduce
My gptel config is:
(require 'gptel)
(setq gptel-model 'deepseek/deepseek-r1-0528:free
gptel-default-mode 'org-mode
gptel-org-branching-context 'yes
gptel-backend
(gptel-make-openai "OpenRouter" ;Any name you want
:host "openrouter.ai"
:endpoint "/api/v1/chat/completions"
:stream t
:key "my key"
:models '(deepseek/deepseek-r1:free
openai/chatgpt-4o-latest
openai/gpt-4o-mini
(openai/gpt-4o
:capabilities (media tool-use json url)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp" "application/pdf"))
openai/o4-mini-high
(anthropic/claude-sonnet-4
:capabilities (media tool-use json url)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp" "application/pdf" "text/plain" "text/csv" "text/html"))
(google/gemini-2.5-pro
:capabilities (media tool-use json url)
:mime-types ("image/jpeg" "image/png" "image/gif" "image/webp" "application/pdf" "text/plain" "text/csv" "text/html")
:input-cost 1.25
:output-cost 10.00)
openai/o4-mini
openai/o3
openai/gpt-4.1)))
(setf (alist-get 'org-mode gptel-prompt-prefix-alist) "@user\n")
(setf (alist-get 'org-mode gptel-response-prefix-alist) "@assistant\n")
Additional Context
Emacs version: 29.3
Org version 9.7.30
Operation System: Ubuntu 24.04.2 LTS
Language of message: Russian
Backend: OpenRouter
Backtrace
Log Information
{
"gptel": "request body",
"timestamp": "2025-06-25 07:53:45"
}
{
"model": "openai/gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a large language model living in Emacs and a helpful assistant. Respond concisely."
},
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:application/pdf;base64,JVBERi0xLjYNJeLjz9MNCjE5MSAwIG9iag08PC9MaW5lYXJpemVkIDEvTCAxMTc3Nzg1L08gMTkzL0UgMTYzNTQ0L04gMjkvVCAxMTc3MTQ4L0ggWyA1MDcgMzc5XT4+DWVuZG9iag0gICAgICAgICAgDQoyMDYgMCBvYmoNPDwvRGVjb2RlUGFybXM8PC9Db2x1bW5zIDUvUHJlZGljdG9yIDEyPj4vRmlsdGVyL0ZsYXRlRGVjb2RlL0lEWzw4RUE2NUVERENBMDYzMTREOEMzMkE3NkNFNjM4OUZGNT48RUIwOUM0MkM4NzMzOUI0NDlDMzQyOUVBOTRDODQwNkY+XS9JbmRleFsxOTEgMzMgMjI3IDFdL0luZm8gMTkwIDAgUi9MZW5ndGggOTEvUHJldiAxMTc3MTQ5L1Jvb3QgMTkyIDAgUi9TaXplIDIyOC9UeXBlL1hSZWYvV1sxIDMgMV0+PnN0cmVhbQ0KaN5iYmRgEGBgYmBgTgORDMEgkrENRLIsAZG8b0Hk+btAknGCPogdtgysMhokYv0ArF4OTEaBSKPpcJF/ etc."
}
},
{
"type": "text",
"text": "@user \\320\\222\\321\\213\\320\\277\\320\\276\\320\\273\\320\\275\\320\\270 \\320\\260\\320\\275\\320\\260\\320\\273\\320\\270\\320\\267 \\320\\264\\320\\260\\320\\275\\320\\275\\320\\276\\320\\271 \\321\\201\\321\\202\\320\\260\\321\\202\\321\\214\\320\\270"
}
]
}
],
"stream": true,
"temperature": 1.0
}
{
"gptel": "response body",
"timestamp": "2025-06-25 07:53:51"
}
{
"error": {
"message": "Provider returned error",
"code": 400,
"metadata": {
"raw": "{\"error\":{\"code\":\"BadRequest\",\"message\":\"Invalid image URL. The URL must be a valid HTTP or HTTPS URL, or a data URL with base64 encoding.\",\"param\":null,\"type\":null}}",
"provider_name": "Azure"
}
},
"user_id": "user_2xtHxs8WWoihesHopBPG762uC6c"
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working