Skip to content

Fix annotation schema to accept "file" type for file uploads #201

@HashimMufti

Description

@HashimMufti

Problem

The annotation validation schema only accepts type: "url_citation", but OpenRouter API returns
type: "file" when processing file uploads (PDFs, images, etc.) with vision models. This
causes validation errors that prevent users from using file processing features.

Error

AI_TypeValidationError: Invalid input: expected "url_citation"
path: ["choices", 0, "message", "annotations", 0, "type"]

Root Cause

When OpenRouter processes files with models like qwen/qwen3-235b-a22b-2507 or other
vision models using the pdf-text or mistral-ocr engines, it returns file annotations as a
cost optimization feature (see OpenRouter docs on skipping parsing
costs
).

The current schema in src/chat/schemas.ts only validates type: "url_citation", causing the
validation to fail when type: "file" is returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions