Skip to main content
With our new OpenAI-compatible API, you can use the popular Instructor library to interact with VLM Run. This allows developers to switch between OpenAI, Instructor and VLM Run APIs with minimal changes.

Configure the OpenAI-compatible Instructor Client with VLM Run

Since Instructor is compatible with the OpenAI API, you can use the same configuration methods as described in the OpenAI Compatibility page. Here’s an example of how to configure the Instructor client to work with VLM Run:

1. Chat Completion with Instructor

Now that you have configured the Instructor client, you can use the inst_client.chat.completions.create method to interact with VLM Run. Below is an example of how to use the Instructor client to create a chat completion:

2. Guided Chat Completion with Instructor

The example above is an unconstrained chat completion request, relying solely on the JSON schema provided to the VLM Run Agents as an instruction. In order to enforce the JSON schema, you can use the json_schema extra body parameter to guide the VLM Run Agents model to extract structured data from the image.
This will ensure that the VLM Run model generates the image and crops the clock face in the specified JSON format.