cheapinference.dev
FEATURE GUIDES

Images & PDFs

Native OpenAI image and document inputs.

Image inputs

Use an OpenAI model that accepts image input. Provide a publicly accessible image URL or a supported data URL. The proxy forwards the content to the provider; it does not run an image-fetching or OCR service of its own.

import OpenAI from "openai";
const client = new OpenAI({
  baseURL: "https://www.cheapinference.dev/v1",
  apiKey: process.env.CHEAPINFERENCE_API_KEY,
});

const result = await client.responses.create({
  model: "gpt-4o", store: false,
  input: [{ role: "user", content: [
    { type: "input_text", text: "Describe this image." },
    { type: "input_image", image_url: "https://example.com/photo.jpg", detail: "auto" },
  ] }],
  max_output_tokens: 512,
});

Replace the example URL with an image you control. For Chat Completions the shape is { type: "image_url", image_url: { url, detail: "auto" } }. URL accessibility, formats, resolution limits, and model support are enforced upstream.

Inline PDF input

import OpenAI from "openai";
const client = new OpenAI({
  baseURL: "https://www.cheapinference.dev/v1",
  apiKey: process.env.CHEAPINFERENCE_API_KEY,
});

import { readFile } from "node:fs/promises";
const bytes = await readFile("report.pdf");
const result = await client.responses.create({
  model: "gpt-4o", store: false,
  input: [{ role: "user", content: [
    { type: "input_text", text: "Summarize this report." },
    { type: "input_file", filename: "report.pdf",
      file_data: `data:application/pdf;base64,${bytes.toString("base64")}` },
  ] }],
  max_output_tokens: 1024,
});

Inline file data and provider-supported file URLs avoid stored file_id references. All requests, including base64 overhead, must fit the public 4 MB body limit. This is native OpenAI file input, not OpenRouter’s file-parser plugin. There is no local OCR fallback or document store.

Usage and unsupported modalities

Vision and document input can cost more tokens than the visible text alone. Final billing uses the provider’s usage object; the initial credit hold is an estimate. Inspect actual usage instead of estimating cost from file size alone.

Image generation, speech, audio transcription, realtime audio, video, and image embeddings are not enabled in this token-metered release. Requests using unsupported modalities or hosted tools are rejected. Other providers’ multimodal formats are outside the OpenAI-only API.