Lesson 05: Multimodal Vision and Media
Deliver multimodal prompts with images and binary media across OpenAI, Anthropic Claude, Google Gemini, and Vertex AI using unified media message creators.
1. Why This Feature Exists
Every major AI provider has an entirely different representation for image payloads (OpenAI uses image_url base64 data URIs; Gemini uses inlineData parts; Claude uses image source objects). Merci SDK isolates this divergence into a single helper.
2. Key Symbols and Exports
3. Implementation Walkthrough
import {
ProviderType,
resolveProvider,
initializeClient,
loadCredentials,
getDefaultModel,
createUnifiedMediaMessages
} from 'merci-sdk';
const PROVIDER = resolveProvider();
const { client } = await initializeClient({ provider: PROVIDER, options: loadCredentials({ provider: PROVIDER }) });
const mediaMessages = await createUnifiedMediaMessages({
provider: PROVIDER,
prompt: 'Describe what you see in this image in detail.',
imagePath: 'examples/fixtures/image.png'
});
const session = client.session(getDefaultModel({ provider: PROVIDER }));
const stream = session.step({ messages: mediaMessages });
for await (const event of stream) {
if (event.type === 'text') process.stdout.write(event.content);
}4. Wire and Telemetry Mechanics
The adapter inspects the current PROVIDER and transforms the unified media message into the provider's exact specification before dispatching the HTTP request.
5. Run the Example
Execute the runnable example directly from the repository root:
node examples/10_multimodal.mjsRead the full example: examples/10_multimodal.mjs →