Skip to content

examples.demo_openai_image

Demo: OpenAI API - Image Analysis Shows how to use vllm-mlx with the OpenAI Python SDK for image understanding.

View the complete module source at #L1-L137.

API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

examples.demo_openai_image

Demo: OpenAI API - Image Analysis

Shows how to use vllm-mlx with the OpenAI Python SDK for image understanding.

Usage
  1. Start the server with a VLM model ("vision-model" is the name used in the OpenAI API): vllm-mlx serve --served-model-name vision-model mlx-community/Qwen3-VL-4B-Instruct-3bit --port 8000

  2. Run this script: python examples/demo_openai_image.py

examples.demo_openai_image.client module-attribute

client = OpenAI(base_url='http://localhost:8000/v1', api_key='not-needed')

examples.demo_openai_image.image_url module-attribute

image_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Cat03.jpg/1200px-Cat03.jpg'

examples.demo_openai_image.response module-attribute

response = client.chat.completions.create(model='vision-model', messages=messages, max_tokens=100)

examples.demo_openai_image.scene_url module-attribute

scene_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Empire_State_Building_%28aerial_view%29.jpg/800px-Empire_State_Building_%28aerial_view%29.jpg'

examples.demo_openai_image.food_url module-attribute

food_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Good_Food_Display_-_NCI_Visuals_Online.jpg/800px-Good_Food_Display_-_NCI_Visuals_Online.jpg'

examples.demo_openai_image.messages module-attribute

messages = [{'role': 'user', 'content': [{'type': 'text', 'text': 'What foods do you see in this image?'}, {'type': 'image_url', 'image_url': {'url': food_url}}]}]

Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

This module does not declare classes or functions.

Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

This module does not declare classes or functions.