Skip to main content
Point base_url at https://gateway.vlm.run/v1/openai in any OpenAI SDK and you can start making requests. This page covers setup and the two most common request shapes: visual Q&A and document OCR. See Introduction for the rationale behind the VLM Run Gateway.

Prerequisites

pip install openai
export VLMRUN_API_KEY="your-api-key"
Base URL: https://gateway.vlm.run/v1/openai. Use Authorization: Bearer <VLMRUN_API_KEY>, or omit the header for anonymous access. See Authentication and Rate Limits.

Visual Q&A

Send a question with an optional image. See Models for available models.
from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.vlm.run/v1/openai",
    api_key="<VLMRUN_API_KEY>",
)

response = client.chat.completions.create(
    model="qwen/qwen3.5-0.8b",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What is happening in this image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/image.generation/sf-golden-gate.jpg",
                    },
                },
            ],
        }
    ],
)

print(response.choices[0].message.content)

Document and Image OCR

Pass a PDF as a document_url content part and select a per-page method. See Models and Flexible Document OCR for the full pipeline.
from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.vlm.run/v1/openai",
    api_key="<VLMRUN_API_KEY>",
)

response = client.chat.completions.create(
    model="paddleocr/pp-ocrv6",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "document_url",
                    "document_url": {
                        "url": "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.markdown/goog-10-k-2024.pdf"
                    },
                }
            ],
        }
    ],
    extra_body={
        "method": "ocr",
        "document_dpi": 150,
    },
)

print(response.choices[0].message.content)

Next steps

Flexible Document OCR

Request knobs, page blocks, and streaming for PDFs.

Models

Catalog, capabilities, and model selection.

Authentication

Anonymous vs API key access and rate limits.

Chat Completions API

Full request parameters and response schema.