Image analysis in chat completions is only supported with the Palmyra X5 model. Other models don’t support the
image_url
content type.You need an API key to access the Writer API. Get an API key by following the steps in the API quickstart.We recommend setting the API key as an environment variable in a
.env
file with the name WRITER_API_KEY
.Overview
Mixed content support allows you to send messages that contain both text and images in a chat with Palmyra X5. Instead of using the separate Vision tool, you can now include images directly in your chat messages, making conversations more natural and contextual.How it works
When sending a message to the chat completion endpoint, you can use thecontent
field in two ways:
- Text-only message:
- Mixed content message:
Endpoint
URL:POST https://api.writer.com/v1/chat
Content fragment types
Text fragment
Image fragment
Examples
Single image analysis
This example shows how to send a message with a single image. Thecontent
field is an array of content fragments, where each fragment can be either text or image.
The text fragment includes the message for the model to analyze. The image fragment includes the image URL.
Using local images with data URLs
You can also use data URLs to send local images without uploading them to a remote server. This is useful for testing or when working with local files:Multiple images with text
You can include multiple images in a single message:Next steps
- Learn about chat completions for text-based conversations
- Explore the Vision tool for dedicated image analysis
- Check out Palmyra X5 model capabilities