Multimodal

PDFs

Read a PDF through a model route that advertises native file input.

Use a Chat Completions file part with a filename and inline PDF data URL. The catalogue's file_input declaration identifies eligible routes. The example below uses native document input; provider page/context limits apply. Replace <model-id> with a model whose Chat endpoint advertises file_input in GET /v1/models. Check endpoint capabilities before pinning a provider.

Run a request

Use Python 3 or Node 22, and export TOKENHUB_API_KEY from your secret store. Download the sample, or replace it with your own file of the same format. Each model request uses your account's paid allowance.

bash
curl --fail "https://aihub.belive.sg/samples/apps/doc-wholesale-list.pdf" -o document.pdf
python3 - <<'PY'
import base64, json
from pathlib import Path

encoded = base64.b64encode(Path("document.pdf").read_bytes()).decode("ascii")
body = {
    "model": "<model-id>",
    "max_tokens": 4000,
    "messages": [{"role": "user", "content": [
        {"type": "text", "text": "Summarize the products in this document."},
        {"type": "file", "file": {"filename": "document.pdf", "file_data": "data:application/pdf;base64," + encoded}},
    ]}],
}
Path("request.json").write_text(json.dumps(body))
PY
curl --fail-with-body "https://tokenhub-api.belive.sg/api/v1/chat/completions" \
  -H "Authorization: Bearer $TOKENHUB_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @request.json

The response is a normal Chat Completion: read the assistant content, reported usage and X-Generation-Id.

PDF support boundaries

There is no gateway guarantee that a PDF will be parsed for every model. AI Hub does not provide OpenRouter's file-parser plugin or its automatic OCR fallback. The Messages compatibility route rejects document blocks, and Responses does not translate input_file. Uploaded AI Hub file IDs are not resolved as PDF chat attachments. For extraction or OCR, use an applicable Capability API.

Choose a model and route

Read GET /api/v1/models in your environment. architecture.input_modalities describes a model, while each endpoint's capabilities identifies the serving route: vision for images, audio_input, video_input or file_input. Check the Models page for available routes. The examples pin a declared route; use a different eligible route only with its own supported request form.

Limits, cost and failures

Base64 increases the request size. The synchronous chat body limit defaults to 20 MiB, and provider format, duration, page and context limits also apply. Keep inline samples small; an uploaded video uses a different path described below. A model's context limit is not a universal media-size limit.

Media input can contribute input tokens or a modality-specific meter. Read the selected route's price table and the resulting usage; do not estimate solely from text length. Key caps and model restrictions still apply.

Malformed input can return 400, an oversized body 413, and an unsuitable route 400 or a routing refusal. See Errors before retrying; after a timeout, reconcile before resubmitting.

Support and limits

Each protocol has its own media block: URL and data inputs and uploaded file IDs have their own schemas and size limits, and a model's page lists its input modalities. PDFs, audio and video are refused on routes that do not take them.

Gateway validation, defaults and response forms are in the operation index and the OpenAPI schemas.

Error codes and recovery are in Errors and recovery. Keep the request or job ID from each response: it identifies the call in Activity and for support.