Skip to content

Multi-Modality

CompactifAI API’s chat completion endpoint supports multi-modality, empowering you to seamlessly process and generate across text and images. This enables richer interactions and more versatile applications—all while maintaining exceptional performance at reduced costs.

import requests
API_URL = "https://api.compactif.ai/v1/chat/completions"
API_KEY = "your_api_key_here"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"model": "mistral-small-3-1",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}
],
"temperature": 0.7
}
response = requests.post(API_URL, headers=headers, json=data)
print(response.json()["choices"][0]["message"]["content"])
FieldTypeDescription
modelstringID of the compressed model to use
messagesarrayArray of message objects
temperaturenumberControls randomness (0-2)
top_pnumberControls diversity via nucleus sampling
nintegerNumber of completions to generate
max_tokensintegerMaximum number of tokens to generate
streambooleanWhether to stream back partial progress
stopstring or arraySequences where the API will stop generating
toolsarrayList of tools the model may call during generation
tool_choicestringControls tool usage ("auto", "none","required", or specific function)

Messages must be an array of objects with the following structure:

{
"role": "user"|"assistant",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
}
]
}

PS: The multimodal accepts also the by default input(the one mentioned in the basic usage).

{
"id": "chatcmpl-ca2af32f-6ba9-4621-803f-1175312f68ba",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "The image depicts a serene, natural landscape featuring a wooden boardwalk that extends into the distance. The boardwalk is surrounded by tall, lush green grasses and various types of vegetation. The sky above is a clear blue with scattered, wispy clouds. In the background, there are clusters of trees with green and autumn-colored leaves, suggesting a transition into the fall season. The overall atmosphere of the image is calm and inviting, ideal for a peaceful walk in nature.",
"refusal": null,
"role": "assistant",
"annotations": null,
"audio": null,
"function_call": null,
"tool_calls": [
],
"reasoning_content": null
},
"stop_reason": null
}
],
"created": 1758286672,
"model": "mistral-small-3-1",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": null,
"usage": {
"completion_tokens": 97,
"prompt_tokens": 2199,
"total_tokens": 2296,
"completion_tokens_details": null,
"prompt_tokens_details": null
},
"prompt_logprobs": null,
"kv_transfer_params": null
}
Model NameModel IDMultiModal Compatible?
DeepSeek R1 0528 Slim by CompactifAIcai-deepseek-r1-0528-slimNo
Llama 4 Scout Slim by CompactifAIcai-llama-4-scout-slimNo
Llama 4 Scoutllama-4-scoutNo
Llama 3.3 70B Slim by CompactifAIcai-llama-3-3-70b-slimNo
Llama 3.3 70Bllama-3-3-70bNo
Llama 3.1 8B Slim by CompactifAIcai-llama-3-1-8b-slimNo
Llama 3.1 8B Slim Reasoning by CompactifAIcai-llama-3-1-8b-slim-rNo
Llama 3.1 8Bllama-3-1-8bNo
Mistral Small 3.1 Slim by CompactifAIcai-mistral-small-3-1-slimNo
Mistral Small 3.1mistral-small-3-1Yes
OpenAI GPT OSS 20Bgpt-oss-20bNo
OpenAI GPT OSS 120Bgpt-oss-120bNo