/** * llmindex.io — OpenRouter API types * Author: Simon-Pierre Boucher * Contact: contact@spboucher.ai * License: Proprietary — © Simon-Pierre Boucher, all rights reserved */ export type ContentPart = | { type: 'text'; text: string } | { type: 'image_url'; image_url: { url: string } }; export interface ChatMessage { role: 'system' | 'user' | 'assistant'; content: string | ContentPart[]; } export interface ChatRequest { model: string; messages: ChatMessage[]; temperature?: number; max_tokens?: number; seed?: number; top_p?: number; } export interface Usage { prompt_tokens: number; completion_tokens: number; total_tokens: number; } export interface ChatCompletionResponse { id: string; model: string; choices: Array<{ index: number; message: { role: string; content: string | null }; finish_reason: string | null; }>; usage?: Usage; } /** USD per 1M tokens; used for cost tracking on each call. */ export interface Pricing { promptPerM: number; completionPerM: number; } export interface ChatResult { /** Assistant text (first choice), '' if empty. */ text: string; raw: ChatCompletionResponse; usage: Usage | null; latencyMs: number; /** Computed from usage × pricing when pricing is provided. */ costUsd: number | null; /** Exact request params sent (audit trail). */ requestParams: ChatRequest; } export interface ORModel { id: string; name: string; context_length?: number | null; pricing?: { prompt: string; completion: string } | null; architecture?: { modality?: string | null; input_modalities?: string[] | null } | null; }