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.
Image understanding
Section titled “Image understanding”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"])Fields
Section titled “Fields”| Field | Type | Description |
|---|---|---|
model | string | ID of the compressed model to use |
messages | array | Array of message objects |
temperature | number | Controls randomness (0-2) |
top_p | number | Controls diversity via nucleus sampling |
n | integer | Number of completions to generate |
max_tokens | integer | Maximum number of tokens to generate |
stream | boolean | Whether to stream back partial progress |
stop | string or array | Sequences where the API will stop generating |
tools | array | List of tools the model may call during generation |
tool_choice | string | Controls tool usage ("auto", "none","required", or specific function) |
Message Format
Section titled “Message Format”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).
Response Example
Section titled “Response Example”{ "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}Compatibility
Section titled “Compatibility”| Model Name | Model ID | MultiModal Compatible? |
|---|---|---|
| DeepSeek R1 0528 Slim by CompactifAI | cai-deepseek-r1-0528-slim | No |
| Llama 4 Scout Slim by CompactifAI | cai-llama-4-scout-slim | No |
| Llama 4 Scout | llama-4-scout | No |
| Llama 3.3 70B Slim by CompactifAI | cai-llama-3-3-70b-slim | No |
| Llama 3.3 70B | llama-3-3-70b | No |
| Llama 3.1 8B Slim by CompactifAI | cai-llama-3-1-8b-slim | No |
| Llama 3.1 8B Slim Reasoning by CompactifAI | cai-llama-3-1-8b-slim-r | No |
| Llama 3.1 8B | llama-3-1-8b | No |
| Mistral Small 3.1 Slim by CompactifAI | cai-mistral-small-3-1-slim | No |
| Mistral Small 3.1 | mistral-small-3-1 | Yes |
| OpenAI GPT OSS 20B | gpt-oss-20b | No |
| OpenAI GPT OSS 120B | gpt-oss-120b | No |