For the complete documentation index, see llms.txt. This page is also available as Markdown.

Chat With File Attachments

Chat with File Attachments

post

Send images and PDF documents as part of your message request.

Header parameters
AuthorizationstringRequiredExample: sk-lZxz
Body
modelstringRequired
streambooleanRequired
Responses
200Success
application/json
costnumberRequired
idstringRequired
modelstringRequired
rolestringRequired
stop_reasonstringRequired
stop_sequencenullRequired
typestringRequired
post/v1/messages
POST /v1/messages HTTP/1.1
Host: llm.onerouter.pro
Authorization: text
Content-Type: application/json
Accept: */*
Content-Length: 1287

{
  "model": "anthropic/claude-opus-4.5",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "document",
          "source": {
            "type": "base64",
            "media_type": "application/pdf",
            "data": "JVBERi0xLjEKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCAzMDAgMTQ0XSAvQ29udGVudHMgNCAwIFIgL1Jlc291cmNlcyA8PCAvRm9udCA8PCAvRjEgNSAwIFIgPj4gPj4gPj4KZW5kb2JqCjQgMCBvYmoKPDwgL0xlbmd0aCAzNyA+PgpzdHJlYW0KQlQKL0YxIDI0IFRmCjcyIDcyIFRkCihIZWxsbyBQREYpIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKNSAwIG9iago8PCAvVHlwZSAvRm9udCAvU3VidHlwZSAvVHlwZTEgL0Jhc2VGb250IC9IZWx2ZXRpY2EgPj4KZW5kb2JqCnhyZWYKMCA2CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKMDAwMDAwMDI0MSAwMDAwMCBuIAowMDAwMDAwMzI4IDAwMDAwIG4gCnRyYWlsZXIKPDwgL1Jvb3QgMSAwIFIgL1NpemUgNiA+PgpzdGFydHhyZWYKMzk4CiUlRU9GCg=="
          }
        },
        {
          "type": "image",
          "source": {
            "type": "base64",
            "media_type": "image/png",
            "data": "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAFklEQVR4nGP8z8DAwMDAxMDAwMDAAAANHQEDasKb6QAAAABJRU5ErkJggg=="
          }
        },
        {
          "type": "text",
          "text": "Please summarize the PDF and describe the image."
        }
      ]
    }
  ],
  "stream": false,
  "stream_options": {
    "include_usage": true
  },
  "usage": {
    "include": true
  }
}
200Success
{
  "content": [
    {
      "text": "## Summary\n\nThe PDF contains a single page with minimal content - just the text \"Hello PDF\" displayed prominently in the center of the page.\n\n## Image Description\n\nThe image shows a simple, clean white page with the words **\"Hello PDF\"** displayed in large, black sans-serif font, centered both horizontally and vertically on the page. The design is minimalist with no other visual elements, borders, or decorations - just the two-word greeting against a plain white background.\n\nThis appears to be a basic test or sample PDF document, commonly used to verify that PDF viewing or processing functionality is working correctly.",
      "type": "text"
    }
  ],
  "cost": 0.011225,
  "cost_details": {
    "audio_cost": 0,
    "byok_cost": 0,
    "completion_cost": 0.003325,
    "discount_rate": 1,
    "image_cost": 0,
    "is_byok": false,
    "native_web_search_cost": 0,
    "plugin_web_search_cost": 0,
    "prompt_cache_read_cost": 0,
    "prompt_cache_write_1_h": 0,
    "prompt_cache_write_5_min": 0,
    "prompt_cache_write_cost": 0,
    "prompt_cost": 0.0079,
    "reasoning_cost": 0,
    "tools_cost": 0,
    "video_cost": 0
  },
  "id": "msg_bdrk_012N3Bsu451RsjNbgjv3DXri",
  "model": "anthropic/claude-opus-4.5",
  "role": "assistant",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "type": "message",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "input_tokens": 1580,
    "output_tokens": 133
  }
}

Last updated