Vision
Send images with your text, in the same call.
On this page
Both models read images. There is no separate endpoint or model: put an image part in a user message of a normal Chat Completions call.
Send an image
An image is a content part of type image_url, next to a text part. Its url is either a data URL with the image in base64 (no upload step) or an https address the model can reach.
curl
# Linux. On macOS: B64=$(base64 -i image.png)B64=$(base64 -w0 image.png)curl https://api.dipoleml.com/v1/chat/completions \ -H "Authorization: Bearer $RAVEN_API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"model\": \"Raven Flash\", \"messages\": [{ \"role\": \"user\", \"content\": [ {\"type\": \"text\", \"text\": \"In one sentence, what is in this image?\"}, {\"type\": \"image_url\", \"image_url\": {\"url\": \"data:image/png;base64,$B64\"}} ] }] }"python
import base64, osfrom openai import OpenAIclient = OpenAI( base_url="https://api.dipoleml.com/v1", api_key=os.environ["RAVEN_API_KEY"],)with open("image.png", "rb") as f: b64 = base64.b64encode(f.read()).decode()resp = client.chat.completions.create( model="Raven Flash", messages=[{ "role": "user", "content": [ {"type": "text", "text": "In one sentence, what is in this image?"}, {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}}, ], }],)print(resp.choices[0].message.content)The answer has the usual shape. A request with images works with every other field of the call, including stream and tools.
Good to know
- Name the image's real media type in a data URL (
data:image/png;base64,...for a PNG file). - An image counts as input. There is no separate charge per image: the request is billed by the tokens in its
usage(API Credits). - A web address must be reachable from the internet. If the model cannot read an image, the call is refused with
400and the codeunsupported_input. - Images go in
usermessages. Earlier images stay in the history you send, so they count as input again on every later call.