Image to Text Inference
A simple example that uses the OpenAI Python client to send an inference request, which contains a base64 encoded PNG image.
Setup
Copy .env.example to .env and configure your access to the service:
cd examples/python
cp image-to-text/.env.example image-to-text/.env
The .env file will be loaded automatically by the example script:
OPENAI_BASE_URL=https://chat.exa4mind.eu/p/<project_id>/openai/v1
OPENAI_API_KEY=<your-lexis-platform-access-token>
OPENAI_MODEL_NAME=Qwen/Qwen3-VL-8B-Instruct
Get a LEXIS Platform Access Token
Visit the LEXIS Platform AI app and select your inference project. Go to the Inference service page and copy the Authentication Token. Paste it into the example's OPENAI_API_KEY env variable. The token should be valid for several hours.
OPENAI_MODEL_NAME can be picked from the OpenAI API models endpoint.
Note that the model must have image processing capability.
For simplicity it's pre-configured to use Qwen/Qwen3-VL-8B-Instruct, which has been tested to work well with this example.
Run using uv
uv is a fast Python package and project manager.
All examples share a single virtual environment under examples/python/.
- Create the virtual environment and install all dependencies:
bash
cd examples/python
uv sync
- Run the example:
bash
uv run python image-to-text/main.py ./test.png "Describe the image in 2 sentences"
The output should look something like:
Model warmup starting. This might take several minutes
.
.
.
This is a close-up shot of a red fox with its eyes tightly shut and mouth wide open in what appears to be a yawn or a joyful expression.
...
Feel free to replace ./test.png with a path to your own PNG image.